Author: mwringe
Date: 2010-06-09 09:48:51 -0400 (Wed, 09 Jun 2010)
New Revision: 3278
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1Converter.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/MarkupEndpoint.java
Log:
- Fill in empty methods in MarkupEndpoint and update V2V1Converter to include converter
methods required.
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
11:04:13 UTC (rev 3277)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1Converter.java 2010-06-09
13:48:51 UTC (rev 3278)
@@ -23,6 +23,9 @@
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;
@@ -32,12 +35,14 @@
import org.oasis.wsrp.v1.V1ClientData;
import org.oasis.wsrp.v1.V1CookieProtocol;
import org.oasis.wsrp.v1.V1Extension;
+import org.oasis.wsrp.v1.V1InteractionParams;
import org.oasis.wsrp.v1.V1ItemDescription;
import org.oasis.wsrp.v1.V1LocalizedString;
import org.oasis.wsrp.v1.V1MarkupContext;
import org.oasis.wsrp.v1.V1MarkupParams;
import org.oasis.wsrp.v1.V1MarkupType;
import org.oasis.wsrp.v1.V1ModelDescription;
+import org.oasis.wsrp.v1.V1NamedString;
import org.oasis.wsrp.v1.V1ModelTypes;
import org.oasis.wsrp.v1.V1PortletContext;
import org.oasis.wsrp.v1.V1PortletDescription;
@@ -46,16 +51,21 @@
import org.oasis.wsrp.v1.V1ResourceList;
import org.oasis.wsrp.v1.V1RuntimeContext;
import org.oasis.wsrp.v1.V1ServiceDescription;
+import org.oasis.wsrp.v1.V1SessionContext;
+import org.oasis.wsrp.v1.V1UpdateResponse;
+import org.oasis.wsrp.v1.V1UploadContext;
import org.oasis.wsrp.v1.V1UserContext;
import org.oasis.wsrp.v2.ClientData;
import org.oasis.wsrp.v2.CookieProtocol;
import org.oasis.wsrp.v2.Extension;
+import org.oasis.wsrp.v2.InteractionParams;
import org.oasis.wsrp.v2.ItemDescription;
import org.oasis.wsrp.v2.LocalizedString;
import org.oasis.wsrp.v2.MarkupContext;
import org.oasis.wsrp.v2.MarkupParams;
import org.oasis.wsrp.v2.MarkupType;
import org.oasis.wsrp.v2.ModelDescription;
+import org.oasis.wsrp.v2.NamedString;
import org.oasis.wsrp.v2.ModelTypes;
import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescription;
@@ -64,8 +74,13 @@
import org.oasis.wsrp.v2.ResourceList;
import org.oasis.wsrp.v2.RuntimeContext;
import org.oasis.wsrp.v2.ServiceDescription;
+import org.oasis.wsrp.v2.SessionContext;
+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;
/**
@@ -81,6 +96,9 @@
public static final V2ToV1PortletDescription V2_TO_V1_PORTLETDESCRIPTION = new
V2ToV1PortletDescription();
public static final V2ToV1LocalizedString V2_TO_V1_LOCALIZEDSTRING = new
V2ToV1LocalizedString();
public static final V2ToV1ItemDescription V2_TO_V1_ITEMDESCRIPTION = new
V2ToV1ItemDescription();
+
+ 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();
public static <F, T> List<T> transform(List<F> fromList,
Function<? super F, ? extends T> function)
@@ -294,12 +312,62 @@
{
throw new NotYetImplemented();
}
+
+ 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;
+ }
+
+ public static StateChange toV2StateChange (V1StateChange v1StateChange)
+ {
+ return StateChange.valueOf((v1StateChange.value()));
+ }
+
+ public static V1UpdateResponse toV1UpdateResponse(UpdateResponse updateResponse)
+ {
+ if (updateResponse != null)
+ {
+ V1UpdateResponse v1UpdateResponse = WSRP1TypeFactory.createUpdateResponse();
+
v1UpdateResponse.setMarkupContext(toV1MarkupContext(updateResponse.getMarkupContext()));
+
v1UpdateResponse.setNavigationalState(updateResponse.getNavigationalContext().getOpaqueValue());
+ v1UpdateResponse.setNewWindowState(updateResponse.getNewWindowState());
+
v1UpdateResponse.setPortletContext(toV1PortletContext(updateResponse.getPortletContext()));
+
v1UpdateResponse.setSessionContext(toV1SessionContext(updateResponse.getSessionContext()));
+ v1UpdateResponse.setNewMode(updateResponse.getNewMode());
+ return v1UpdateResponse;
+ }
+ else
+ {
+ return null;
+ }
+ }
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.getExtensions().addAll(Lists.transform(sessionContext.getExtensions(),
V2_TO_V1_EXTENSION));
+
+ return v1SessionContext;
+ }
+ else
+ {
+ return null;
+ }
}
-
+
private static class V1ToV2Extension implements Function<V1Extension,
Extension>
{
public Extension apply(V1Extension from)
@@ -409,6 +477,31 @@
}
}
+ public static class V1ToV2NamedString implements Function<V1NamedString,
NamedString>
+ {
+ public NamedString apply(V1NamedString v1NamedString)
+ {
+ NamedString result = new NamedString();
+ result.setName(v1NamedString.getName());
+ result.setValue(v1NamedString.getValue());
+ return result;
+ }
+ }
+
+ public static class V1ToV2UploadContext implements Function<V1UploadContext,
UploadContext>
+ {
+
+ public UploadContext apply(V1UploadContext v1UploadContext)
+ {
+ 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>
{
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/MarkupEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/MarkupEndpoint.java 2010-06-09
11:04:13 UTC (rev 3277)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/MarkupEndpoint.java 2010-06-09
13:48:51 UTC (rev 3278)
@@ -25,6 +25,7 @@
import org.gatein.common.NotYetImplemented;
import org.gatein.wsrp.endpoints.WSRPBaseEndpoint;
+import org.gatein.wsrp.spec.v1.V2V1Converter;
import org.oasis.wsrp.v1.V1AccessDenied;
import org.oasis.wsrp.v1.V1BlockingInteractionResponse;
import org.oasis.wsrp.v1.V1Extension;
@@ -57,14 +58,30 @@
import org.oasis.wsrp.v1.V1UpdateResponse;
import org.oasis.wsrp.v1.V1UserContext;
import org.oasis.wsrp.v1.WSRPV1MarkupPortType;
+import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.BlockingInteractionResponse;
import org.oasis.wsrp.v2.GetMarkup;
+import org.oasis.wsrp.v2.InconsistentParameters;
import org.oasis.wsrp.v2.InitCookie;
+import org.oasis.wsrp.v2.InvalidCookie;
+import org.oasis.wsrp.v2.InvalidHandle;
+import org.oasis.wsrp.v2.InvalidRegistration;
+import org.oasis.wsrp.v2.InvalidSession;
+import org.oasis.wsrp.v2.InvalidUserCategory;
import org.oasis.wsrp.v2.MarkupResponse;
+import org.oasis.wsrp.v2.MissingParameters;
+import org.oasis.wsrp.v2.OperationFailed;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
+import org.oasis.wsrp.v2.PortletStateChangeRequired;
import org.oasis.wsrp.v2.ReleaseSessions;
import org.oasis.wsrp.v2.ReturnAny;
+import org.oasis.wsrp.v2.UnsupportedLocale;
+import org.oasis.wsrp.v2.UnsupportedMimeType;
+import org.oasis.wsrp.v2.UnsupportedMode;
+import org.oasis.wsrp.v2.UnsupportedWindowState;
+import com.google.common.collect.Lists;
+
import javax.jws.HandlerChain;
import javax.jws.WebParam;
import javax.xml.ws.Holder;
@@ -100,23 +117,84 @@
V1UnsupportedLocale, V1InconsistentParameters, V1PortletStateChangeRequired,
V1InvalidHandle, V1InvalidRegistration,
V1InvalidUserCategory, V1AccessDenied, V1OperationFailed
{
- /*forceSessionAccess();
+
+ forceSessionAccess();
PerformBlockingInteraction performBlockingInteraction = new
PerformBlockingInteraction();
- performBlockingInteraction.setPortletContext(portletContext);
- performBlockingInteraction.setRuntimeContext(runtimeContext);
- performBlockingInteraction.setMarkupParams(markupParams);
- performBlockingInteraction.setInteractionParams(interactionParams);
- performBlockingInteraction.setRegistrationContext(registrationContext);
- performBlockingInteraction.setUserContext(userContext);
+
performBlockingInteraction.setPortletContext(V2V1Converter.toV2PortletContext(portletContext));
+
performBlockingInteraction.setRuntimeContext(V2V1Converter.toV2RuntimeContext(runtimeContext));
+
performBlockingInteraction.setMarkupParams(V2V1Converter.toV2MarkupParams(markupParams));
+
performBlockingInteraction.setInteractionParams(V2V1Converter.toV2InteractionParams(interactionParams));
+
+
performBlockingInteraction.setRegistrationContext(V2V1Converter.toV2RegistrationContext(registrationContext));
+
performBlockingInteraction.setUserContext(V2V1Converter.toV2UserContext(userContext));
- BlockingInteractionResponse interactionResponse =
producer.performBlockingInteraction(performBlockingInteraction);
+ BlockingInteractionResponse interactionResponse = null;
+ try
+ {
+ interactionResponse =
producer.performBlockingInteraction(performBlockingInteraction);
- updateResponse.value = interactionResponse.getUpdateResponse();
+ }
+ catch (InvalidCookie invalidCookie)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidCookie.class, invalidCookie);
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidHandle.class, invalidHandle);
+ }
+ catch (InvalidSession invalidSession)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidSession.class, invalidSession);
+ }
+ catch (UnsupportedMode unsupportedMode)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedMode.class, unsupportedMode);
+ }
+ catch (UnsupportedMimeType unsupportedMimeType)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedMimeType.class,
unsupportedMimeType);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ throw V2V1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
+ }
+ catch (UnsupportedWindowState unsupportedWindowState)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedWindowState.class,
unsupportedWindowState);
+ }
+ catch (UnsupportedLocale unsupportedLocale)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedLocale.class,
unsupportedLocale);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDenied);
+ }
+ catch (PortletStateChangeRequired portletStateChangeRequired)
+ {
+ throw V2V1Converter.toV1Exception(V1PortletStateChangeRequired.class,
portletStateChangeRequired);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidRegistration.class,
invalidRegistration);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ throw V2V1Converter.toV1Exception(V1MissingParameters.class,
missingParameters);
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidUserCategory.class,
invalidUserCategory);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ throw V2V1Converter.toV1Exception(V1InconsistentParameters.class,
inconsistentParameters);
+ }
+
+ updateResponse.value =
V2V1Converter.toV1UpdateResponse(interactionResponse.getUpdateResponse());
redirectURL.value = interactionResponse.getRedirectURL();
- extensions.value = interactionResponse.getExtensions();*/
-
- throw new NotYetImplemented();
+ extensions.value = Lists.transform(interactionResponse.getExtensions(),
V2V1Converter.V2_TO_V1_EXTENSION);
}
public List<V1Extension> releaseSessions(
@@ -124,17 +202,35 @@
@WebParam(name = "sessionIDs", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> sessionIDs
) throws V1MissingParameters, V1InvalidRegistration, V1AccessDenied,
V1OperationFailed
{
- /*forceSessionAccess();
+ forceSessionAccess();
ReleaseSessions releaseSessions = new ReleaseSessions();
- releaseSessions.setRegistrationContext(registrationContext);
+
releaseSessions.setRegistrationContext(V2V1Converter.toV2RegistrationContext(registrationContext));
releaseSessions.getSessionIDs().addAll(sessionIDs);
- ReturnAny returnAny = producer.releaseSessions(releaseSessions);
+ ReturnAny returnAny;
+ try
+ {
+ returnAny = producer.releaseSessions(releaseSessions);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidRegistration.class,
invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ throw V2V1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ throw V2V1Converter.toV1Exception(V1MissingParameters.class,
missingParameters);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDenied);
+ }
- return returnAny.getExtensions();*/
-
- throw new NotYetImplemented();
+ return Lists.transform(returnAny.getExtensions(),
V2V1Converter.V2_TO_V1_EXTENSION);
}
public void getMarkup(
@@ -145,42 +241,110 @@
@WebParam(name = "markupParams", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") V1MarkupParams markupParams,
@WebParam(mode = WebParam.Mode.OUT, name = "markupContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<V1MarkupContext> markupContext,
@WebParam(mode = WebParam.Mode.OUT, name = "sessionContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<V1SessionContext> sessionContext,
- @WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions
+ @WebParam(mode = WebParam.Mode.OUT, name =
"eUnsupportedWindowStatextensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions
) throws V1UnsupportedMimeType, V1UnsupportedMode, V1UnsupportedWindowState,
V1InvalidCookie, V1InvalidSession, V1MissingParameters,
V1UnsupportedLocale, V1InconsistentParameters, V1InvalidHandle,
V1InvalidRegistration, V1InvalidUserCategory, V1AccessDenied,
V1OperationFailed
{
- /*forceSessionAccess();
+ forceSessionAccess();
GetMarkup getMarkup = new GetMarkup();
- getMarkup.setRegistrationContext(registrationContext);
- getMarkup.setPortletContext(portletContext);
- getMarkup.setRuntimeContext(runtimeContext);
- getMarkup.setUserContext(userContext);
- getMarkup.setMarkupParams(markupParams);
+
getMarkup.setRegistrationContext(V2V1Converter.toV2RegistrationContext(registrationContext));
+ getMarkup.setPortletContext(V2V1Converter.toV2PortletContext(portletContext));
+ getMarkup.setRuntimeContext(V2V1Converter.toV2RuntimeContext(runtimeContext));
+ getMarkup.setUserContext(V2V1Converter.toV2UserContext(userContext));
+ getMarkup.setMarkupParams(V2V1Converter.toV2MarkupParams(markupParams));
- MarkupResponse response = producer.getMarkup(getMarkup);
+ MarkupResponse response;
+ try
+ {
+ response = producer.getMarkup(getMarkup);
+ }
+ catch (UnsupportedWindowState unsupportedWindowState)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedWindowState.class,
unsupportedWindowState);
+ }
+ catch (InvalidCookie invalidCookie)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidCookie.class, invalidCookie);
+ }
+ catch (InvalidSession invalidSession)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidSession.class, invalidSession);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDenied);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ throw V2V1Converter.toV1Exception(V1InconsistentParameters.class,
inconsistentParameters);
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidHandle.class, invalidHandle);
+ }
+ catch (UnsupportedLocale unsupportedLocale)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedLocale.class,
unsupportedLocale);
+ }
+ catch (UnsupportedMode unsupportedMode)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedMode.class, unsupportedMode);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ throw V2V1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ throw V2V1Converter.toV1Exception(V1MissingParameters.class,
missingParameters);
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidUserCategory.class,
invalidUserCategory);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidRegistration.class,
invalidRegistration);
+ }
+ catch (UnsupportedMimeType unsupportedMimeType)
+ {
+ throw V2V1Converter.toV1Exception(V1UnsupportedMimeType.class,
unsupportedMimeType);
+ }
- markupContext.value = response.getMarkupContext();
- sessionContext.value = response.getSessionContext();
- extensions.value = response.getExtensions();*/
-
- throw new NotYetImplemented();
+ markupContext.value =
V2V1Converter.toV1MarkupContext(response.getMarkupContext());
+ sessionContext.value =
V2V1Converter.toV1SessionContext(response.getSessionContext());
+ extensions.value = Lists.transform(response.getExtensions(),
V2V1Converter.V2_TO_V1_EXTENSION);
}
public List<V1Extension> initCookie(
@WebParam(name = "registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") V1RegistrationContext registrationContext
) throws V1InvalidRegistration, V1AccessDenied, V1OperationFailed
{
- /*forceSessionAccess();
+ forceSessionAccess();
InitCookie initCookie = new InitCookie();
- initCookie.setRegistrationContext(registrationContext);
+
initCookie.setRegistrationContext(V2V1Converter.toV2RegistrationContext(registrationContext));
- ReturnAny returnAny = producer.initCookie(initCookie);
+ ReturnAny returnAny;
+ try
+ {
+ returnAny = producer.initCookie(initCookie);
+ }
+ catch (AccessDenied accessDenied)
+ {
+ throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDenied);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ throw V2V1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ throw V2V1Converter.toV1Exception(V1InvalidRegistration.class,
invalidRegistration);
+ }
- return returnAny.getExtensions();*/
-
- throw new NotYetImplemented();
+ return Lists.transform(returnAny.getExtensions(),
V2V1Converter.V2_TO_V1_EXTENSION);
}
}