Author: chris.laprun(a)jboss.com
Date: 2010-06-13 15:31:48 -0400 (Sun, 13 Jun 2010)
New Revision: 3306
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1PortletManagementService.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/PortletManagementEndpoint.java
Log:
- Finished implementing portlet management. NOT TESTED!
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java 2010-06-12
13:15:54 UTC (rev 3305)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java 2010-06-13
19:31:48 UTC (rev 3306)
@@ -25,13 +25,16 @@
import com.google.common.base.Function;
import com.google.common.collect.Lists;
+import org.gatein.common.util.ParameterValidation;
import org.gatein.pc.api.OpaqueStateString;
+import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.WSRPExceptionFactory;
import org.gatein.wsrp.WSRPTypeFactory;
import org.gatein.wsrp.WSRPUtils;
import org.oasis.wsrp.v1.V1ClientData;
import org.oasis.wsrp.v1.V1Contact;
import org.oasis.wsrp.v1.V1CookieProtocol;
+import org.oasis.wsrp.v1.V1DestroyFailed;
import org.oasis.wsrp.v1.V1EmployerInfo;
import org.oasis.wsrp.v1.V1Extension;
import org.oasis.wsrp.v1.V1InteractionParams;
@@ -47,8 +50,11 @@
import org.oasis.wsrp.v1.V1PortletContext;
import org.oasis.wsrp.v1.V1PortletDescription;
import org.oasis.wsrp.v1.V1Postal;
+import org.oasis.wsrp.v1.V1Property;
import org.oasis.wsrp.v1.V1PropertyDescription;
+import org.oasis.wsrp.v1.V1PropertyList;
import org.oasis.wsrp.v1.V1RegistrationContext;
+import org.oasis.wsrp.v1.V1ResetProperty;
import org.oasis.wsrp.v1.V1Resource;
import org.oasis.wsrp.v1.V1ResourceList;
import org.oasis.wsrp.v1.V1ResourceValue;
@@ -65,6 +71,7 @@
import org.oasis.wsrp.v2.CookieProtocol;
import org.oasis.wsrp.v2.EmployerInfo;
import org.oasis.wsrp.v2.Extension;
+import org.oasis.wsrp.v2.FailedPortlets;
import org.oasis.wsrp.v2.InteractionParams;
import org.oasis.wsrp.v2.ItemDescription;
import org.oasis.wsrp.v2.LocalizedString;
@@ -78,8 +85,11 @@
import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescription;
import org.oasis.wsrp.v2.Postal;
+import org.oasis.wsrp.v2.Property;
import org.oasis.wsrp.v2.PropertyDescription;
+import org.oasis.wsrp.v2.PropertyList;
import org.oasis.wsrp.v2.RegistrationContext;
+import org.oasis.wsrp.v2.ResetProperty;
import org.oasis.wsrp.v2.Resource;
import org.oasis.wsrp.v2.ResourceList;
import org.oasis.wsrp.v2.ResourceValue;
@@ -93,6 +103,8 @@
import org.oasis.wsrp.v2.UserContext;
import org.oasis.wsrp.v2.UserProfile;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -111,6 +123,8 @@
public static final V1ToV2ResourceValue RESOURCEVALUE = new V1ToV2ResourceValue();
public static final V1ToV2NamedString NAMEDSTRING = new V1ToV2NamedString();
public static final V1ToV2UploadContext UPLOADCONTEXT = new V1ToV2UploadContext();
+ public static final V1ToV2Property PROPERTY = new V1ToV2Property();
+ public static final V1ToV2ResetProperty RESETPROPERTY = new V1ToV2ResetProperty();
public static MarkupParams toV2MarkupParams(V1MarkupParams v1MarkupParams)
{
@@ -623,6 +637,56 @@
}
}
+ public static PropertyList toV2PropertyList(V1PropertyList v1PropertyList)
+ {
+ if (v1PropertyList != null)
+ {
+ PropertyList result = WSRPTypeFactory.createPropertyList();
+
+ List<Property> properties =
WSRPUtils.transform(v1PropertyList.getProperties(), PROPERTY);
+ if (properties != null)
+ {
+ result.getProperties().addAll(properties);
+ }
+
+ List<Extension> extensions =
WSRPUtils.transform(v1PropertyList.getExtensions(), EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static PortletDescription toV2PortletDescription(V1PortletDescription
v1PortletDescription)
+ {
+ return PORTLETDESCRIPTION.apply(v1PortletDescription);
+ }
+
+ public static List<FailedPortlets>
toV2FailedPortlets(List<V1DestroyFailed> destroyFailed)
+ {
+ if (ParameterValidation.existsAndIsNotEmpty(destroyFailed))
+ {
+ // todo: might need improvements
+ List<FailedPortlets> result = new
ArrayList<FailedPortlets>(destroyFailed.size());
+ for (V1DestroyFailed failed : destroyFailed)
+ {
+
result.add(WSRPTypeFactory.createFailedPortlets(Collections.singletonList(failed.getPortletHandle()),
failed.getReason()));
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public static class V1ToV2Extension implements Function<V1Extension, Extension>
{
public Extension apply(V1Extension from)
@@ -865,4 +929,42 @@
}
}
}
+
+ public static class V1ToV2Property implements Function<V1Property, Property>
+ {
+ public Property apply(V1Property from)
+ {
+ if (from != null)
+ {
+ Property result = WSRPTypeFactory.createProperty(from.getName(),
from.getLang(), from.getStringValue());
+ result.setType(WSRPConstants.XSD_STRING); // todo: not sure what to do
here... :(
+
+ List<Object> any = from.getAny();
+ if (ParameterValidation.existsAndIsNotEmpty(any))
+ {
+ result.getAny().addAll(any);
+ }
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ private static class V1ToV2ResetProperty implements Function<V1ResetProperty,
ResetProperty>
+ {
+ public ResetProperty apply(V1ResetProperty from)
+ {
+ if (from != null)
+ {
+ return WSRPTypeFactory.createResetProperty(from.getName());
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
}
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-12
13:15:54 UTC (rev 3305)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-13
19:31:48 UTC (rev 3306)
@@ -25,11 +25,13 @@
import com.google.common.base.Function;
import com.google.common.collect.Lists;
+import org.gatein.common.util.ParameterValidation;
import org.gatein.wsrp.WSRPUtils;
import org.oasis.wsrp.v1.V1CacheControl;
import org.oasis.wsrp.v1.V1ClientData;
import org.oasis.wsrp.v1.V1Contact;
import org.oasis.wsrp.v1.V1CookieProtocol;
+import org.oasis.wsrp.v1.V1DestroyFailed;
import org.oasis.wsrp.v1.V1EmployerInfo;
import org.oasis.wsrp.v1.V1Extension;
import org.oasis.wsrp.v1.V1InteractionParams;
@@ -48,6 +50,7 @@
import org.oasis.wsrp.v1.V1Postal;
import org.oasis.wsrp.v1.V1Property;
import org.oasis.wsrp.v1.V1PropertyDescription;
+import org.oasis.wsrp.v1.V1PropertyList;
import org.oasis.wsrp.v1.V1RegistrationContext;
import org.oasis.wsrp.v1.V1ResetProperty;
import org.oasis.wsrp.v1.V1Resource;
@@ -69,6 +72,7 @@
import org.oasis.wsrp.v2.CookieProtocol;
import org.oasis.wsrp.v2.EmployerInfo;
import org.oasis.wsrp.v2.Extension;
+import org.oasis.wsrp.v2.FailedPortlets;
import org.oasis.wsrp.v2.InteractionParams;
import org.oasis.wsrp.v2.ItemDescription;
import org.oasis.wsrp.v2.LocalizedString;
@@ -85,6 +89,7 @@
import org.oasis.wsrp.v2.Postal;
import org.oasis.wsrp.v2.Property;
import org.oasis.wsrp.v2.PropertyDescription;
+import org.oasis.wsrp.v2.PropertyList;
import org.oasis.wsrp.v2.RegistrationContext;
import org.oasis.wsrp.v2.ResetProperty;
import org.oasis.wsrp.v2.Resource;
@@ -101,6 +106,8 @@
import org.oasis.wsrp.v2.UserContext;
import org.oasis.wsrp.v2.UserProfile;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -728,6 +735,58 @@
return PORTLETDESCRIPTION.apply(description);
}
+ public static List<V1DestroyFailed> toV1DestroyFailed(List<FailedPortlets>
failedPortletsList)
+ {
+ if (failedPortletsList != null)
+ {
+ List<V1DestroyFailed> result = new
ArrayList<V1DestroyFailed>(failedPortletsList.size());
+
+ for (FailedPortlets failedPortlets : failedPortletsList)
+ {
+ QName errorCode = failedPortlets.getErrorCode();
+ V1LocalizedString reason = toV1LocalizedString(failedPortlets.getReason());
+ String v1Reason = errorCode.toString() + ": " + reason.getValue();
+ for (String handle : failedPortlets.getPortletHandles())
+ {
+ V1DestroyFailed destroyFailed =
WSRP1TypeFactory.createDestroyFailed(handle, v1Reason);
+ result.add(destroyFailed);
+ }
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static V1PropertyList toV1PropertyList(PropertyList propertyList)
+ {
+ if (propertyList != null)
+ {
+ V1PropertyList result = new V1PropertyList();
+
+ List<V1Property> properties =
WSRPUtils.transform(propertyList.getProperties(), PROPERTY);
+ if (properties != null)
+ {
+ result.getProperties().addAll(properties);
+ }
+
+ List<V1Extension> extensions =
WSRPUtils.transform(propertyList.getExtensions(), EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
private static class V2ToV1Extension implements Function<Extension,
V1Extension>
{
public V1Extension apply(Extension from)
@@ -991,7 +1050,7 @@
{
V1Property result =
WSRP1TypeFactory.createProperty(from.getName().toString(), from.getLang(),
from.getStringValue());
List<Object> any = from.getAny();
- if (any != null)
+ if (ParameterValidation.existsAndIsNotEmpty(any))
{
result.getAny().addAll(any);
}
@@ -1007,25 +1066,6 @@
private static class V2ToV1ResetProperty implements Function<ResetProperty,
V1ResetProperty>
{
- public V1Property apply(Property from)
- {
- if (from != null)
- {
- V1Property result =
WSRP1TypeFactory.createProperty(from.getName().toString(), from.getLang(),
from.getStringValue());
- List<Object> any = from.getAny();
- if (any != null)
- {
- result.getAny().addAll(any);
- }
-
- return result;
- }
- else
- {
- return null;
- }
- }
-
public V1ResetProperty apply(ResetProperty from)
{
if (from != null)
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1PortletManagementService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1PortletManagementService.java 2010-06-12
13:15:54 UTC (rev 3305)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1PortletManagementService.java 2010-06-13
19:31:48 UTC (rev 3306)
@@ -27,16 +27,21 @@
import org.gatein.wsrp.WSRPExceptionFactory;
import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.services.PortletManagementService;
+import org.gatein.wsrp.spec.v1.V1ToV2Converter;
import org.gatein.wsrp.spec.v1.V2ToV1Converter;
import org.oasis.wsrp.v1.V1AccessDenied;
+import org.oasis.wsrp.v1.V1DestroyFailed;
import org.oasis.wsrp.v1.V1Extension;
import org.oasis.wsrp.v1.V1InconsistentParameters;
import org.oasis.wsrp.v1.V1InvalidHandle;
import org.oasis.wsrp.v1.V1InvalidRegistration;
import org.oasis.wsrp.v1.V1InvalidUserCategory;
import org.oasis.wsrp.v1.V1MissingParameters;
+import org.oasis.wsrp.v1.V1ModelDescription;
import org.oasis.wsrp.v1.V1OperationFailed;
import org.oasis.wsrp.v1.V1PortletDescription;
+import org.oasis.wsrp.v1.V1Property;
+import org.oasis.wsrp.v1.V1ResetProperty;
import org.oasis.wsrp.v1.V1ResourceList;
import org.oasis.wsrp.v1.WSRPV1PortletManagementPortType;
import org.oasis.wsrp.v2.AccessDenied;
@@ -90,14 +95,21 @@
{
try
{
+ Holder<V1PortletDescription> v1PortletDescriptionHolder = new
Holder<V1PortletDescription>();
+ Holder<V1ResourceList> v1ResourceListHolder = new
Holder<V1ResourceList>();
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
service.getPortletDescription(
V2ToV1Converter.toV1RegistrationContext(registrationContext),
V2ToV1Converter.toV1PortletContext(portletContext),
V2ToV1Converter.toV1UserContext(userContext),
desiredLocales,
- new
Holder<V1PortletDescription>(V2ToV1Converter.toV1PortletDescription(portletDescription.value)),
- new
Holder<V1ResourceList>(V2ToV1Converter.toV1ResourceList(resourceList.value)),
- new
Holder<List<V1Extension>>(WSRPUtils.transform(extensions.value,
V2ToV1Converter.EXTENSION)));
+ v1PortletDescriptionHolder,
+ v1ResourceListHolder,
+ v1Extensions);
+
+ portletDescription.value =
V1ToV2Converter.toV2PortletDescription(v1PortletDescriptionHolder.value);
+ resourceList.value =
V1ToV2Converter.toV2ResourceList(v1ResourceListHolder.value);
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
}
catch (V1AccessDenied v1AccessDenied)
{
@@ -132,13 +144,82 @@
@Override
public void clonePortlet(RegistrationContext registrationContext, PortletContext
portletContext, UserContext userContext, Lifetime lifetime, Holder<String>
portletHandle, Holder<byte[]> portletState, Holder<Lifetime>
scheduledDestruction, Holder<List<Extension>> extensions) throws AccessDenied,
InconsistentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory,
MissingParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSupported,
ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+ service.clonePortlet(
+ V2ToV1Converter.toV1RegistrationContext(registrationContext),
+ V2ToV1Converter.toV1PortletContext(portletContext),
+ V2ToV1Converter.toV1UserContext(userContext),
+ portletHandle,
+ portletState,
+ v1Extensions
+ );
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1AccessDenied v1AccessDenied)
+ {
+ WSRPExceptionFactory.throwWSException(AccessDenied.class,
v1AccessDenied.getMessage(), v1AccessDenied);
+ }
+ catch (V1InconsistentParameters v1InconsistentParameters)
+ {
+ WSRPExceptionFactory.throwWSException(InconsistentParameters.class,
v1InconsistentParameters.getMessage(), v1InconsistentParameters);
+ }
+ catch (V1InvalidHandle v1InvalidHandle)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidHandle.class,
v1InvalidHandle.getMessage(), v1InvalidHandle);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1InvalidUserCategory v1InvalidUserCategory)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidUserCategory.class,
v1InvalidUserCategory.getMessage(), v1InvalidUserCategory);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
public void destroyPortlets(RegistrationContext registrationContext,
List<String> portletHandles, UserContext userContext,
Holder<List<FailedPortlets>> failedPortlets,
Holder<List<Extension>> extensions) throws InconsistentParameters,
InvalidRegistration, MissingParameters, ModifyRegistrationRequired, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1DestroyFailed>> destroyFailed = new
Holder<List<V1DestroyFailed>>();
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+ service.destroyPortlets(
+ V2ToV1Converter.toV1RegistrationContext(registrationContext),
+ portletHandles,
+ destroyFailed,
+ v1Extensions
+ );
+
+ failedPortlets.value = V1ToV2Converter.toV2FailedPortlets(destroyFailed.value);
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1InconsistentParameters v1InconsistentParameters)
+ {
+ WSRPExceptionFactory.throwWSException(InconsistentParameters.class,
v1InconsistentParameters.getMessage(), v1InconsistentParameters);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
@@ -186,18 +267,150 @@
@Override
public void setPortletProperties(RegistrationContext registrationContext,
PortletContext portletContext, UserContext userContext, PropertyList propertyList,
Holder<String> portletHandle, Holder<byte[]> portletState,
Holder<Lifetime> scheduledDestruction, Holder<List<Extension>>
extensions) throws AccessDenied, InconsistentParameters, InvalidHandle,
InvalidRegistration, InvalidUserCategory, MissingParameters, ModifyRegistrationRequired,
OperationFailed, OperationNotSupported, ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+ service.setPortletProperties(
+ V2ToV1Converter.toV1RegistrationContext(registrationContext),
+ V2ToV1Converter.toV1PortletContext(portletContext),
+ V2ToV1Converter.toV1UserContext(userContext),
+ V2ToV1Converter.toV1PropertyList(propertyList),
+ portletHandle,
+ portletState,
+ v1Extensions
+ );
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1AccessDenied v1AccessDenied)
+ {
+ WSRPExceptionFactory.throwWSException(AccessDenied.class,
v1AccessDenied.getMessage(), v1AccessDenied);
+ }
+ catch (V1InconsistentParameters v1InconsistentParameters)
+ {
+ WSRPExceptionFactory.throwWSException(InconsistentParameters.class,
v1InconsistentParameters.getMessage(), v1InconsistentParameters);
+ }
+ catch (V1InvalidHandle v1InvalidHandle)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidHandle.class,
v1InvalidHandle.getMessage(), v1InvalidHandle);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1InvalidUserCategory v1InvalidUserCategory)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidUserCategory.class,
v1InvalidUserCategory.getMessage(), v1InvalidUserCategory);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
public void getPortletProperties(RegistrationContext registrationContext,
PortletContext portletContext, UserContext userContext, List<String> names,
Holder<List<Property>> properties, Holder<List<ResetProperty>>
resetProperties, Holder<List<Extension>> extensions) throws AccessDenied,
InconsistentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory,
MissingParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSupported,
ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1Property>> v1PropertyList = new
Holder<List<V1Property>>();
+ Holder<List<V1ResetProperty>> v1ResetPropertyList = new
Holder<List<V1ResetProperty>>();
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+ service.getPortletProperties(
+ V2ToV1Converter.toV1RegistrationContext(registrationContext),
+ V2ToV1Converter.toV1PortletContext(portletContext),
+ V2ToV1Converter.toV1UserContext(userContext),
+ names,
+ v1PropertyList,
+ v1ResetPropertyList,
+ v1Extensions
+ );
+ properties.value = WSRPUtils.transform(v1PropertyList.value,
V1ToV2Converter.PROPERTY);
+ resetProperties.value = WSRPUtils.transform(v1ResetPropertyList.value,
V1ToV2Converter.RESETPROPERTY);
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1AccessDenied v1AccessDenied)
+ {
+ WSRPExceptionFactory.throwWSException(AccessDenied.class,
v1AccessDenied.getMessage(), v1AccessDenied);
+ }
+ catch (V1InconsistentParameters v1InconsistentParameters)
+ {
+ WSRPExceptionFactory.throwWSException(InconsistentParameters.class,
v1InconsistentParameters.getMessage(), v1InconsistentParameters);
+ }
+ catch (V1InvalidHandle v1InvalidHandle)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidHandle.class,
v1InvalidHandle.getMessage(), v1InvalidHandle);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1InvalidUserCategory v1InvalidUserCategory)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidUserCategory.class,
v1InvalidUserCategory.getMessage(), v1InvalidUserCategory);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
public void getPortletPropertyDescription(RegistrationContext registrationContext,
PortletContext portletContext, UserContext userContext, List<String> desiredLocales,
Holder<ModelDescription> modelDescription, Holder<ResourceList> resourceList,
Holder<List<Extension>> extensions) throws AccessDenied,
InconsistentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory,
MissingParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSupported,
ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<V1ResourceList> v1ResourceListHolder = new
Holder<V1ResourceList>();
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+ Holder<V1ModelDescription> v1ModelDescription = new
Holder<V1ModelDescription>();
+
+ service.getPortletPropertyDescription(
+ V2ToV1Converter.toV1RegistrationContext(registrationContext),
+ V2ToV1Converter.toV1PortletContext(portletContext),
+ V2ToV1Converter.toV1UserContext(userContext),
+ desiredLocales,
+ v1ModelDescription,
+ v1ResourceListHolder,
+ v1Extensions);
+
+ modelDescription.value =
V1ToV2Converter.toV2ModelDescription(v1ModelDescription.value);
+ resourceList.value =
V1ToV2Converter.toV2ResourceList(v1ResourceListHolder.value);
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1AccessDenied v1AccessDenied)
+ {
+ WSRPExceptionFactory.throwWSException(AccessDenied.class,
v1AccessDenied.getMessage(), v1AccessDenied);
+ }
+ catch (V1InconsistentParameters v1InconsistentParameters)
+ {
+ WSRPExceptionFactory.throwWSException(InconsistentParameters.class,
v1InconsistentParameters.getMessage(), v1InconsistentParameters);
+ }
+ catch (V1InvalidHandle v1InvalidHandle)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidHandle.class,
v1InvalidHandle.getMessage(), v1InvalidHandle);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1InvalidUserCategory v1InvalidUserCategory)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidUserCategory.class,
v1InvalidUserCategory.getMessage(), v1InvalidUserCategory);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/PortletManagementEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/PortletManagementEndpoint.java 2010-06-12
13:15:54 UTC (rev 3305)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/PortletManagementEndpoint.java 2010-06-13
19:31:48 UTC (rev 3306)
@@ -23,7 +23,6 @@
package org.gatein.wsrp.endpoints.v1;
-import org.gatein.common.NotYetImplemented;
import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.endpoints.WSRPBaseEndpoint;
import org.gatein.wsrp.spec.v1.V1ToV2Converter;
@@ -49,16 +48,23 @@
import org.oasis.wsrp.v1.V1UserContext;
import org.oasis.wsrp.v1.WSRPV1PortletManagementPortType;
import org.oasis.wsrp.v2.AccessDenied;
+import org.oasis.wsrp.v2.ClonePortlet;
+import org.oasis.wsrp.v2.DestroyPortlets;
+import org.oasis.wsrp.v2.DestroyPortletsResponse;
import org.oasis.wsrp.v2.GetPortletDescription;
import org.oasis.wsrp.v2.GetPortletProperties;
+import org.oasis.wsrp.v2.GetPortletPropertyDescription;
import org.oasis.wsrp.v2.InconsistentParameters;
import org.oasis.wsrp.v2.InvalidHandle;
import org.oasis.wsrp.v2.InvalidRegistration;
import org.oasis.wsrp.v2.InvalidUserCategory;
import org.oasis.wsrp.v2.MissingParameters;
import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescriptionResponse;
+import org.oasis.wsrp.v2.PortletPropertyDescriptionResponse;
import org.oasis.wsrp.v2.PropertyList;
+import org.oasis.wsrp.v2.SetPortletProperties;
import javax.jws.HandlerChain;
import javax.jws.WebParam;
@@ -91,19 +97,48 @@
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions
) throws V1MissingParameters, V1InconsistentParameters, V1InvalidHandle,
V1InvalidRegistration, V1InvalidUserCategory, V1AccessDenied, V1OperationFailed
{
- /*GetPortletPropertyDescription getPortletPropertyDescription = new
GetPortletPropertyDescription();
- getPortletPropertyDescription.setRegistrationContext(registrationContext);
- getPortletPropertyDescription.setPortletContext(portletContext);
- getPortletPropertyDescription.setUserContext(userContext);
+ GetPortletPropertyDescription getPortletPropertyDescription = new
GetPortletPropertyDescription();
+
getPortletPropertyDescription.setRegistrationContext(V1ToV2Converter.toV2RegistrationContext(registrationContext));
+
getPortletPropertyDescription.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
+
getPortletPropertyDescription.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
getPortletPropertyDescription.getDesiredLocales().addAll(desiredLocales);
+ PortletPropertyDescriptionResponse descriptionResponse;
+ try
+ {
+ descriptionResponse =
producer.getPortletPropertyDescription(getPortletPropertyDescription);
- PortletPropertyDescriptionResponse descriptionResponse =
producer.getPortletPropertyDescription(getPortletPropertyDescription);
-
- modelDescription.value = descriptionResponse.getModelDescription();
- resourceList.value = descriptionResponse.getResourceList();
- extensions.value = descriptionResponse.getExtensions();*/
-
- throw new NotYetImplemented();
+ modelDescription.value =
V2ToV1Converter.toV1ModelDescription(descriptionResponse.getModelDescription());
+ resourceList.value =
V2ToV1Converter.toV1ResourceList(descriptionResponse.getResourceList());
+ extensions.value = WSRPUtils.transform(descriptionResponse.getExtensions(),
V2ToV1Converter.EXTENSION);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ WSRP1ExceptionFactory.throwWSException(accessDenied.getClass(),
accessDenied.getMessage(), accessDenied);
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidHandle.getClass(),
invalidHandle.getMessage(), invalidHandle);
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidUserCategory.getClass(),
invalidUserCategory.getMessage(), invalidUserCategory);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(inconsistentParameters.getClass(),
inconsistentParameters.getMessage(), inconsistentParameters);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(missingParameters.getClass(),
missingParameters.getMessage(), missingParameters);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidRegistration.getClass(),
invalidRegistration.getMessage(), invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
public void setPortletProperties(
@@ -116,19 +151,48 @@
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions
) throws V1MissingParameters, V1InconsistentParameters, V1InvalidHandle,
V1InvalidRegistration, V1InvalidUserCategory, V1AccessDenied, V1OperationFailed
{
- /*SetPortletProperties setPortletProperties = new SetPortletProperties();
- setPortletProperties.setRegistrationContext(registrationContext);
- setPortletProperties.setPortletContext(portletContext);
- setPortletProperties.setUserContext(userContext);
- setPortletProperties.setPropertyList(propertyList);
+ SetPortletProperties setPortletProperties = new SetPortletProperties();
+
setPortletProperties.setRegistrationContext(V1ToV2Converter.toV2RegistrationContext(registrationContext));
+
setPortletProperties.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
+ setPortletProperties.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
+
setPortletProperties.setPropertyList(V1ToV2Converter.toV2PropertyList(propertyList));
- PortletContext response = producer.setPortletProperties(setPortletProperties);
-
- portletHandle.value = response.getPortletHandle();
- portletState.value = response.getPortletState();
- extensions.value = response.getExtensions();*/
-
- throw new NotYetImplemented();
+ PortletContext response;
+ try
+ {
+ response = producer.setPortletProperties(setPortletProperties);
+ portletHandle.value = response.getPortletHandle();
+ portletState.value = response.getPortletState();
+ extensions.value = WSRPUtils.transform(response.getExtensions(),
V2ToV1Converter.EXTENSION);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ WSRP1ExceptionFactory.throwWSException(accessDenied.getClass(),
accessDenied.getMessage(), accessDenied);
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidHandle.getClass(),
invalidHandle.getMessage(), invalidHandle);
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidUserCategory.getClass(),
invalidUserCategory.getMessage(), invalidUserCategory);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(inconsistentParameters.getClass(),
inconsistentParameters.getMessage(), inconsistentParameters);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(missingParameters.getClass(),
missingParameters.getMessage(), missingParameters);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidRegistration.getClass(),
invalidRegistration.getMessage(), invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
public void clonePortlet(
@@ -140,18 +204,47 @@
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions
) throws V1MissingParameters, V1InconsistentParameters, V1InvalidHandle,
V1InvalidRegistration, V1InvalidUserCategory, V1AccessDenied, V1OperationFailed
{
- /*ClonePortlet clonePortlet = new ClonePortlet();
- clonePortlet.setRegistrationContext(registrationContext);
- clonePortlet.setPortletContext(portletContext);
- clonePortlet.setUserContext(userContext);
+ ClonePortlet clonePortlet = new ClonePortlet();
+
clonePortlet.setRegistrationContext(V1ToV2Converter.toV2RegistrationContext(registrationContext));
+
clonePortlet.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
+ clonePortlet.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
- PortletContext response = producer.clonePortlet(clonePortlet);
-
- portletHandle.value = response.getPortletHandle();
- portletState.value = response.getPortletState();
- extensions.value = response.getExtensions();*/
-
- throw new NotYetImplemented();
+ PortletContext response;
+ try
+ {
+ response = producer.clonePortlet(clonePortlet);
+ portletHandle.value = response.getPortletHandle();
+ portletState.value = response.getPortletState();
+ extensions.value = WSRPUtils.transform(response.getExtensions(),
V2ToV1Converter.EXTENSION);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ WSRP1ExceptionFactory.throwWSException(accessDenied.getClass(),
accessDenied.getMessage(), accessDenied);
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidHandle.getClass(),
invalidHandle.getMessage(), invalidHandle);
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidUserCategory.getClass(),
invalidUserCategory.getMessage(), invalidUserCategory);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(inconsistentParameters.getClass(),
inconsistentParameters.getMessage(), inconsistentParameters);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(missingParameters.getClass(),
missingParameters.getMessage(), missingParameters);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidRegistration.getClass(),
invalidRegistration.getMessage(), invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
public void getPortletDescription(
@@ -231,7 +324,6 @@
properties.value = WSRPUtils.transform(result.getProperties(),
V2ToV1Converter.PROPERTY);
resetProperties.value = WSRPUtils.transform(result.getResetProperties(),
V2ToV1Converter.RESETPROPERTY);
extensions.value = WSRPUtils.transform(result.getExtensions(),
V2ToV1Converter.EXTENSION);
-
}
catch (AccessDenied accessDenied)
{
@@ -270,15 +362,33 @@
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions
) throws V1MissingParameters, V1InconsistentParameters, V1InvalidRegistration,
V1OperationFailed
{
- /*DestroyPortlets destroyPortlets = new DestroyPortlets();
- destroyPortlets.setRegistrationContext(registrationContext);
+ DestroyPortlets destroyPortlets = new DestroyPortlets();
+
destroyPortlets.setRegistrationContext(V1ToV2Converter.toV2RegistrationContext(registrationContext));
destroyPortlets.getPortletHandles().addAll(portletHandles);
- DestroyPortletsResponse destroyPortletsResponse =
producer.destroyPortlets(destroyPortlets);
+ DestroyPortletsResponse destroyPortletsResponse;
+ try
+ {
+ destroyPortletsResponse = producer.destroyPortlets(destroyPortlets);
- destroyFailed.value = destroyPortletsResponse.getDestroyFailed();
- extensions.value = destroyPortletsResponse.getExtensions();*/
-
- throw new NotYetImplemented();
+ destroyFailed.value =
V2ToV1Converter.toV1DestroyFailed(destroyPortletsResponse.getFailedPortlets());
+ extensions.value = WSRPUtils.transform(destroyPortletsResponse.getExtensions(),
V2ToV1Converter.EXTENSION);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(inconsistentParameters.getClass(),
inconsistentParameters.getMessage(), inconsistentParameters);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(missingParameters.getClass(),
missingParameters.getMessage(), missingParameters);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidRegistration.getClass(),
invalidRegistration.getMessage(), invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
}