Author: chris.laprun(a)jboss.com
Date: 2010-06-14 05:43:26 -0400 (Mon, 14 Jun 2010)
New Revision: 3320
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/PortletManagementEndpoint.java
Log:
- GTNWSRP-43: Replaced direct calls to constructors.
- GTNWSRP-42: Started updating for WSRP 2 type compliance.
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-14
08:58:54 UTC (rev 3319)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2010-06-14
09:43:26 UTC (rev 3320)
@@ -92,9 +92,10 @@
import static org.gatein.wsrp.WSRPRewritingConstants.*;
/**
+ * TODO: NEEDS TO BE UPDATED TO CONFORM TO WSRP 2 XSD, see GTNWSRP-42
+ * <p/>
* Creates minimally valid instances of WSRP types, populated with default values where
possible, as per
- * wsrp_v2_types.xsd. See <a
href="http://jira.jboss.com/jira/browse/JBPORTAL-808">JBPORT...
for more
- * information.
+ * wsrp_v2_types.xsd.
*
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision: 11317 $
@@ -212,6 +213,18 @@
return description;
}
+ public static GetPortletDescription createGetPortletDescription(RegistrationContext
registrationContext, PortletContext portletContext, UserContext userContext)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationContext,
"registration context");
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet
context");
+ ParameterValidation.throwIllegalArgExceptionIfNull(userContext, "user
context");
+ GetPortletDescription description = new GetPortletDescription();
+ description.setPortletContext(portletContext);
+ description.setRegistrationContext(registrationContext);
+ description.setUserContext(userContext);
+ return description;
+ }
+
/**
* @param registrationContext
* @param portletContext
@@ -239,31 +252,25 @@
return getPortletDescription;
}
- /**
- * registrationContext(RegistrationContext)?, portletContext(PortletContext),
userContext(UserContext)?,
- * desiredLocales(xsd:string)*
- *
- * @param registrationContext
- * @param portletContext
- * @return
- * @since 2.4.1
- */
- public static GetPortletProperties createGetPortletProperties(RegistrationContext
registrationContext, PortletContext portletContext)
+ public static GetPortletProperties createGetPortletProperties(RegistrationContext
registrationContext, PortletContext portletContext, UserContext userContext,
List<String> names)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationContext,
"RegistrationContext");
+ ParameterValidation.throwIllegalArgExceptionIfNull(userContext,
"UserContext");
+ if (!ParameterValidation.existsAndIsNotEmpty(names))
+ {
+ throw new IllegalArgumentException("Must pass a non-null list of property
names");
+ }
GetPortletProperties properties = new GetPortletProperties();
properties.setRegistrationContext(registrationContext);
properties.setPortletContext(portletContext);
+ properties.setUserContext(userContext);
+ properties.getNames().addAll(names);
return properties;
}
- /** ====== WSRP Response objects ====== **/
+ /** ====== WSRP Response objects ====== * */
- /**
- * ( updateResponse(UpdateResponse) | redirectURL(xsd:string) ),
extensions(Extension)*
- *
- * @return
- */
public static BlockingInteractionResponse
createBlockingInteractionResponse(UpdateResponse updateResponse)
{
if (updateResponse == null)
@@ -275,11 +282,6 @@
return interactionResponse;
}
- /**
- * ( updateResponse(UpdateResponse) | redirectURL(xsd:string) ),
extensions(Extension)*
- *
- * @return
- */
public static BlockingInteractionResponse createBlockingInteractionResponse(String
redirectURL)
{
if (redirectURL == null || redirectURL.length() == 0)
@@ -291,27 +293,11 @@
return interactionResponse;
}
- /**
- * sessionContext(SessionContext)?, portletContext(PortletContext)?,
markupContext(MarkupContext)?,
- * navigationalState(xsd:string)? newWindowState(xsd:string)?, newMode(xsd:string)?
- *
- * @return
- */
public static UpdateResponse createUpdateResponse()
{
return new UpdateResponse();
}
- /**
- * portletHandle(xsd:string), markupTypes(MarkupType)+, groupID(xsd:string)?,
description(LocalizedString)?,
- * shortTitle(LocalizedString)?, title(LocalizedString)?,
displayName(LocalizedString)?, keywords(LocalizedString)*,
- * userCategories(xsd:string)*, userProfileItems(xsd:string)*,
usesMethodGet(xsd:boolean[false])?,
- * defaultMarkupSecure(xsd:boolean[false])?, onlySecure(xsd:boolean[false])?,
userContextStoredInSession(xsd:boolean[false])?,
- * templatesStoredInSession(xsd:boolean[false])?,
hasUserSpecificState(xsd:boolean[false])?,
- * doesUrlTemplateProcessing(xsd:boolean[false])?, extensions(Extension)*
- *
- * @return
- */
public static PortletDescription
createPortletDescription(org.gatein.pc.api.PortletContext portletContext,
List<MarkupType> markupTypes)
{
PortletContext context = WSRPUtils.convertToWSRPPortletContext(portletContext);
@@ -366,14 +352,6 @@
WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE);
}
- /**
- * secureClientCommunication(xsd:boolean), locales(xsd:string)+,
mimeTypes(xsd:string)+, mode(xsd:string),
- * windowState(xsd:string), clientData({@link ClientData})?,
navigationalState(xsd:string)?,
- * markupCharacterSets(xsd:string)*, validateTag(xsd:string)?,
validNewModes(xsd:string)*,
- * validNewWindowStates(xsd:string)*, extensions({@link
org.oasis.wsrp.v2.Extension})*
- *
- * @return
- */
public static MarkupParams createMarkupParams(boolean secureClientCommunication,
List<String> locales,
List<String> mimeTypes, String
mode, String windowState)
{
@@ -412,12 +390,6 @@
return createRuntimeContext(WSRPConstants.NONE_USER_AUTHENTICATION);
}
- /**
- * userAuthentication(xsd:string), portletInstanceKey(xsd:string)?,
namespacePrefix(xsd:string)?,
- * templates(Templates)?, sessionID(xsd:string)?, extensions(Extension)*
- *
- * @return
- */
public static RuntimeContext createRuntimeContext(String userAuthentication)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(userAuthentication,
"user authentication", "RuntimeContext");
@@ -427,12 +399,6 @@
return runtimeContext;
}
- /**
- * portletHandle(xsd:string), portletState(xsd:base64Binary)?, extensions({@link
org.oasis.wsrp.v2.Extension})*
- *
- * @param portletHandle
- * @return
- */
public static PortletContext createPortletContext(String portletHandle)
{
checkPortletHandle(portletHandle);
@@ -443,12 +409,6 @@
}
- /**
- * @param portletHandle
- * @param portletState
- * @return
- * @since 2.6
- */
public static PortletContext createPortletContext(String portletHandle, byte[]
portletState)
{
PortletContext pc = createPortletContext(portletHandle);
@@ -466,12 +426,6 @@
return createInteractionParams(StateChange.READ_ONLY);
}
- /**
- * portletStateChange({@link StateChange}), interactionState(xsd:string)?,
formParameters(NamedString)*,
- * uploadContexts(UploadContext)*, extensions(Extension)*
- *
- * @return
- */
public static InteractionParams createInteractionParams(StateChange
portletStateChange)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletStateChange,
"portletStateChange");
@@ -481,12 +435,6 @@
return interactionParams;
}
- /**
- * registrationContext(RegistrationContext)?
- *
- * @param registrationContext
- * @return
- */
public static InitCookie createInitCookie(RegistrationContext registrationContext)
{
InitCookie initCookie = new InitCookie();
@@ -494,15 +442,6 @@
return initCookie;
}
- /**
- * requiresRegistration(xsd:boolean), offeredPortlets(PortletDescription)*,
userCategoryDescriptions(ItemDescription)*,
- * customUserProfileItemDescriptions(ItemDescription)*,
customWindowStateDescriptions(ItemDescription)*,
- * customModeDescriptions(ItemDescription)*,
requiresInitCookie(CookieProtocol[none])?,
- * registrationPropertyDescription(ModelDescription)?, locales(xsd:string)*,
resourceList(ResourceList)?,
- * extensions(Extension)*
- *
- * @return
- */
public static ServiceDescription createServiceDescription(boolean
requiresRegistration)
{
ServiceDescription serviceDescription = new ServiceDescription();
@@ -510,11 +449,6 @@
return serviceDescription;
}
- /**
- * markupContext(MarkupContext), sessionContext(SessionContext)?,
extensions(Extension)*
- *
- * @return
- */
public static MarkupResponse createMarkupResponse(MarkupContext markupContext)
{
ParameterValidation.throwIllegalArgExceptionIfNull(markupContext,
"MarkupContext");
@@ -530,11 +464,6 @@
* textual mime types using the syntax specified in RFC1522[14] (e.g. "text/html;
charset=UTF-8"). In this particular
* case this character set MAY be different than the response message.
* <p/>
- * useCachedMarkup(xsd:boolean[false])?, mimeType(xsd:string)?,
(markupString(xsd:string) |
- * markupBinary(xsd:base64Binary)), locale(xsd:string)?,
requiresUrlRewriting(xsd:boolean[false])?,
- * cacheControl(CacheControl)?, preferredTitle(xsd:string)?, extensions(Extension)*
- *
- * @return
*/
public static MarkupContext createMarkupContext(String mediaType, String
markupString)
{
@@ -550,10 +479,6 @@
}
/**
- * useCachedMarkup(xsd:boolean[false])?, mimeType(xsd:string)?,
(markupString(xsd:string) |
- * markupBinary(xsd:base64Binary)), locale(xsd:string)?,
requiresUrlRewriting(xsd:boolean[false])?,
- * cacheControl(CacheControl)?, preferredTitle(xsd:string)?, extensions(Extension)*
- *
* @param mediaType The mime type of the returned markup. The mimeType field MUST be
specified whenever markup is
* returned, and if the markupBinary field is used to return the
markup, the mime type MUST include
* the character set for textual mime types using the syntax
specified in RFC1522[14] (e.g.
@@ -575,8 +500,6 @@
}
/**
- * sessionID(xsd:string), expires(xsd:int), extensions(Extension)*
- *
* @param sessionID An opaque string the Portlet defines for referencing state that is
stored locally on the
* Producer. The maximum length of a sessionID is 4096 characters,
* @param expires Maximum number of seconds between invocations referencing the
sessionID before the Producer will
@@ -597,13 +520,7 @@
return sessionContext;
}
- /**
- * For UserProfile and related classes, everything is optional so no need to have
factory methods.
- * <p/>
- * userContextKey(xsd:string), userCategories(xsd:string)*, profile(UserProfile)?,
extensions(Extension)*
- *
- * @return
- */
+ /** For UserProfile and related classes, everything is optional so no need to have
factory methods. */
public static UserContext createUserContext(String userContextKey)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(userContextKey,
"user context key", "UserContext");
@@ -613,10 +530,6 @@
}
/**
- * consumerName(xsd:string), consumerAgent(xsd:string),
methodGetSupported(xsd:boolean), consumerModes(xsd:string)*,
- * consumerWindowStates(xsd:string)*, consumerUserScopes(xsd:string)*,
customUserProfileData(xsd:string)*,
- * registrationProperties(Property)*, extensions(Extension)*
- *
* @param consumerName A name (preferably unique) that identifies the Consumer
[R355] An example of such a name
* would be the Consumer's URL.
* @param methodGetSupported A flag that tells the Producer whether the Consumer has
implemented portlet URLs
@@ -650,11 +563,6 @@
return registrationData;
}
- /**
- * ( stringValue(xsd:string) | any* ), @name(xsd:string), @xml:lang
- *
- * @return
- */
public static Property createProperty(String name, String lang, String stringValue)
{
// QName.valueOf validates name
@@ -1044,26 +952,19 @@
return clonePortlet;
}
- /**
- * registrationContext(RegistrationContext)?, portletHandles(xsd:string)+
- *
- * @return
- * @since 2.6
- */
public static DestroyPortlets createDestroyPortlets(RegistrationContext
registrationContext, List<String> portletHandles)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationContext,
"RegistrationContext");
ParameterValidation.throwIllegalArgExceptionIfNull(portletHandles, "Portlet
handles");
- if (portletHandles.isEmpty())
+ if (!ParameterValidation.existsAndIsNotEmpty(portletHandles))
{
throw new IllegalArgumentException("Cannot create a DestroyPortlets with an
empty list of portlet handles!");
}
DestroyPortlets destroyPortlets = new DestroyPortlets();
destroyPortlets.setRegistrationContext(registrationContext);
- if (ParameterValidation.existsAndIsNotEmpty(portletHandles))
- {
- destroyPortlets.getPortletHandles().addAll(portletHandles);
- }
+ destroyPortlets.getPortletHandles().addAll(portletHandles);
+
return destroyPortlets;
}
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-14
08:58:54 UTC (rev 3319)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/PortletManagementEndpoint.java 2010-06-14
09:43:26 UTC (rev 3320)
@@ -23,6 +23,8 @@
package org.gatein.wsrp.endpoints.v1;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.wsrp.WSRPTypeFactory;
import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.endpoints.WSRPBaseEndpoint;
import org.gatein.wsrp.spec.v1.V1ToV2Converter;
@@ -97,15 +99,16 @@
@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(V1ToV2Converter.toV2RegistrationContext(registrationContext));
-
getPortletPropertyDescription.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
-
getPortletPropertyDescription.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
- getPortletPropertyDescription.getDesiredLocales().addAll(desiredLocales);
- PortletPropertyDescriptionResponse descriptionResponse;
try
{
- descriptionResponse =
producer.getPortletPropertyDescription(getPortletPropertyDescription);
+ GetPortletPropertyDescription getPortletPropertyDescription =
WSRPTypeFactory.createGetPortletPropertyDescription(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext),
+ V1ToV2Converter.toV2PortletContext(portletContext),
+ V1ToV2Converter.toV2UserContext(userContext),
+ desiredLocales
+ );
+ PortletPropertyDescriptionResponse descriptionResponse =
+ producer.getPortletPropertyDescription(getPortletPropertyDescription);
modelDescription.value =
V2ToV1Converter.toV1ModelDescription(descriptionResponse.getModelDescription());
resourceList.value =
V2ToV1Converter.toV1ResourceList(descriptionResponse.getResourceList());
@@ -151,16 +154,15 @@
@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(V1ToV2Converter.toV2RegistrationContext(registrationContext));
-
setPortletProperties.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
- setPortletProperties.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
-
setPortletProperties.setPropertyList(V1ToV2Converter.toV2PropertyList(propertyList));
-
- PortletContext response;
try
{
- response = producer.setPortletProperties(setPortletProperties);
+ SetPortletProperties setPortletProperties =
WSRPTypeFactory.createSetPortletProperties(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext),
+ V1ToV2Converter.toV2PortletContext(portletContext),
+ V1ToV2Converter.toV2PropertyList(propertyList));
+
setPortletProperties.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
+
+ PortletContext response = producer.setPortletProperties(setPortletProperties);
portletHandle.value = response.getPortletHandle();
portletState.value = response.getPortletState();
extensions.value = WSRPUtils.transform(response.getExtensions(),
V2ToV1Converter.EXTENSION);
@@ -204,15 +206,15 @@
@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(V1ToV2Converter.toV2RegistrationContext(registrationContext));
-
clonePortlet.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
- clonePortlet.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
-
- PortletContext response;
try
{
- response = producer.clonePortlet(clonePortlet);
+ ClonePortlet clonePortlet = WSRPTypeFactory.createClonePortlet(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext),
+ V1ToV2Converter.toV2PortletContext(portletContext),
+ V1ToV2Converter.toV2UserContext(userContext)
+ );
+
+ PortletContext response = producer.clonePortlet(clonePortlet);
portletHandle.value = response.getPortletHandle();
portletState.value = response.getPortletState();
extensions.value = WSRPUtils.transform(response.getExtensions(),
V2ToV1Converter.EXTENSION);
@@ -257,14 +259,18 @@
@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
{
- GetPortletDescription getPortletDescription = new GetPortletDescription();
-
getPortletDescription.setRegistrationContext(V1ToV2Converter.toV2RegistrationContext(registrationContext));
-
getPortletDescription.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
-
getPortletDescription.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
- getPortletDescription.getDesiredLocales().addAll(desiredLocales);
-
try
{
+ GetPortletDescription getPortletDescription =
WSRPTypeFactory.createGetPortletDescription(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext),
+ V1ToV2Converter.toV2PortletContext(portletContext),
+ V1ToV2Converter.toV2UserContext(userContext)
+ );
+ if (ParameterValidation.existsAndIsNotEmpty(desiredLocales))
+ {
+ getPortletDescription.getDesiredLocales().addAll(desiredLocales);
+ }
+
PortletDescriptionResponse description =
producer.getPortletDescription(getPortletDescription);
portletDescription.value =
V2ToV1Converter.toV1PortletDescription(description.getPortletDescription());
@@ -311,14 +317,15 @@
@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
{
- GetPortletProperties getPortletProperties = new GetPortletProperties();
-
getPortletProperties.setRegistrationContext(V1ToV2Converter.toV2RegistrationContext(registrationContext));
-
getPortletProperties.setPortletContext(V1ToV2Converter.toV2PortletContext(portletContext));
- getPortletProperties.setUserContext(V1ToV2Converter.toV2UserContext(userContext));
- getPortletProperties.getNames().addAll(names);
-
try
{
+ GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext),
+ V1ToV2Converter.toV2PortletContext(portletContext),
+ V1ToV2Converter.toV2UserContext(userContext),
+ names
+ );
+
PropertyList result = producer.getPortletProperties(getPortletProperties);
properties.value = WSRPUtils.transform(result.getProperties(),
V2ToV1Converter.PROPERTY);
@@ -362,14 +369,12 @@
@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(V1ToV2Converter.toV2RegistrationContext(registrationContext));
- destroyPortlets.getPortletHandles().addAll(portletHandles);
-
- DestroyPortletsResponse destroyPortletsResponse;
try
{
- destroyPortletsResponse = producer.destroyPortlets(destroyPortlets);
+ DestroyPortlets destroyPortlets = WSRPTypeFactory.createDestroyPortlets(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext), portletHandles
+ );
+ DestroyPortletsResponse destroyPortletsResponse =
producer.destroyPortlets(destroyPortlets);
destroyFailed.value =
V2ToV1Converter.toV1DestroyFailed(destroyPortletsResponse.getFailedPortlets());
extensions.value = WSRPUtils.transform(destroyPortletsResponse.getExtensions(),
V2ToV1Converter.EXTENSION);