Author: chris.laprun(a)jboss.com
Date: 2010-06-09 10:37:04 -0400 (Wed, 09 Jun 2010)
New Revision: 3279
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1Converter.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1TypeFactory.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1ServiceDescriptionService.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/ServiceDescriptionEndpoint.java
Log:
- Finished end-to-end implementation of ServiceDescription for WSRP 1.
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 2010-06-09
13:48:51 UTC (rev 3278)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2010-06-09
14:37:04 UTC (rev 3279)
@@ -38,13 +38,13 @@
import org.gatein.pc.api.WindowState;
import org.gatein.pc.api.cache.CacheLevel;
import org.gatein.pc.api.spi.PortletInvocationContext;
+import org.gatein.wsrp.spec.v2.ErrorCodes;
import org.oasis.wsrp.v2.BlockingInteractionResponse;
import org.oasis.wsrp.v2.CacheControl;
import org.oasis.wsrp.v2.ClientData;
import org.oasis.wsrp.v2.ClonePortlet;
import org.oasis.wsrp.v2.DestroyPortlets;
import org.oasis.wsrp.v2.DestroyPortletsResponse;
-import org.gatein.wsrp.spec.v2.ErrorCodes;
import org.oasis.wsrp.v2.FailedPortlets;
import org.oasis.wsrp.v2.GetMarkup;
import org.oasis.wsrp.v2.GetPortletDescription;
@@ -328,6 +328,22 @@
return portletDescription;
}
+ public static PortletDescription createPortletDescription(String portletHandle,
List<MarkupType> markupTypes)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", null);
+ checkPortletHandle(portletHandle);
+ ParameterValidation.throwIllegalArgExceptionIfNull(markupTypes,
"MarkupType");
+ if (markupTypes.isEmpty())
+ {
+ throw new IllegalArgumentException("Cannot create a PortletDescription with
an empty list of MarkupTypes!");
+ }
+
+ PortletDescription portletDescription = new PortletDescription();
+ portletDescription.setPortletHandle(portletHandle);
+ portletDescription.getMarkupTypes().addAll(markupTypes);
+ return portletDescription;
+ }
+
private static void checkPortletHandle(String portletHandle)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", "PortletDescription");
@@ -1162,9 +1178,9 @@
}
/**
- * reason(LocalizedString)?, resourceList(ResourceList)?, extensions(Extension)*
- * errorCode(ErrorCodes)
+ * reason(LocalizedString)?, resourceList(ResourceList)?, extensions(Extension)*
errorCode(ErrorCodes)
* portletHandles(xsd:string)+
+ *
* @param portletHandles
* @param reason
* @return
@@ -1181,7 +1197,7 @@
failedPortlets.setReason(createLocalizedString(reason));
}
failedPortlets.setErrorCode(ErrorCodes.OperationFailed);
-
+
return failedPortlets;
}
@@ -1190,13 +1206,14 @@
/**
* failedPortlets(FailedPortlets)*, extensions(Extension)*
+ *
* @param failedPortlets
* @return
*/
public static DestroyPortletsResponse
createDestroyPortletsResponse(List<FailedPortlets> failedPortlets)
{
DestroyPortletsResponse dpr = new DestroyPortletsResponse();
- if(ParameterValidation.existsAndIsNotEmpty(failedPortlets))
+ if (ParameterValidation.existsAndIsNotEmpty(failedPortlets))
{
dpr.getFailedPortlets().addAll(failedPortlets);
}
@@ -1217,7 +1234,7 @@
}
}
- if(ParameterValidation.existsAndIsNotEmpty(publicNavigationalState))
+ if (ParameterValidation.existsAndIsNotEmpty(publicNavigationalState))
{
// todo: public NS GTNWSRP-38
for (Map.Entry<String, String[]> entry :
publicNavigationalState.entrySet())
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1Converter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1Converter.java 2010-06-09
13:48:51 UTC (rev 3278)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1Converter.java 2010-06-09
14:37:04 UTC (rev 3279)
@@ -23,9 +23,6 @@
package org.gatein.wsrp.spec.v1;
-import java.io.NotActiveException;
-import java.util.List;
-
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import org.gatein.common.NotYetImplemented;
@@ -42,16 +39,19 @@
import org.oasis.wsrp.v1.V1MarkupParams;
import org.oasis.wsrp.v1.V1MarkupType;
import org.oasis.wsrp.v1.V1ModelDescription;
+import org.oasis.wsrp.v1.V1ModelTypes;
import org.oasis.wsrp.v1.V1NamedString;
-import org.oasis.wsrp.v1.V1ModelTypes;
import org.oasis.wsrp.v1.V1PortletContext;
import org.oasis.wsrp.v1.V1PortletDescription;
import org.oasis.wsrp.v1.V1PropertyDescription;
import org.oasis.wsrp.v1.V1RegistrationContext;
+import org.oasis.wsrp.v1.V1Resource;
import org.oasis.wsrp.v1.V1ResourceList;
+import org.oasis.wsrp.v1.V1ResourceValue;
import org.oasis.wsrp.v1.V1RuntimeContext;
import org.oasis.wsrp.v1.V1ServiceDescription;
import org.oasis.wsrp.v1.V1SessionContext;
+import org.oasis.wsrp.v1.V1StateChange;
import org.oasis.wsrp.v1.V1UpdateResponse;
import org.oasis.wsrp.v1.V1UploadContext;
import org.oasis.wsrp.v1.V1UserContext;
@@ -65,22 +65,23 @@
import org.oasis.wsrp.v2.MarkupParams;
import org.oasis.wsrp.v2.MarkupType;
import org.oasis.wsrp.v2.ModelDescription;
+import org.oasis.wsrp.v2.ModelTypes;
import org.oasis.wsrp.v2.NamedString;
-import org.oasis.wsrp.v2.ModelTypes;
import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescription;
import org.oasis.wsrp.v2.PropertyDescription;
import org.oasis.wsrp.v2.RegistrationContext;
+import org.oasis.wsrp.v2.Resource;
import org.oasis.wsrp.v2.ResourceList;
+import org.oasis.wsrp.v2.ResourceValue;
import org.oasis.wsrp.v2.RuntimeContext;
import org.oasis.wsrp.v2.ServiceDescription;
import org.oasis.wsrp.v2.SessionContext;
+import org.oasis.wsrp.v2.StateChange;
import org.oasis.wsrp.v2.UpdateResponse;
import org.oasis.wsrp.v2.UploadContext;
import org.oasis.wsrp.v2.UserContext;
-import org.oasis.wsrp.v1.V1StateChange;
-import org.oasis.wsrp.v2.StateChange;
import java.util.List;
/**
@@ -93,10 +94,22 @@
public static final V2ToV1Extension V2_TO_V1_EXTENSION = new V2ToV1Extension();
public static final V2ToV1MarkupType V2_TO_V1_MARKUPTYPE = new V2ToV1MarkupType();
+ public static final V1ToV2MarkupType V1_TO_V2_MARKUPTYPE = new V1ToV2MarkupType();
public static final V2ToV1PortletDescription V2_TO_V1_PORTLETDESCRIPTION = new
V2ToV1PortletDescription();
+ public static final V1ToV2PortletDescription V1_TO_V2_PORTLETDESCRIPTION = new
V1ToV2PortletDescription();
public static final V2ToV1LocalizedString V2_TO_V1_LOCALIZEDSTRING = new
V2ToV1LocalizedString();
+ public static final V1ToV2LocalizedString V1_TO_V2_LOCALIZEDSTRING = new
V1ToV2LocalizedString();
public static final V2ToV1ItemDescription V2_TO_V1_ITEMDESCRIPTION = new
V2ToV1ItemDescription();
-
+
+ public static final V1ToV2ItemDescription V1_TO_V2_ITEMDESCRIPTION = new
V1ToV2ItemDescription();
+ public static final V2ToV1PropertyDescription V2_TO_V1_PROPERTYDESCRIPTION = new
V2ToV1PropertyDescription();
+ public static final V2ToV1Resource V2_TO_V1_RESOURCE = new V2ToV1Resource();
+ public static final V2ToV1ResourceValue V2_TO_V1_RESOURCEVALUE = new
V2ToV1ResourceValue();
+ public static final V1ToV2PropertyDescription V1_TO_V2_PROPERTYDESCRIPTION = new
V1ToV2PropertyDescription();
+ public static final V1ToV2Resource V1_TO_V2_RESOURCE = new V1ToV2Resource();
+ private static final V1ToV2ResourceValue V1_TO_V2_RESOURCEVALUE = new
V1ToV2ResourceValue();
+
+
public static final V1ToV2NamedString V1_TO_V2_NAMEDSTRING = new V1ToV2NamedString();
public static final V1ToV2UploadContext V1_TO_V2_UPLOADCONTEXT = new
V1ToV2UploadContext();
public static final V2ToV1PropertyDescription V2_TO_V1_PROPERTY_DESCRIPTION = new
V2ToV1PropertyDescription();
@@ -178,7 +191,22 @@
public static RegistrationContext toV2RegistrationContext(V1RegistrationContext
registrationContext)
{
- throw new NotYetImplemented();
+ if (registrationContext != null)
+ {
+ RegistrationContext result =
WSRPTypeFactory.createRegistrationContext(registrationContext.getRegistrationHandle());
+ result.setRegistrationState(registrationContext.getRegistrationState());
+ List<Extension> extensions =
V2V1Converter.transform(registrationContext.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
}
public static RuntimeContext toV2RuntimeContext(V1RuntimeContext runtimeContext)
@@ -287,7 +315,7 @@
{
if (modelDescription != null)
{
- V1ModelDescription result =
WSRP1TypeFactory.createModelDescription(V2V1Converter.transform(modelDescription.getPropertyDescriptions(),
V2_TO_V1_PROPERTY_DESCRIPTION));
+ V1ModelDescription result =
WSRP1TypeFactory.createModelDescription(V2V1Converter.transform(modelDescription.getPropertyDescriptions(),
V2_TO_V1_PROPERTYDESCRIPTION));
List<V1Extension> extensions =
V2V1Converter.transform(modelDescription.getExtensions(), V2_TO_V1_EXTENSION);
if (extensions != null)
{
@@ -305,30 +333,57 @@
public static V1ModelTypes toV1ModelTypes(ModelTypes modelTypes)
{
- throw new NotYetImplemented();
+ if (modelTypes != null)
+ {
+ V1ModelTypes result = new V1ModelTypes();
+ result.setAny(modelTypes.getAny());
+ return result;
+ }
+ else
+ {
+ return null;
+ }
}
public static V1ResourceList toV1ResourceList(ResourceList resourceList)
{
- throw new NotYetImplemented();
+ if (resourceList != null)
+ {
+ V1ResourceList result = new V1ResourceList();
+ List<V1Extension> extensions =
V2V1Converter.transform(resourceList.getExtensions(), V2_TO_V1_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+ List<V1Resource> v1Resources =
V2V1Converter.transform(resourceList.getResources(), V2_TO_V1_RESOURCE);
+ if (v1Resources != null)
+ {
+ result.getResources().addAll(v1Resources);
+ }
+ return result;
+ }
+ else
+ {
+ return null;
+ }
}
-
+
public static InteractionParams toV2InteractionParams(V1InteractionParams
v1InteractionParams)
{
- InteractionParams interactionParams =
WSRPTypeFactory.createInteractionParams(toV2StateChange(v1InteractionParams.getPortletStateChange()));
- interactionParams.setInteractionState(v1InteractionParams.getInteractionState());
-
interactionParams.getExtensions().addAll(Lists.transform(v1InteractionParams.getExtensions(),
V1_TO_V2_EXTENSION));
-
interactionParams.getFormParameters().addAll(Lists.transform(v1InteractionParams.getFormParameters(),
V1_TO_V2_NAMEDSTRING));
-
interactionParams.getUploadContexts().addAll(Lists.transform(v1InteractionParams.getUploadContexts(),
V1_TO_V2_UPLOADCONTEXT));
-
- return interactionParams;
+ InteractionParams interactionParams =
WSRPTypeFactory.createInteractionParams(toV2StateChange(v1InteractionParams.getPortletStateChange()));
+ interactionParams.setInteractionState(v1InteractionParams.getInteractionState());
+
interactionParams.getExtensions().addAll(Lists.transform(v1InteractionParams.getExtensions(),
V1_TO_V2_EXTENSION));
+
interactionParams.getFormParameters().addAll(Lists.transform(v1InteractionParams.getFormParameters(),
V1_TO_V2_NAMEDSTRING));
+
interactionParams.getUploadContexts().addAll(Lists.transform(v1InteractionParams.getUploadContexts(),
V1_TO_V2_UPLOADCONTEXT));
+
+ return interactionParams;
}
-
- public static StateChange toV2StateChange (V1StateChange v1StateChange)
+
+ public static StateChange toV2StateChange(V1StateChange v1StateChange)
{
return StateChange.valueOf((v1StateChange.value()));
}
-
+
public static V1UpdateResponse toV1UpdateResponse(UpdateResponse updateResponse)
{
if (updateResponse != null)
@@ -351,15 +406,15 @@
public static V1LocalizedString toV1LocalizedString(LocalizedString localizedString)
{
return V2_TO_V1_LOCALIZEDSTRING.apply(localizedString);
- }
-
+ }
+
public static V1SessionContext toV1SessionContext(SessionContext sessionContext)
{
if (sessionContext != null)
{
- V1SessionContext v1SessionContext =
WSRP1TypeFactory.createSessionContext(sessionContext.getSessionID(),sessionContext.getExpires().intValue());
+ V1SessionContext v1SessionContext =
WSRP1TypeFactory.createSessionContext(sessionContext.getSessionID(),
sessionContext.getExpires().intValue());
v1SessionContext.getExtensions().addAll(Lists.transform(sessionContext.getExtensions(),
V2_TO_V1_EXTENSION));
-
+
return v1SessionContext;
}
else
@@ -367,7 +422,83 @@
return null;
}
}
-
+
+ public static LocalizedString toV2LocalizedString(V1LocalizedString localizedString)
+ {
+ return V1_TO_V2_LOCALIZEDSTRING.apply(localizedString);
+ }
+
+ public static CookieProtocol toV2CookieProtocol(V1CookieProtocol v1CookieProtocol)
+ {
+ if (v1CookieProtocol != null)
+ {
+ return CookieProtocol.fromValue(v1CookieProtocol.value());
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static ModelDescription toV2ModelDescription(V1ModelDescription
v1ModelDescription)
+ {
+ if (v1ModelDescription != null)
+ {
+ ModelDescription result =
WSRPTypeFactory.createModelDescription(V2V1Converter.transform(v1ModelDescription.getPropertyDescriptions(),
V1_TO_V2_PROPERTYDESCRIPTION));
+ List<Extension> extensions =
V2V1Converter.transform(v1ModelDescription.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+ result.setModelTypes(toV2ModelTypes(v1ModelDescription.getModelTypes()));
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private static ModelTypes toV2ModelTypes(V1ModelTypes modelTypes)
+ {
+ if (modelTypes != null)
+ {
+ ModelTypes result = new ModelTypes();
+ result.setAny(modelTypes.getAny());
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static ResourceList toV2ResourceList(V1ResourceList v1ResourceList)
+ {
+ if (v1ResourceList != null)
+ {
+ ResourceList result = new ResourceList();
+
+ List<Extension> extensions =
V2V1Converter.transform(v1ResourceList.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+ List<Resource> resources =
V2V1Converter.transform(v1ResourceList.getResources(), V1_TO_V2_RESOURCE);
+ if (resources != null)
+ {
+ result.getResources().addAll(resources);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
private static class V1ToV2Extension implements Function<V1Extension,
Extension>
{
public Extension apply(V1Extension from)
@@ -453,6 +584,57 @@
}
}
+ private static class V1ToV2PortletDescription implements
Function<V1PortletDescription, PortletDescription>
+ {
+
+ public PortletDescription apply(V1PortletDescription from)
+ {
+ if (from != null)
+ {
+ PortletDescription result =
WSRPTypeFactory.createPortletDescription(from.getPortletHandle(),
+ V2V1Converter.transform(from.getMarkupTypes(), V1_TO_V2_MARKUPTYPE));
+
result.setDescription(V1_TO_V2_LOCALIZEDSTRING.apply(from.getDescription()));
+
result.setDisplayName(V1_TO_V2_LOCALIZEDSTRING.apply(from.getDisplayName()));
+ List<Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+ List<LocalizedString> keywords =
V2V1Converter.transform(from.getKeywords(), V1_TO_V2_LOCALIZEDSTRING);
+ if (keywords != null)
+ {
+ result.getKeywords().addAll(keywords);
+ }
+ List<String> userCategories = from.getUserCategories();
+ if (userCategories != null)
+ {
+ result.getUserCategories().addAll(userCategories);
+ }
+ List<String> userProfileItems = from.getUserProfileItems();
+ if (userProfileItems != null)
+ {
+ result.getUserProfileItems().addAll(userProfileItems);
+ }
+ result.setDefaultMarkupSecure(from.isDefaultMarkupSecure());
+ result.setDoesUrlTemplateProcessing(from.isDoesUrlTemplateProcessing());
+ result.setTemplatesStoredInSession(from.isTemplatesStoredInSession());
+ result.setHasUserSpecificState(from.isHasUserSpecificState());
+ result.setOnlySecure(from.isOnlySecure());
+ result.setUserContextStoredInSession(from.isUserContextStoredInSession());
+ result.setUsesMethodGet(from.isUsesMethodGet());
+ result.setShortTitle(V1_TO_V2_LOCALIZEDSTRING.apply(from.getShortTitle()));
+ result.setTitle(V1_TO_V2_LOCALIZEDSTRING.apply(from.getTitle()));
+
+ result.setGroupID(from.getGroupID());
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
private static class V2ToV1ItemDescription implements Function<ItemDescription,
V1ItemDescription>
{
@@ -477,6 +659,31 @@
}
}
+ private static class V1ToV2ItemDescription implements Function<V1ItemDescription,
ItemDescription>
+ {
+
+ public ItemDescription apply(V1ItemDescription from)
+ {
+ if (from != null)
+ {
+ ItemDescription result = new ItemDescription();
+ result.setItemName(from.getItemName());
+
result.setDescription(V1_TO_V2_LOCALIZEDSTRING.apply(from.getDescription()));
+ List<Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+
public static class V1ToV2NamedString implements Function<V1NamedString,
NamedString>
{
public NamedString apply(V1NamedString v1NamedString)
@@ -487,7 +694,7 @@
return result;
}
}
-
+
public static class V1ToV2UploadContext implements Function<V1UploadContext,
UploadContext>
{
@@ -496,12 +703,12 @@
UploadContext result =
WSRPTypeFactory.createUploadContext(v1UploadContext.getMimeType(),
v1UploadContext.getUploadData());
result.getExtensions().addAll(Lists.transform(v1UploadContext.getExtensions(),
V1_TO_V2_EXTENSION));
result.getMimeAttributes().addAll(Lists.transform(v1UploadContext.getMimeAttributes(),
V1_TO_V2_NAMEDSTRING));
-
+
return result;
}
-
+
}
-
+
private static class V2ToV1MarkupType implements Function<MarkupType,
V1MarkupType>
{
@@ -509,7 +716,14 @@
{
if (from != null)
{
- return WSRP1TypeFactory.createMarkupType(from.getMimeType(), from.getModes(),
from.getWindowStates(), from.getLocales());
+ V1MarkupType result = WSRP1TypeFactory.createMarkupType(from.getMimeType(),
from.getModes(), from.getWindowStates(), from.getLocales());
+ List<V1Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V2_TO_V1_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
}
else
{
@@ -518,6 +732,29 @@
}
}
+ private static class V1ToV2MarkupType implements Function<V1MarkupType,
MarkupType>
+ {
+
+ public MarkupType apply(V1MarkupType from)
+ {
+ if (from != null)
+ {
+ MarkupType result = WSRPTypeFactory.createMarkupType(from.getMimeType(),
from.getModes(), from.getWindowStates(), from.getLocales());
+ List<Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
private static class V2ToV1LocalizedString implements Function<LocalizedString,
V1LocalizedString>
{
@@ -535,6 +772,23 @@
}
}
+ private static class V1ToV2LocalizedString implements Function<V1LocalizedString,
LocalizedString>
+ {
+
+ public LocalizedString apply(V1LocalizedString from)
+ {
+ if (from != null)
+ {
+ return WSRPTypeFactory.createLocalizedString(from.getLang(),
from.getResourceName(), from.getValue());
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+ }
+
private static class V2ToV1PropertyDescription implements
Function<PropertyDescription, V1PropertyDescription>
{
@@ -544,6 +798,13 @@
{
V1PropertyDescription result =
WSRP1TypeFactory.createPropertyDescription(from.getName().toString(), from.getType());
result.setHint(toV1LocalizedString(from.getHint()));
+ result.setLabel(toV1LocalizedString(from.getLabel()));
+ List<V1Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V2_TO_V1_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
return result;
}
else
@@ -552,4 +813,124 @@
}
}
}
+
+ private static class V2ToV1Resource implements Function<Resource, V1Resource>
+ {
+ public V1Resource apply(Resource from)
+ {
+ if (from != null)
+ {
+ V1Resource result = new V1Resource();
+ result.setResourceName(from.getResourceName());
+ List<V1ResourceValue> values =
V2V1Converter.transform(from.getValues(), V2_TO_V1_RESOURCEVALUE);
+ if (values != null)
+ {
+ result.getValues().addAll(values);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ }
+
+ private static class V2ToV1ResourceValue implements Function<ResourceValue,
V1ResourceValue>
+ {
+ public V1ResourceValue apply(ResourceValue from)
+ {
+ if (from != null)
+ {
+ V1ResourceValue result = new V1ResourceValue();
+ result.setLang(from.getLang());
+ result.setValue(from.getValue());
+ List<V1Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V2_TO_V1_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ private static class V1ToV2Resource implements Function<V1Resource, Resource>
+ {
+ public Resource apply(V1Resource from)
+ {
+ if (from != null)
+ {
+ Resource result = new Resource();
+ result.setResourceName(from.getResourceName());
+ List<ResourceValue> values = V2V1Converter.transform(from.getValues(),
V1_TO_V2_RESOURCEVALUE);
+ if (values != null)
+ {
+ result.getValues().addAll(values);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ }
+
+ private static class V1ToV2ResourceValue implements Function<V1ResourceValue,
ResourceValue>
+ {
+ public ResourceValue apply(V1ResourceValue from)
+ {
+ if (from != null)
+ {
+ ResourceValue result = new ResourceValue();
+ result.setLang(from.getLang());
+ result.setValue(from.getValue());
+ List<Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ private static class V1ToV2PropertyDescription implements
Function<V1PropertyDescription, PropertyDescription>
+ {
+ public PropertyDescription apply(V1PropertyDescription from)
+ {
+ if (from != null)
+ {
+ PropertyDescription result =
WSRPTypeFactory.createPropertyDescription(from.getName(), from.getType());
+ result.setHint(toV2LocalizedString(from.getHint()));
+ result.setLabel(toV2LocalizedString(from.getLabel()));
+ List<Extension> extensions =
V2V1Converter.transform(from.getExtensions(), V1_TO_V2_EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
}
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1TypeFactory.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1TypeFactory.java 2010-06-09
13:48:51 UTC (rev 3278)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1TypeFactory.java 2010-06-09
14:37:04 UTC (rev 3279)
@@ -331,6 +331,7 @@
public static V1PortletDescription createPortletDescription(String portletHandle,
List<V1MarkupType> markupTypes)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", null);
+ checkPortletHandle(portletHandle);
ParameterValidation.throwIllegalArgExceptionIfNull(markupTypes,
"MarkupType");
if (markupTypes.isEmpty())
{
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1ServiceDescriptionService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1ServiceDescriptionService.java 2010-06-09
13:48:51 UTC (rev 3278)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1ServiceDescriptionService.java 2010-06-09
14:37:04 UTC (rev 3279)
@@ -1,24 +1,25 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.wsrp.services.v1;
@@ -104,10 +105,15 @@
{
throw V2V1Converter.toV2Exception(OperationFailed.class, v1OperationFailed);
}
- /*service.getServiceDescription(registrationContext, desiredLocales,
portletHandles, userContext,
- requiresRegistration, offeredPortlets, userCategoryDescriptions,
extensionDescriptions,
- customWindowStateDescriptions, customModeDescriptions, requiresInitCookie,
registrationPropertyDescription,
- locales, resourceList, eventDescriptions, schemaType, supportedOptions,
exportDescription,
- mayReturnRegistrationState, extensions);*/
+
+ offeredPortlets.value = V2V1Converter.transform(v1OfferedPortlets.value,
V2V1Converter.V1_TO_V2_PORTLETDESCRIPTION);
+ userCategoryDescriptions.value = V2V1Converter.transform(v1UserCategories.value,
V2V1Converter.V1_TO_V2_ITEMDESCRIPTION);
+// customUserProfileItemDescriptions.value =
description.getCustomUserProfileItemDescriptions();
+ customWindowStateDescriptions.value = V2V1Converter.transform(v1WindowStates.value,
V2V1Converter.V1_TO_V2_ITEMDESCRIPTION);
+ customModeDescriptions.value = V2V1Converter.transform(v1Modes.value,
V2V1Converter.V1_TO_V2_ITEMDESCRIPTION);
+ requiresInitCookie.value = V2V1Converter.toV2CookieProtocol(v1Cookie.value);
+ registrationPropertyDescription.value =
V2V1Converter.toV2ModelDescription(v1RegistrationProperties.value);
+ resourceList.value = V2V1Converter.toV2ResourceList(v1Resources.value);
+ extensions.value = V2V1Converter.transform(v1Extensions.value,
V2V1Converter.V1_TO_V2_EXTENSION);
}
}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/ServiceDescriptionEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/ServiceDescriptionEndpoint.java 2010-06-09
13:48:51 UTC (rev 3278)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/ServiceDescriptionEndpoint.java 2010-06-09
14:37:04 UTC (rev 3279)
@@ -80,7 +80,7 @@
getServiceDescription.setRegistrationContext(V2V1Converter.toV2RegistrationContext(registrationContext));
getServiceDescription.getDesiredLocales().addAll(desiredLocales);
- ServiceDescription description = null;
+ ServiceDescription description;
try
{
description = producer.getServiceDescription(getServiceDescription);