Author: chris.laprun(a)jboss.com
Date: 2009-10-15 10:52:07 -0400 (Thu, 15 Oct 2009)
New Revision: 360
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java
Log:
- Moved existsAndIsNotEmpty methods to WSRPUtils.
- Fixed issue with getWindowStates and getModes in RequestProcessor.createPortalContext as
just checking for null wasn't enough.
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java 2009-10-15
13:55:16 UTC (rev 359)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java 2009-10-15
14:52:07 UTC (rev 360)
@@ -68,7 +68,7 @@
{
org.oasis.wsrp.v1.UserContext wsrpUserContext =
WSRPTypeFactory.createUserContext(userContextKey);
wsrpUserContext.setProfile(createUserProfileFrom(userContext));
- if (WSRPTypeFactory.existsAndIsNotEmpty(userCategories))
+ if (WSRPUtils.existsAndIsNotEmpty(userCategories))
{
wsrpUserContext.getUserCategories().addAll(userCategories);
}
@@ -79,7 +79,7 @@
{
Map<String, String> userInfos = userContext.getInformations();
- if (!WSRPTypeFactory.existsAndIsNotEmpty(userInfos))
+ if (!WSRPUtils.existsAndIsNotEmpty(userInfos))
{
return null;
}
@@ -304,7 +304,7 @@
{
List<Locale> locales = Collections.emptyList();
- if (WSRPTypeFactory.existsAndIsNotEmpty(desiredLocales))
+ if (WSRPUtils.existsAndIsNotEmpty(desiredLocales))
{
locales = new ArrayList<Locale>(desiredLocales.size());
for (String desiredLocale : desiredLocales)
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2009-10-15
13:55:16 UTC (rev 359)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2009-10-15
14:52:07 UTC (rev 360)
@@ -80,7 +80,6 @@
import org.oasis.wsrp.v1.UserContext;
import javax.xml.namespace.QName;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -366,11 +365,11 @@
markupParams.setSecureClientCommunication(secureClientCommunication);
markupParams.setMode(mode);
markupParams.setWindowState(windowState);
- if (existsAndIsNotEmpty(locales))
+ if (WSRPUtils.existsAndIsNotEmpty(locales))
{
markupParams.getLocales().addAll(locales);
}
- if (existsAndIsNotEmpty(mimeTypes))
+ if (WSRPUtils.existsAndIsNotEmpty(mimeTypes))
{
markupParams.getMimeTypes().addAll(mimeTypes);
}
@@ -783,7 +782,7 @@
public static ModelDescription createModelDescription(List<PropertyDescription>
propertyDescriptions)
{
ModelDescription description = new ModelDescription();
- if (existsAndIsNotEmpty(propertyDescriptions))
+ if (WSRPUtils.existsAndIsNotEmpty(propertyDescriptions))
{
description.getPropertyDescriptions().addAll(propertyDescriptions);
}
@@ -881,7 +880,7 @@
description.setRegistrationContext(registrationContext);
description.setPortletContext(portletContext);
description.setUserContext(userContext);
- if (existsAndIsNotEmpty(desiredLocales))
+ if (WSRPUtils.existsAndIsNotEmpty(desiredLocales))
{
description.getDesiredLocales().addAll(desiredLocales);
}
@@ -930,7 +929,7 @@
public static DestroyPortletsResponse
createDestroyPortletsResponse(List<DestroyFailed> destroyFailed)
{
DestroyPortletsResponse destroyPortletsResponse = new DestroyPortletsResponse();
- if (existsAndIsNotEmpty(destroyFailed))
+ if (WSRPUtils.existsAndIsNotEmpty(destroyFailed))
{
destroyPortletsResponse.getDestroyFailed().addAll(destroyFailed);
}
@@ -1005,7 +1004,7 @@
DestroyPortlets destroyPortlets = new DestroyPortlets();
destroyPortlets.setRegistrationContext(registrationContext);
- if (existsAndIsNotEmpty(portletHandles))
+ if (WSRPUtils.existsAndIsNotEmpty(portletHandles))
{
destroyPortlets.getPortletHandles().addAll(portletHandles);
}
@@ -1055,7 +1054,7 @@
ReleaseSessions sessions = new ReleaseSessions();
sessions.setRegistrationContext(registrationContext);
- if (existsAndIsNotEmpty(sessionIDs))
+ if (WSRPUtils.existsAndIsNotEmpty(sessionIDs))
{
sessions.getSessionIDs().addAll(sessionIDs);
}
@@ -1106,38 +1105,18 @@
MarkupType markupType = new MarkupType();
markupType.setMimeType(mimeType);
- if (existsAndIsNotEmpty(modeNames))
+ if (WSRPUtils.existsAndIsNotEmpty(modeNames))
{
markupType.getModes().addAll(modeNames);
}
- if (existsAndIsNotEmpty(windowStateNames))
+ if (WSRPUtils.existsAndIsNotEmpty(windowStateNames))
{
markupType.getWindowStates().addAll(windowStateNames);
}
- if (existsAndIsNotEmpty(localeNames))
+ if (WSRPUtils.existsAndIsNotEmpty(localeNames))
{
markupType.getLocales().addAll(localeNames);
}
return markupType;
}
-
- /**
- * @param collection
- * @return
- * @deprecated use ParameterValidation.existsAndIsNotEmpty instead
- */
- static boolean existsAndIsNotEmpty(Collection collection)
- {
- return collection != null && !collection.isEmpty();
- }
-
- /**
- * @param map
- * @return
- * @deprecated use ParameterValidation.existsAndIsNotEmpty instead
- */
- static boolean existsAndIsNotEmpty(Map map)
- {
- return map != null && !map.isEmpty();
- }
}
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java
===================================================================
--- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java 2009-10-15
13:55:16 UTC (rev 359)
+++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java 2009-10-15
14:52:07 UTC (rev 360)
@@ -47,6 +47,7 @@
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -452,4 +453,24 @@
localizedString.setResourceName(wsrpLocalizedString.getResourceName());
return localizedString;
}
+
+ /**
+ * @param collection
+ * @return
+ * @deprecated use ParameterValidation.existsAndIsNotEmpty instead
+ */
+ public static boolean existsAndIsNotEmpty(Collection collection)
+ {
+ return collection != null && !collection.isEmpty();
+ }
+
+ /**
+ * @param map
+ * @return
+ * @deprecated use ParameterValidation.existsAndIsNotEmpty instead
+ */
+ public static boolean existsAndIsNotEmpty(Map map)
+ {
+ return map != null && !map.isEmpty();
+ }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java 2009-10-15
13:55:16 UTC (rev 359)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RequestProcessor.java 2009-10-15
14:52:07 UTC (rev 360)
@@ -23,13 +23,13 @@
package org.gatein.wsrp.producer;
-import org.gatein.pc.api.Mode;
-import org.gatein.pc.api.WindowState;
import org.gatein.common.net.media.MediaType;
import org.gatein.common.util.MarkupInfo;
+import org.gatein.pc.api.Mode;
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.StateString;
+import org.gatein.pc.api.WindowState;
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
import org.gatein.pc.api.spi.PortalContext;
@@ -405,7 +405,7 @@
public Set<WindowState> getWindowStates()
{
List<String> validNewWindowStates = params.getValidNewWindowStates();
- if (validNewWindowStates != null)
+ if (WSRPUtils.existsAndIsNotEmpty(validNewWindowStates))
{
Set<WindowState> states = new
HashSet<WindowState>(validNewWindowStates.size());
for (String state : validNewWindowStates)
@@ -420,7 +420,7 @@
public Set<Mode> getModes()
{
List<String> validNewModes = params.getValidNewModes();
- if (validNewModes != null)
+ if (WSRPUtils.existsAndIsNotEmpty(validNewModes))
{
Set<Mode> modes = new HashSet<Mode>(validNewModes.size());
for (String mode : validNewModes)
Show replies by date