Author: chris.laprun(a)jboss.com
Date: 2010-06-20 08:14:13 -0400 (Sun, 20 Jun 2010)
New Revision: 3392
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java
Log:
- Added WSRPUtils.convertToCommonLocalizedStringOrNull method.
- Renamed WSRPUtils.convertToLocalizedString to convertToRegistrationLocalizedString.
- Fixed NPEs that could occur due to navigationalContext being possibly null.
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 2010-06-20
12:09:52 UTC (rev 3391)
+++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java 2010-06-20
12:14:13 UTC (rev 3392)
@@ -43,6 +43,7 @@
import org.oasis.wsrp.v2.InteractionParams;
import org.oasis.wsrp.v2.MarkupParams;
import org.oasis.wsrp.v2.NamedString;
+import org.oasis.wsrp.v2.NavigationalContext;
import org.oasis.wsrp.v2.PropertyDescription;
import org.oasis.wsrp.v2.StateChange;
import org.slf4j.Logger;
@@ -369,9 +370,13 @@
{
sb.append("(secure)");
}
-
sb.append("[M=").append(params.getMode()).append("][WS=").append(params.getWindowState()).append("]")
- .append("[private
NS=").append(params.getNavigationalContext().getOpaqueValue()).append("]")
- .append("[public
NS=").append(params.getNavigationalContext().getPublicValues()).append("]");
+ NavigationalContext navigationalContext = params.getNavigationalContext();
+
sb.append("[M=").append(params.getMode()).append("][WS=").append(params.getWindowState()).append("]");
+ if (navigationalContext != null)
+ {
+ sb.append("[private
NS=").append(navigationalContext.getOpaqueValue()).append("]")
+ .append("[public
NS=").append(navigationalContext.getPublicValues()).append("]");
+ }
return sb.toString();
}
return null;
@@ -456,7 +461,7 @@
}
else
{
- return convertToLocalizedString(wsrpLocalizedString);
+ return convertToRegistrationLocalizedString(wsrpLocalizedString);
}
}
@@ -465,7 +470,7 @@
* @return
* @since 2.6
*/
- public static LocalizedString
convertToLocalizedString(org.oasis.wsrp.v2.LocalizedString wsrpLocalizedString)
+ public static LocalizedString
convertToRegistrationLocalizedString(org.oasis.wsrp.v2.LocalizedString
wsrpLocalizedString)
{
ParameterValidation.throwIllegalArgExceptionIfNull(wsrpLocalizedString, "WSRP
LocalizedString");
String lang = wsrpLocalizedString.getLang();
@@ -523,6 +528,17 @@
}
}
+ public static org.gatein.common.i18n.LocalizedString
convertToCommonLocalizedStringOrNull(org.oasis.wsrp.v2.LocalizedString
wsrpLocalizedString)
+ {
+ if (wsrpLocalizedString != null)
+ {
+ return new
org.gatein.common.i18n.LocalizedString(wsrpLocalizedString.getValue(),
+ getLocale(wsrpLocalizedString.getLang()));
+ }
+
+ return null;
+ }
+
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-20
12:09:52 UTC (rev 3391)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-20
12:14:13 UTC (rev 3392)
@@ -94,6 +94,7 @@
import org.oasis.wsrp.v2.ModelDescription;
import org.oasis.wsrp.v2.ModelTypes;
import org.oasis.wsrp.v2.NamedString;
+import org.oasis.wsrp.v2.NavigationalContext;
import org.oasis.wsrp.v2.Online;
import org.oasis.wsrp.v2.PersonName;
import org.oasis.wsrp.v2.PortletContext;
@@ -125,8 +126,6 @@
import org.oasis.wsrp.v2.UserContext;
import org.oasis.wsrp.v2.UserProfile;
-import sun.reflect.generics.visitor.Reifier;
-
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;
@@ -181,7 +180,11 @@
markupParams.getMimeTypes(), markupParams.getMode(),
markupParams.getWindowState());
v1MarkupParams.setClientData(toV1ClientData(markupParams.getClientData()));
-
v1MarkupParams.setNavigationalState(markupParams.getNavigationalContext().getOpaqueValue());
+ NavigationalContext navigationalContext =
markupParams.getNavigationalContext();
+ if (navigationalContext != null)
+ {
+ v1MarkupParams.setNavigationalState(navigationalContext.getOpaqueValue());
+ }
v1MarkupParams.setValidateTag(markupParams.getValidateTag());
List<String> charSets = markupParams.getMarkupCharacterSets();
@@ -992,7 +995,7 @@
{
result = WSRP1TypeFactory.createBlockingInteractionResponse(updateResponse);
}
-
+
List<V1Extension> extensions =
WSRPUtils.transform(blockingInteractionResponse.getExtensions(), EXTENSION);
if (extensions != null)
{
@@ -1058,7 +1061,7 @@
{
V1PortletDescriptionResponse result =
WSRP1TypeFactory.createPortletDescriptionResponse(toV1PortletDescription(portletDescriptionResponse.getPortletDescription()));
result.setResourceList(toV1ResourceList(portletDescriptionResponse.getResourceList()));
-
+
List<V1Extension> extensions =
WSRPUtils.transform(portletDescriptionResponse.getExtensions(), EXTENSION);
if (extensions != null)
{
@@ -1072,7 +1075,7 @@
return null;
}
}
-
+
public static V1PropertyDescription toV1PropertyDescription(PropertyDescription
propertyDescription)
{
if (propertyDescription != null)
@@ -1093,7 +1096,7 @@
return null;
}
}
-
+
private static class V2ToV1Extension implements Function<Extension,
V1Extension>
{
public V1Extension apply(Extension from)
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java 2010-06-20
12:09:52 UTC (rev 3391)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java 2010-06-20
12:14:13 UTC (rev 3392)
@@ -46,6 +46,7 @@
import org.oasis.wsrp.v2.MarkupResponse;
import org.oasis.wsrp.v2.MissingParameters;
import org.oasis.wsrp.v2.ModifyRegistrationRequired;
+import org.oasis.wsrp.v2.NavigationalContext;
import org.oasis.wsrp.v2.OperationFailed;
import org.oasis.wsrp.v2.OperationNotSupported;
import org.oasis.wsrp.v2.PortletContext;
@@ -168,9 +169,11 @@
gm.setRuntimeContext(runtimeContext);
gm.setUserContext(userContext);
+ NavigationalContext navigationalContext = markupParams.getNavigationalContext();
String markupString =
getMarkupString(WSRPUtils.getJSR168PortletModeFromWSRPName(markupParams.getMode()),
WSRPUtils.getJSR168WindowStateFromWSRPName(markupParams.getWindowState()),
- markupParams.getNavigationalContext().getOpaqueValue(), gm);
+ navigationalContext != null ? navigationalContext.getOpaqueValue() : null,
+ gm);
markupContext.value =
WSRPTypeFactory.createMarkupContext(MediaType.TEXT_HTML.getValue(), markupString);
markupContext.value.setRequiresRewriting(Boolean.TRUE);
Show replies by date