Author: mwringe
Date: 2010-09-03 17:19:40 -0400 (Fri, 03 Sep 2010)
New Revision: 4042
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
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/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1TypeFactory.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v2/WSRP2ExceptionFactory.java
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/RenderHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/TestProducerBehavior.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/PortletManagementEndpoint.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/RegistrationEndpoint.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/NeedPortletHandleTest.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/NeedPortletHandleTest.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
Log:
GTNWSRP-43: update calls to WSRP 2 type constructors to use the WSRPTypeFactory instead of
directly.
GTNWSRP-42: update WSRPTypeFactory to be conform to the xsd.
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -105,72 +105,68 @@
}
}
- EmployerInfo employerInfo = new EmployerInfo();
- employerInfo.setEmployer(userInfos.get(INFO_USER_EMPLOYER));
- employerInfo.setDepartment(userInfos.get(INFO_USER_DEPARTMENT));
- employerInfo.setJobtitle(userInfos.get(INFO_USER_JOB_TITLE));
+ String employer = userInfos.get(INFO_USER_EMPLOYER);
+ String department = userInfos.get(INFO_USER_DEPARTMENT);
+ String jobTitle = userInfos.get(INFO_USER_JOB_TITLE);
+ EmployerInfo employerInfo = WSRPTypeFactory.createEmployerInfo(employer,
department, jobTitle);
- UserProfile userProfile = new UserProfile();
- userProfile.setName(name);
- userProfile.setBdate(bdate);
- userProfile.setGender(userInfos.get(INFO_USER_GENDER));
- userProfile.setEmployerInfo(employerInfo);
- userProfile.setHomeInfo(createContactFrom(userInfos, false));
- userProfile.setBusinessInfo(createContactFrom(userInfos, true));
+ Contact homeInfo = createContactFrom(userInfos, false);
+ Contact businessInfo = createContactFrom(userInfos, true);
+ UserProfile userProfile = WSRPTypeFactory.createUserProfile(name, bdate,
userInfos.get(INFO_USER_GENDER), employerInfo, homeInfo, businessInfo);
+
return userProfile;
}
private static PersonName createNameFrom(Map<String, String> userInfos)
{
- PersonName name = new PersonName();
- name.setPrefix(userInfos.get(INFO_USER_NAME_PREFIX));
- name.setFamily(userInfos.get(INFO_USER_NAME_FAMILY));
- name.setGiven(userInfos.get(INFO_USER_NAME_GIVEN));
- name.setMiddle(userInfos.get(INFO_USER_NAME_MIDDLE));
- name.setSuffix(userInfos.get(INFO_USER_NAME_SUFFIX));
- name.setNickname(userInfos.get(INFO_USER_NAME_NICKNAME));
+ String prefix = userInfos.get(INFO_USER_NAME_PREFIX);
+ String given = userInfos.get(INFO_USER_NAME_GIVEN);
+ String family = userInfos.get(INFO_USER_NAME_FAMILY);
+ String middle = userInfos.get(INFO_USER_NAME_MIDDLE);
+ String suffix = userInfos.get(INFO_USER_NAME_SUFFIX);
+ String nickName = userInfos.get(INFO_USER_NAME_NICKNAME);
+
+ PersonName name = WSRPTypeFactory.createPersonName(prefix, given, family, middle,
suffix, nickName);
+
return name;
}
private static Contact createContactFrom(Map<String, String> infos, boolean
isBusiness)
{
- Online online = new Online();
- online.setEmail(infos.get(getOnlineUserInfoKey(OnlineInfo.EMAIL, isBusiness)));
- online.setUri(infos.get(getOnlineUserInfoKey(OnlineInfo.URI, isBusiness)));
+ String email = infos.get(getOnlineUserInfoKey(OnlineInfo.EMAIL, isBusiness));
+ String uri = infos.get(getOnlineUserInfoKey(OnlineInfo.URI, isBusiness));
+ Online online = WSRPTypeFactory.createOnline(email, uri);
- Postal postal = new Postal();
- postal.setName(infos.get(getPostalUserInfoKey(PostalInfo.NAME, isBusiness)));
- postal.setStreet(infos.get(getPostalUserInfoKey(PostalInfo.STREET, isBusiness)));
- postal.setCity(infos.get(getPostalUserInfoKey(PostalInfo.CITY, isBusiness)));
- postal.setStateprov(infos.get(getPostalUserInfoKey(PostalInfo.STATEPROV,
isBusiness)));
- postal.setPostalcode(infos.get(getPostalUserInfoKey(PostalInfo.POSTALCODE,
isBusiness)));
- postal.setCountry(infos.get(getPostalUserInfoKey(PostalInfo.COUNTRY,
isBusiness)));
- postal.setOrganization(infos.get(getPostalUserInfoKey(PostalInfo.ORGANIZATION,
isBusiness)));
+ String name = infos.get(getPostalUserInfoKey(PostalInfo.NAME, isBusiness));
+ String street = infos.get(getPostalUserInfoKey(PostalInfo.STREET, isBusiness));
+ String city = infos.get(getPostalUserInfoKey(PostalInfo.CITY, isBusiness));
+ String stateprov = infos.get(getPostalUserInfoKey(PostalInfo.STATEPROV,
isBusiness));
+ String postalCode = infos.get(getPostalUserInfoKey(PostalInfo.POSTALCODE,
isBusiness));
+ String country = infos.get(getPostalUserInfoKey(PostalInfo.COUNTRY, isBusiness));
+ String organization = infos.get(getPostalUserInfoKey(PostalInfo.ORGANIZATION,
isBusiness));
+ Postal postal = WSRPTypeFactory.createPostal(name, street, city, stateprov,
postalCode, country, organization);
- Telecom telecom = new Telecom();
- telecom.setTelephone(createTelephoneNumFrom(infos, TelecomType.TELEPHONE,
isBusiness));
- telecom.setFax(createTelephoneNumFrom(infos, TelecomType.FAX, isBusiness));
- telecom.setMobile(createTelephoneNumFrom(infos, TelecomType.MOBILE, isBusiness));
- telecom.setPager(createTelephoneNumFrom(infos, TelecomType.PAGER, isBusiness));
+ TelephoneNum telephone = createTelephoneNumFrom(infos, TelecomType.TELEPHONE,
isBusiness);
+ TelephoneNum fax = createTelephoneNumFrom(infos, TelecomType.FAX, isBusiness);
+ TelephoneNum mobile = createTelephoneNumFrom(infos, TelecomType.MOBILE,
isBusiness);
+ TelephoneNum pager = createTelephoneNumFrom(infos, TelecomType.PAGER, isBusiness);
+ Telecom telecom = WSRPTypeFactory.createTelecom(telephone, fax, mobile, pager);
+
+ Contact contact = WSRPTypeFactory.createContact(postal, telecom, online);
- Contact contact = new Contact();
- contact.setPostal(postal);
- contact.setTelecom(telecom);
- contact.setOnline(online);
-
return contact;
}
private static TelephoneNum createTelephoneNumFrom(Map<String, String> infos,
TelecomType type, boolean isBusiness)
{
- TelephoneNum num = new TelephoneNum();
- num.setIntcode(infos.get(getTelecomInfoKey(type, TelecomInfo.INTCODE,
isBusiness)));
- num.setLoccode(infos.get(getTelecomInfoKey(type, TelecomInfo.LOCCODE,
isBusiness)));
- num.setNumber(infos.get(getTelecomInfoKey(type, TelecomInfo.NUMBER, isBusiness)));
- num.setExt(infos.get(getTelecomInfoKey(type, TelecomInfo.EXT, isBusiness)));
- num.setComment(infos.get(getTelecomInfoKey(type, TelecomInfo.COMMENT,
isBusiness)));
+ String intCode = infos.get(getTelecomInfoKey(type, TelecomInfo.INTCODE,
isBusiness));
+ String loccode = infos.get(getTelecomInfoKey(type, TelecomInfo.LOCCODE,
isBusiness));
+ String number = infos.get(getTelecomInfoKey(type, TelecomInfo.NUMBER,
isBusiness));
+ String ext = infos.get(getTelecomInfoKey(type, TelecomInfo.EXT, isBusiness));
+ String comment = infos.get(getTelecomInfoKey(type, TelecomInfo.COMMENT,
isBusiness));
+ TelephoneNum telephoneNum = WSRPTypeFactory.createTelephoneNum(intCode, loccode,
number, ext, comment);
- return num;
+ return telephoneNum;
}
/**
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-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -44,8 +44,10 @@
import org.oasis.wsrp.v2.CacheControl;
import org.oasis.wsrp.v2.ClientData;
import org.oasis.wsrp.v2.ClonePortlet;
+import org.oasis.wsrp.v2.Contact;
import org.oasis.wsrp.v2.DestroyPortlets;
import org.oasis.wsrp.v2.DestroyPortletsResponse;
+import org.oasis.wsrp.v2.EmployerInfo;
import org.oasis.wsrp.v2.Event;
import org.oasis.wsrp.v2.EventDescription;
import org.oasis.wsrp.v2.EventParams;
@@ -53,6 +55,7 @@
import org.oasis.wsrp.v2.ExportPortlets;
import org.oasis.wsrp.v2.ExportPortletsResponse;
import org.oasis.wsrp.v2.ExportedPortlet;
+import org.oasis.wsrp.v2.Extension;
import org.oasis.wsrp.v2.FailedPortlets;
import org.oasis.wsrp.v2.GetMarkup;
import org.oasis.wsrp.v2.GetPortletDescription;
@@ -69,6 +72,7 @@
import org.oasis.wsrp.v2.ImportedPortlet;
import org.oasis.wsrp.v2.InitCookie;
import org.oasis.wsrp.v2.InteractionParams;
+import org.oasis.wsrp.v2.ItemDescription;
import org.oasis.wsrp.v2.Lifetime;
import org.oasis.wsrp.v2.LocalizedString;
import org.oasis.wsrp.v2.MarkupContext;
@@ -76,17 +80,22 @@
import org.oasis.wsrp.v2.MarkupResponse;
import org.oasis.wsrp.v2.MarkupType;
import org.oasis.wsrp.v2.MimeResponse;
+import org.oasis.wsrp.v2.MissingParametersFault;
import org.oasis.wsrp.v2.ModelDescription;
import org.oasis.wsrp.v2.ModifyRegistration;
import org.oasis.wsrp.v2.NamedString;
import org.oasis.wsrp.v2.NamedStringArray;
import org.oasis.wsrp.v2.NavigationalContext;
+import org.oasis.wsrp.v2.Online;
+import org.oasis.wsrp.v2.OperationFailedFault;
import org.oasis.wsrp.v2.ParameterDescription;
import org.oasis.wsrp.v2.PerformBlockingInteraction;
+import org.oasis.wsrp.v2.PersonName;
import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescription;
import org.oasis.wsrp.v2.PortletDescriptionResponse;
import org.oasis.wsrp.v2.PortletPropertyDescriptionResponse;
+import org.oasis.wsrp.v2.Postal;
import org.oasis.wsrp.v2.Property;
import org.oasis.wsrp.v2.PropertyDescription;
import org.oasis.wsrp.v2.PropertyList;
@@ -95,21 +104,29 @@
import org.oasis.wsrp.v2.ReleaseExport;
import org.oasis.wsrp.v2.ReleaseSessions;
import org.oasis.wsrp.v2.ResetProperty;
+import org.oasis.wsrp.v2.Resource;
import org.oasis.wsrp.v2.ResourceContext;
import org.oasis.wsrp.v2.ResourceList;
import org.oasis.wsrp.v2.ResourceParams;
import org.oasis.wsrp.v2.ResourceResponse;
+import org.oasis.wsrp.v2.ResourceValue;
+import org.oasis.wsrp.v2.ReturnAny;
import org.oasis.wsrp.v2.RuntimeContext;
import org.oasis.wsrp.v2.ServiceDescription;
import org.oasis.wsrp.v2.SessionContext;
+import org.oasis.wsrp.v2.SessionParams;
import org.oasis.wsrp.v2.SetExportLifetime;
import org.oasis.wsrp.v2.SetPortletProperties;
import org.oasis.wsrp.v2.StateChange;
+import org.oasis.wsrp.v2.Telecom;
+import org.oasis.wsrp.v2.TelephoneNum;
import org.oasis.wsrp.v2.Templates;
import org.oasis.wsrp.v2.UpdateResponse;
import org.oasis.wsrp.v2.UploadContext;
import org.oasis.wsrp.v2.UserContext;
+import org.oasis.wsrp.v2.UserProfile;
+import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.Collection;
@@ -119,7 +136,6 @@
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.
@@ -154,17 +170,6 @@
}
/**
- * Same as createMarkupRequest(handle, createDefaultRuntimeContext(),
createDefaultMarkupParams())
- *
- * @param handle
- * @return
- */
- public static GetMarkup createDefaultGetMarkup(String handle)
- {
- return createGetMarkup(null, createPortletContext(handle),
createDefaultRuntimeContext(), null, createDefaultMarkupParams());
- }
-
- /**
* {@link RegistrationContext} (nillable), {@link PortletContext}, {@link
RuntimeContext}, {@link UserContext}
* (nillable), {@link MarkupParams}
*
@@ -221,19 +226,6 @@
}
/**
- * Same as createPerformBlockingInteraction(portletHandle, {@link
#createDefaultRuntimeContext}(), {@link
- * #createDefaultMarkupParams}(), {@link #createDefaultInteractionParams}());
- *
- * @param portletHandle
- * @return
- */
- public static PerformBlockingInteraction
createDefaultPerformBlockingInteraction(String portletHandle)
- {
- return createPerformBlockingInteraction(null, createPortletContext(portletHandle),
createDefaultRuntimeContext(), null, createDefaultMarkupParams(),
- createDefaultInteractionParams());
- }
-
- /**
* {@link RegistrationContext} (nillable), {@link PortletContext}, {@link
RuntimeContext}, {@link UserContext}
* (nillable), {@link MarkupParams}, {@link InteractionParams}
*
@@ -309,8 +301,10 @@
*/
public static GetPortletDescription createGetPortletDescription(RegistrationContext
registrationContext, String portletHandle)
{
+ PortletContext portletContext = createPortletContext(portletHandle);
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet
context");
GetPortletDescription description = new GetPortletDescription();
- description.setPortletContext(createPortletContext(portletHandle));
+ description.setPortletContext(portletContext);
description.setRegistrationContext(registrationContext);
return description;
}
@@ -418,18 +412,6 @@
}
}
- /**
- * Same as createMarkupParams(false, {@link WSRPConstants#getDefaultLocales()},
{@link
- * WSRPConstants#getDefaultMimeTypes()}, {@link WSRPConstants#VIEW_MODE}, {@link
WSRPConstants#NORMAL_WINDOW_STATE})
- *
- * @return
- */
- public static MarkupParams createDefaultMarkupParams()
- {
- return createMarkupParams(false, WSRPConstants.getDefaultLocales(),
WSRPConstants.getDefaultMimeTypes(),
- WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE);
- }
-
public static MarkupParams createMarkupParams(boolean secureClientCommunication,
List<String> locales,
List<String> mimeTypes, String
mode, String windowState)
{
@@ -438,6 +420,11 @@
{
throw new IllegalArgumentException("Cannot create a MarkupParams with an
empty list of locales!");
}
+
+ if (mimeTypes.isEmpty())
+ {
+ throw new IllegalArgumentException("Cannot create a MarkupParams with an
empty list of mimeTypes!");
+ }
ParameterValidation.throwIllegalArgExceptionIfNull(mimeTypes, "MIME
types");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mode, "mode",
"MarkupParams");
@@ -471,6 +458,13 @@
{
throw new IllegalArgumentException("Cannot create a ResourceParams with an
empty list of locales!");
}
+
+ ParameterValidation.throwIllegalArgExceptionIfNull(mimeTypes,
"locales");
+ if (mimeTypes.isEmpty())
+ {
+ throw new IllegalArgumentException("Cannot create a MarkupParams with an
empty list of mimeTypes!");
+ }
+
ParameterValidation.throwIllegalArgExceptionIfNull(mimeTypes, "MIME
types");
ParameterValidation.throwIllegalArgExceptionIfNull(stateChange, "State
Change");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mode, "mode",
"ResourceParams");
@@ -497,23 +491,16 @@
return resourceParams;
}
- /**
- * Same as createRuntimeContext({@link WSRPConstants#NONE_USER_AUTHENTICATION})
- *
- * @return
- */
- public static RuntimeContext createDefaultRuntimeContext()
+ public static RuntimeContext createRuntimeContext(String userAuthentication, String
portletInstanceKey, String namespacePrefix)
{
- return createRuntimeContext(WSRPConstants.NONE_USER_AUTHENTICATION);
- }
-
- public static RuntimeContext createRuntimeContext(String userAuthentication)
- {
- //TODO: portletInstanceKey and NameSpacepPrefix are also required;
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(userAuthentication,
"user authentication", "RuntimeContext");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletInstanceKey,
"Portlet Instance Key", "RuntimeContext");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(namespacePrefix,
"Namespace Prefix", "RuntimeContext");
RuntimeContext runtimeContext = new RuntimeContext();
runtimeContext.setUserAuthentication(userAuthentication);
+ runtimeContext.setPortletInstanceKey(portletInstanceKey);
+ runtimeContext.setNamespacePrefix(namespacePrefix);
return runtimeContext;
}
@@ -534,16 +521,6 @@
return pc;
}
- /**
- * Same as createInteractionParams(StateChange.readOnly)
- *
- * @return
- */
- public static InteractionParams createDefaultInteractionParams()
- {
- return createInteractionParams(StateChange.READ_ONLY);
- }
-
public static InteractionParams createInteractionParams(StateChange
portletStateChange)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletStateChange,
"portletStateChange");
@@ -593,6 +570,7 @@
*/
public static MarkupContext createMarkupContext(String mediaType, String
markupString)
{
+ //TODO: this should be allowed to be null
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mediaType, "Media
type", "MarkupContext");
if (markupString == null)
{
@@ -614,6 +592,7 @@
*/
public static MarkupContext createMarkupContext(String mediaType, byte[]
markupBinary)
{
+ //TODO: this should be allowed to be null
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mediaType, "MIME
type", "MarkupContext");
if (markupBinary == null || markupBinary.length == 0)
{
@@ -640,6 +619,7 @@
public static <T extends MimeResponse> T createMimeResponse(String mimeType,
String itemString, byte[] itemBinary, Class<T> clazz)
{
+ //TODO: this should be allowed to be null
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mimeType, "MIME
type", "MimeResponse");
if ((itemString == null) && (itemBinary == null || itemBinary.length ==
0))
{
@@ -710,12 +690,13 @@
* method="get".
* @return
*/
- public static RegistrationData createRegistrationData(String consumerName, boolean
methodGetSupported)
+ public static RegistrationData createRegistrationData(String consumerName, String
consumerAgent, boolean methodGetSupported)
{
- //TODO: consumer agent requirement
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName,
"consumer name", "RegistrationData");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerAgent,
"consumer agent", "RegistrationData");
RegistrationData regData = createDefaultRegistrationData();
regData.setConsumerName(consumerName);
+ regData.setConsumerAgent(consumerAgent);
regData.setMethodGetSupported(methodGetSupported);
return regData;
}
@@ -745,10 +726,8 @@
public static Property createProperty(QName name, String lang, String stringValue)
{
- //TODO: stringValue is not required
ParameterValidation.throwIllegalArgExceptionIfNull(name, "name");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang,
"language", "Property");
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(stringValue, "String
value", "Property");
Property property = new Property();
property.setName(name);
@@ -878,6 +857,21 @@
return templates;
}
+
+ public static Templates createTemplates(String defaultTemplate, String
blockingActionTemplate, String renderTemplate, String resourceTemplate, String
secureDefaultTemplate, String secureBlockingActionTemplate, String secureRenderTemplate,
String secureResourceTemplate)
+ {
+ Templates templates = new Templates();
+ templates.setDefaultTemplate(defaultTemplate);
+ templates.setBlockingActionTemplate(blockingActionTemplate);
+ templates.setRenderTemplate(renderTemplate);
+ templates.setResourceTemplate(resourceTemplate);
+ templates.setSecureDefaultTemplate(secureDefaultTemplate);
+ templates.setSecureBlockingActionTemplate(secureBlockingActionTemplate);
+ templates.setSecureRenderTemplate(secureRenderTemplate);
+ templates.setSecureResourceTemplate(secureResourceTemplate);
+
+ return templates;
+ }
private static String createTemplate(PortletInvocationContext context, ContainerURL
url, Boolean secure)
{
@@ -1232,8 +1226,20 @@
public static MarkupType createMarkupType(String mimeType, List<String>
modeNames, List<String> windowStateNames, List<String> localeNames)
{
- //TODO: modes and windowstates might need a check for null
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mimeType, "MIME
Type", "MarkupContext");
+
+ ParameterValidation.throwIllegalArgExceptionIfNull(modeNames,
"modeNames");
+ if (modeNames.isEmpty())
+ {
+ throw new IllegalArgumentException("Cannot create a MarkupType with an
empty list of modes!");
+ }
+
+ ParameterValidation.throwIllegalArgExceptionIfNull(windowStateNames,
"windowStatesNames");
+ if (windowStateNames.isEmpty())
+ {
+ throw new IllegalArgumentException("Cannot create a MarkupType with an
empty list of windowStates!");
+ }
+
MarkupType markupType = new MarkupType();
markupType.setMimeType(mimeType);
@@ -1262,7 +1268,6 @@
*/
public static FailedPortlets createFailedPortlets(Collection<String>
portletHandles, ErrorCodes.Codes errorCode, String reason)
{
- //TODO: reason should be a LocalizedString
ParameterValidation.throwIllegalArgExceptionIfNull(errorCode,
"ErrorCode");
if (ParameterValidation.existsAndIsNotEmpty(portletHandles))
{
@@ -1328,6 +1333,19 @@
return null;
}
+
+ public static NavigationalContext createNavigationalContext(String opaqueValue,
List<NamedString> publicValues)
+ {
+ NavigationalContext navigationalContext = new NavigationalContext();
+ navigationalContext.setOpaqueValue(opaqueValue);
+
+ if (publicValues != null && !publicValues.isEmpty())
+ {
+ navigationalContext.getPublicValues().addAll(publicValues);
+ }
+
+ return navigationalContext;
+ }
public static ParameterDescription createParameterDescription(String identifier)
{
@@ -1388,6 +1406,7 @@
public static NamedString createNamedString(String name, String value)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "name");
NamedString namedString = new NamedString();
namedString.setName(name);
namedString.setValue(value);
@@ -1437,6 +1456,7 @@
public static ExportedPortlet createExportedPortlet(String portletHandle, byte[]
exportData)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletHandle,
"PortletHandle");
+ ParameterValidation.throwIllegalArgExceptionIfNull(exportData,
"ExportData");
ExportedPortlet exportedPortlet = new ExportedPortlet();
exportedPortlet.setPortletHandle(portletHandle);
@@ -1486,7 +1506,6 @@
public static ImportPortletsFailed createImportPortletsFailed(List<String>
importIds, ErrorCodes.Codes errorCode, String reason)
{
- //TODO: reason should be a LocalizedString
ParameterValidation.throwIllegalArgExceptionIfNull(errorCode,
"ErrorCode");
if (ParameterValidation.existsAndIsNotEmpty(importIds))
{
@@ -1501,7 +1520,7 @@
return failedPortlets;
}
- throw new IllegalArgumentException("Must provide non-null, non-empty portlet
handle list.");
+ throw new IllegalArgumentException("Must provide non-null, non-empty portlet
id list.");
}
public static ImportedPortlet createImportedPortlet(String portletID, PortletContext
portletContext)
@@ -1518,6 +1537,7 @@
public static ReleaseExport createReleaseExport(RegistrationContext
registrationContext, byte[] exportContext, UserContext userContext)
{
+ //Can the exportContext be empty?
if (exportContext == null || exportContext.length == 0)
{
throw new IllegalArgumentException("Must provide a non null or empty
exportContext to ReleaseExport.");
@@ -1533,6 +1553,7 @@
public static SetExportLifetime createSetExportLifetime(RegistrationContext
registrationContext, byte[] exportContext, UserContext userContext, Lifetime lifetime)
{
+ //Can the exportContext be empty?
if (exportContext == null || exportContext.length == 0)
{
throw new IllegalArgumentException("Must provide a non null or empty
exportContext to SetExportLifetime.");
@@ -1546,4 +1567,180 @@
return setExportLifetime;
}
+
+ public static Contact createContact(Postal postal, Telecom telecom, Online online)
+ {
+ Contact contact = new Contact();
+ contact.setPostal(postal);
+ contact.setTelecom(telecom);
+ contact.setOnline(online);
+
+ return contact;
+ }
+
+ public static Postal createPostal(String name, String street, String city, String
stateprov, String postalCode, String country, String organization)
+ {
+ Postal postal = new Postal();
+ postal.setName(name);
+ postal.setStreet(street);
+ postal.setCity(city);
+ postal.setStateprov(stateprov);
+ postal.setPostalcode(postalCode);
+ postal.setCountry(country);
+ postal.setOrganization(organization);
+
+ return postal;
+ }
+
+ public static Telecom createTelecom(TelephoneNum telephone, TelephoneNum fax,
TelephoneNum mobile, TelephoneNum pager)
+ {
+ Telecom telecom = new Telecom();
+ telecom.setTelephone(telephone);
+ telecom.setFax(fax);
+ telecom.setMobile(mobile);
+ telecom.setPager(pager);
+
+ return telecom;
+ }
+
+ public static TelephoneNum createTelephoneNum(String intCode, String loccode, String
number, String ext, String comment)
+ {
+ TelephoneNum telephoneNum = new TelephoneNum();
+ telephoneNum.setIntcode(intCode);
+ telephoneNum.setLoccode(loccode);
+ telephoneNum.setNumber(number);
+ telephoneNum.setExt(ext);
+ telephoneNum.setComment(comment);
+
+ return telephoneNum;
+ }
+
+ public static Online createOnline(String email, String uri)
+ {
+ Online online = new Online();
+ online.setEmail(email);
+ online.setUri(uri);
+ return online;
+ }
+
+ public static EmployerInfo createEmployerInfo(String employer, String department,
String jobTitle)
+ {
+ EmployerInfo employerInfo = new EmployerInfo();
+ employerInfo.setEmployer(employer);
+ employerInfo.setDepartment(department);
+ employerInfo.setJobtitle(jobTitle);
+
+ return employerInfo;
+ }
+
+ public static PersonName createPersonName(String prefix, String given, String family,
String middle, String suffix, String nickname)
+ {
+ PersonName personName = new PersonName();
+ personName.setPrefix(prefix);
+ personName.setGiven(given);
+ personName.setFamily(family);
+ personName.setMiddle(middle);
+ personName.setSuffix(suffix);
+ personName.setNickname(nickname);
+
+ return personName;
+ }
+
+ public static Extension createExtension(Object any)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(any, "Any");
+ Extension extension = new Extension();
+ extension.setAny(any);
+
+ return extension;
+ }
+
+ public static MissingParametersFault createMissingParametersFault()
+ {
+ MissingParametersFault missingParametersFault = new MissingParametersFault();
+ return missingParametersFault;
+ }
+
+ public static OperationFailedFault createOperationFailedFault()
+ {
+ OperationFailedFault operationFailedFault = new OperationFailedFault();
+ return operationFailedFault;
+ }
+
+ public static ItemDescription createItemDescription(LocalizedString description,
LocalizedString displayName, String itemName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(itemName,
"ItemName");
+
+ ItemDescription itemDescription = new ItemDescription();
+ itemDescription.setDescription(description);
+ itemDescription.setDisplayName(displayName);
+ itemDescription.setItemName(itemName);
+
+ return itemDescription;
+ }
+
+ public static Resource createResource(String resourceName, List<ResourceValue>
resourceValue)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(resourceName,
"ResourceName");
+ Resource resource = new Resource();
+ resource.setResourceName(resourceName);
+
+ if (resourceValue != null && !resourceValue.isEmpty())
+ {
+ resource.getValues().addAll(resourceValue);
+ }
+
+ return resource;
+ }
+
+ public static ResourceList createResourceList(List<Resource> resources)
+ {
+ if (ParameterValidation.existsAndIsNotEmpty(resources))
+ {
+ ResourceList resourceList = new ResourceList();
+ resourceList.getResources().addAll(resources);
+
+ return resourceList;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Must provide non-null, non-empty
resource list.");
+ }
+ }
+
+ public static ResourceValue createResourceValue(String lang, String value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(lang, "Lang");
+ ResourceValue resourceValue = new ResourceValue();
+ resourceValue.setLang(value);
+ resourceValue.setValue(value);
+
+ return resourceValue;
+ }
+
+ public static ReturnAny createReturnAny()
+ {
+ return new ReturnAny();
+ }
+
+ public static SessionParams createSessionParams(String sessionID)
+ {
+ SessionParams sessionParams = new SessionParams();
+ sessionParams.setSessionID(sessionID);
+
+ return sessionParams;
+ }
+
+ public static UserProfile createUserProfile(PersonName name, XMLGregorianCalendar
bdate, String gender, EmployerInfo employerInfo, Contact homeInfo, Contact businessInfo)
+ {
+ UserProfile userProfile = new UserProfile();
+ userProfile.setName(name);
+ userProfile.setBdate(bdate);
+ userProfile.setGender(gender);
+ userProfile.setEmployerInfo(employerInfo);
+ userProfile.setHomeInfo(homeInfo);
+ userProfile.setBusinessInfo(businessInfo);
+
+ return userProfile;
+ }
}
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-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -142,6 +142,8 @@
import java.util.Collections;
import java.util.List;
+import javax.xml.datatype.XMLGregorianCalendar;
+
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
@@ -271,13 +273,9 @@
{
if (v1RuntimeContext != null)
{
- RuntimeContext runtimeContext =
WSRPTypeFactory.createRuntimeContext(v1RuntimeContext.getUserAuthentication());
- runtimeContext.setNamespacePrefix(v1RuntimeContext.getNamespacePrefix());
- runtimeContext.setPortletInstanceKey(v1RuntimeContext.getPortletInstanceKey());
+ RuntimeContext runtimeContext =
WSRPTypeFactory.createRuntimeContext(v1RuntimeContext.getUserAuthentication(),
v1RuntimeContext.getPortletInstanceKey(), v1RuntimeContext.getNamespacePrefix());
- //TODO: handle the SessionParams better
- SessionParams sessionParams = new SessionParams();
- sessionParams.setSessionID(v1RuntimeContext.getSessionID());
+ SessionParams sessionParams =
WSRPTypeFactory.createSessionParams(v1RuntimeContext.getSessionID());
runtimeContext.setSessionParams(sessionParams);
runtimeContext.setTemplates(toV2Templates(v1RuntimeContext.getTemplates()));
@@ -300,15 +298,15 @@
{
if (v1Templates != null)
{
- //TODO: should we be using the
WSRP1TypeFactory,createTemplates(PortletInvocationContext) instead?
- Templates templates = new Templates();
- templates.setBlockingActionTemplate(v1Templates.getBlockingActionTemplate());
- templates.setDefaultTemplate(v1Templates.getDefaultTemplate());
- templates.setRenderTemplate(v1Templates.getRenderTemplate());
- templates.setResourceTemplate(v1Templates.getResourceTemplate());
-
templates.setSecureBlockingActionTemplate(v1Templates.getSecureBlockingActionTemplate());
- templates.setSecureRenderTemplate(v1Templates.getSecureRenderTemplate());
- templates.setSecureResourceTemplate(v1Templates.getSecureResourceTemplate());
+ String defaultTemplate = v1Templates.getDefaultTemplate();
+ String blockingActionTemplate = v1Templates.getBlockingActionTemplate();
+ String renderTemplate = v1Templates.getRenderTemplate();
+ String resourceTemplate = v1Templates.getResourceTemplate();
+ String secureDefaultTemplate = v1Templates.getSecureDefaultTemplate();
+ String secureBlockingActionTemplate =
v1Templates.getSecureBlockingActionTemplate();
+ String secureRenderTemplate = v1Templates.getSecureRenderTemplate();
+ String secureResourceTemplate = v1Templates.getSecureResourceTemplate();
+ Templates templates = WSRPTypeFactory.createTemplates(defaultTemplate,
blockingActionTemplate, renderTemplate, resourceTemplate, secureDefaultTemplate,
secureBlockingActionTemplate, secureRenderTemplate, secureResourceTemplate);
List<V1Extension> extensions = v1Templates.getExtensions();
if (extensions != null)
@@ -354,13 +352,13 @@
{
if (v1UserProfile != null)
{
- UserProfile userProfile = new UserProfile();
- userProfile.setBdate(v1UserProfile.getBdate());
- userProfile.setBusinessInfo(toV2Context(v1UserProfile.getBusinessInfo()));
- userProfile.setEmployerInfo(toV2EmployerInfo(v1UserProfile.getEmployerInfo()));
- userProfile.setGender(v1UserProfile.getGender());
- userProfile.setHomeInfo(toV2Context(v1UserProfile.getHomeInfo()));
- userProfile.setName(toV2PersonName(v1UserProfile.getName()));
+ PersonName name = toV2PersonName(v1UserProfile.getName());
+ XMLGregorianCalendar bdate = v1UserProfile.getBdate();
+ String gender = v1UserProfile.getGender();
+ EmployerInfo employerInfo = toV2EmployerInfo(v1UserProfile.getEmployerInfo());
+ Contact homeInfo = toV2Context(v1UserProfile.getHomeInfo());
+ Contact businessInfo = toV2Context(v1UserProfile.getBusinessInfo());
+ UserProfile userProfile = WSRPTypeFactory.createUserProfile(name, bdate, gender,
employerInfo, homeInfo, businessInfo);
return userProfile;
}
@@ -374,10 +372,10 @@
{
if (v1EmployerInfo != null)
{
- EmployerInfo employerInfo = new EmployerInfo();
- employerInfo.setDepartment(v1EmployerInfo.getDepartment());
- employerInfo.setEmployer(v1EmployerInfo.getEmployer());
- employerInfo.setJobtitle(v1EmployerInfo.getJobtitle());
+ String employer = v1EmployerInfo.getEmployer();
+ String department = v1EmployerInfo.getEmployer();
+ String jobTitle = v1EmployerInfo.getJobtitle();
+ EmployerInfo employerInfo = WSRPTypeFactory.createEmployerInfo(employer,
department, jobTitle);
List<V1Extension> extensions = v1EmployerInfo.getExtensions();
if (extensions != null)
@@ -397,14 +395,8 @@
{
if (v1PersonName != null)
{
- PersonName personName = new PersonName();
- personName.setFamily(v1PersonName.getFamily());
- personName.setGiven(v1PersonName.getGiven());
- personName.setMiddle(v1PersonName.getMiddle());
- personName.setNickname(v1PersonName.getNickname());
- personName.setPrefix(v1PersonName.getPrefix());
- personName.setSuffix(v1PersonName.getSuffix());
-
+ PersonName personName =
WSRPTypeFactory.createPersonName(v1PersonName.getPrefix(), v1PersonName.getGiven(),
v1PersonName.getFamily(), v1PersonName.getMiddle(), v1PersonName.getSuffix(),
v1PersonName.getNickname());
+
List<V1Extension> extensions = v1PersonName.getExtensions();
if (extensions != null)
{
@@ -423,10 +415,10 @@
{
if (v1Contact != null)
{
- Contact contact = new Contact();
- contact.setOnline(toV2Online(v1Contact.getOnline()));
- contact.setPostal(toV2Postal(v1Contact.getPostal()));
- contact.setTelecom(toV2Telecom(v1Contact.getTelecom()));
+ Postal postal = toV2Postal(v1Contact.getPostal());
+ Telecom teleCom = toV2Telecom(v1Contact.getTelecom());
+ Online online = toV2Online(v1Contact.getOnline());
+ Contact contact = WSRPTypeFactory.createContact(postal, teleCom, online);
List<V1Extension> extensions = v1Contact.getExtensions();
if (extensions != null)
@@ -446,9 +438,7 @@
{
if (v1Online != null)
{
- Online online = new Online();
- online.setEmail(v1Online.getEmail());
- online.setUri(v1Online.getUri());
+ Online online = WSRPTypeFactory.createOnline(v1Online.getEmail(),
v1Online.getUri());
List<V1Extension> extensions = v1Online.getExtensions();
if (extensions != null)
@@ -468,14 +458,7 @@
{
if (v1Postal != null)
{
- Postal postal = new Postal();
- postal.setCity(v1Postal.getCity());
- postal.setCountry(v1Postal.getCountry());
- postal.setName(v1Postal.getName());
- postal.setOrganization(v1Postal.getOrganization());
- postal.setPostalcode(v1Postal.getPostalcode());
- postal.setStateprov(v1Postal.getStateprov());
- postal.setStreet(v1Postal.getStreet());
+ Postal postal = WSRPTypeFactory.createPostal(v1Postal.getName(),
v1Postal.getStreet(), v1Postal.getCity(), v1Postal.getStateprov(),
v1Postal.getPostalcode(), v1Postal.getCountry(), v1Postal.getOrganization());
List<V1Extension> extensions = v1Postal.getExtensions();
if (extensions != null)
@@ -495,11 +478,11 @@
{
if (v1Telecom != null)
{
- Telecom telecom = new Telecom();
- telecom.setFax(toV2TelephoneNum(v1Telecom.getFax()));
- telecom.setMobile(toV2TelephoneNum(v1Telecom.getMobile()));
- telecom.setPager(toV2TelephoneNum(v1Telecom.getPager()));
- telecom.setTelephone(toV2TelephoneNum(v1Telecom.getTelephone()));
+ TelephoneNum telephone = toV2TelephoneNum(v1Telecom.getTelephone());
+ TelephoneNum fax = toV2TelephoneNum(v1Telecom.getFax());
+ TelephoneNum mobile = toV2TelephoneNum(v1Telecom.getMobile());
+ TelephoneNum pager = toV2TelephoneNum(v1Telecom.getPager());
+ Telecom telecom = WSRPTypeFactory.createTelecom(telephone, fax, mobile, pager);
List<V1Extension> extensions = v1Telecom.getExtensions();
if (extensions != null)
@@ -519,12 +502,12 @@
{
if (v1TelephoneNum != null)
{
- TelephoneNum telephoneNum = new TelephoneNum();
- telephoneNum.setComment(v1TelephoneNum.getComment());
- telephoneNum.setExt(v1TelephoneNum.getExt());
- telephoneNum.setIntcode(v1TelephoneNum.getIntcode());
- telephoneNum.setLoccode(v1TelephoneNum.getLoccode());
- telephoneNum.setNumber(v1TelephoneNum.getNumber());
+ String intCode = v1TelephoneNum.getIntcode();
+ String loccode = v1TelephoneNum.getLoccode();
+ String number = v1TelephoneNum.getNumber();
+ String ext = v1TelephoneNum.getExt();
+ String comment = v1TelephoneNum.getComment();
+ TelephoneNum telephoneNum = WSRPTypeFactory.createTelephoneNum(intCode, loccode,
number, ext, comment);
List<V1Extension> extensions = v1TelephoneNum.getExtensions();
if (extensions != null)
@@ -651,18 +634,14 @@
{
if (v1ResourceList != null)
{
- ResourceList result = new ResourceList();
+ List<Resource> resources =
WSRPUtils.transform(v1ResourceList.getResources(), RESOURCE);
+ ResourceList result = WSRPTypeFactory.createResourceList(resources);
List<Extension> extensions =
WSRPUtils.transform(v1ResourceList.getExtensions(), EXTENSION);
if (extensions != null)
{
result.getExtensions().addAll(extensions);
}
- List<Resource> resources =
WSRPUtils.transform(v1ResourceList.getResources(), RESOURCE);
- if (resources != null)
- {
- result.getResources().addAll(resources);
- }
return result;
}
@@ -732,8 +711,7 @@
{
if (registrationData != null)
{
- RegistrationData result =
WSRPTypeFactory.createRegistrationData(registrationData.getConsumerName(),
registrationData.isMethodGetSupported());
- result.setConsumerAgent(registrationData.getConsumerAgent());
+ RegistrationData result =
WSRPTypeFactory.createRegistrationData(registrationData.getConsumerName(),
registrationData.getConsumerAgent(), registrationData.isMethodGetSupported());
List<Property> properties =
WSRPUtils.transform(registrationData.getRegistrationProperties(), PROPERTY);
if (properties != null)
@@ -1076,8 +1054,7 @@
{
if (from != null)
{
- Extension extension = new Extension();
- extension.setAny(from.getAny());
+ Extension extension = WSRPTypeFactory.createExtension(from.getAny());
return extension;
}
else
@@ -1145,9 +1122,8 @@
{
if (from != null)
{
- ItemDescription result = new ItemDescription();
- result.setItemName(from.getItemName());
- result.setDescription(LOCALIZEDSTRING.apply(from.getDescription()));
+ LocalizedString description = LOCALIZEDSTRING.apply(from.getDescription());
+ ItemDescription result = WSRPTypeFactory.createItemDescription(description,
null, from.getItemName());
List<Extension> extensions = WSRPUtils.transform(from.getExtensions(),
EXTENSION);
if (extensions != null)
{
@@ -1244,14 +1220,7 @@
{
if (from != null)
{
- Resource result = new Resource();
- result.setResourceName(from.getResourceName());
- List<ResourceValue> values = WSRPUtils.transform(from.getValues(),
RESOURCEVALUE);
- if (values != null)
- {
- result.getValues().addAll(values);
- }
-
+ Resource result = WSRPTypeFactory.createResource(from.getResourceName(),
WSRPUtils.transform(from.getValues(), RESOURCEVALUE));
return result;
}
else
@@ -1268,9 +1237,8 @@
{
if (from != null)
{
- ResourceValue result = new ResourceValue();
- result.setLang(from.getLang());
- result.setValue(from.getValue());
+ ResourceValue result = WSRPTypeFactory.createResourceValue(from.getLang(),
from.getValue());
+
List<Extension> extensions = WSRPUtils.transform(from.getExtensions(),
EXTENSION);
if (extensions != 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-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -243,7 +243,7 @@
{
if (runtimeContext != null)
{
- V1RuntimeContext v1RuntimeContext =
WSRP1TypeFactory.createRuntimeContext(runtimeContext.getUserAuthentication());
+ V1RuntimeContext v1RuntimeContext =
WSRP1TypeFactory.createRuntimeContext(runtimeContext.getUserAuthentication(),
runtimeContext.getPortletInstanceKey(), runtimeContext.getNamespacePrefix());
v1RuntimeContext.setNamespacePrefix(runtimeContext.getNamespacePrefix());
v1RuntimeContext.setPortletInstanceKey(runtimeContext.getPortletInstanceKey());
SessionParams sessionParams = runtimeContext.getSessionParams();
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-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1TypeFactory.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -120,17 +120,6 @@
}
/**
- * Same as createMarkupRequest(handle, createDefaultRuntimeContext(),
createDefaultMarkupParams())
- *
- * @param handle
- * @return
- */
- public static V1GetMarkup createDefaultMarkupRequest(String handle)
- {
- return createMarkupRequest(createPortletContext(handle),
createDefaultRuntimeContext(), createDefaultMarkupParams());
- }
-
- /**
* registrationContext(RegistrationContext)?, portletContext(PortletContext),
runtimeContext(RuntimeContext),
* userContext(UserContext)?, markupParams(MarkupParams)
*
@@ -154,19 +143,6 @@
}
/**
- * Same as createPerformBlockingInteraction(portletHandle, {@link
#createDefaultRuntimeContext}(), {@link
- * #createDefaultMarkupParams}(), {@link #createDefaultInteractionParams}());
- *
- * @param portletHandle
- * @return
- */
- public static V1PerformBlockingInteraction
createDefaultPerformBlockingInteraction(String portletHandle)
- {
- return createPerformBlockingInteraction(createPortletContext(portletHandle),
createDefaultRuntimeContext(), createDefaultMarkupParams(),
- createDefaultInteractionParams());
- }
-
- /**
* {@link V1RegistrationContext}?, {@link V1PortletContext}, {@link V1RuntimeContext},
{@link V1UserContext}?, {@link
* V1MarkupParams}, {@link V1InteractionParams}
*
@@ -403,27 +379,19 @@
}
/**
- * Same as createRuntimeContext({@link WSRPConstants#NONE_USER_AUTHENTICATION})
- *
- * @return
- */
- public static V1RuntimeContext createDefaultRuntimeContext()
- {
- 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 V1RuntimeContext createRuntimeContext(String userAuthentication)
+ public static V1RuntimeContext createRuntimeContext(String userAuthentication, String
portletInstanceKey, String namespacePrefix)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(userAuthentication,
"user authentication", "RuntimeContext");
V1RuntimeContext runtimeContext = new V1RuntimeContext();
runtimeContext.setUserAuthentication(userAuthentication);
+ runtimeContext.setPortletInstanceKey(portletInstanceKey);
+ runtimeContext.setNamespacePrefix(namespacePrefix);
return runtimeContext;
}
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v2/WSRP2ExceptionFactory.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v2/WSRP2ExceptionFactory.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v2/WSRP2ExceptionFactory.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -24,6 +24,7 @@
package org.gatein.wsrp.spec.v2;
import org.gatein.wsrp.WSRPExceptionFactory;
+import org.gatein.wsrp.WSRPTypeFactory;
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.ExportByValueNotSupported;
import org.oasis.wsrp.v2.ExportNoLongerValid;
@@ -103,7 +104,7 @@
{
if (valueToCheck == null)
{
- throw new MissingParameters("Missing required " + valueName + (context
!= null ? " in " + context : ""), new MissingParametersFault());
+ throw new MissingParameters("Missing required " + valueName + (context
!= null ? " in " + context : ""),
WSRPTypeFactory.createMissingParametersFault());
}
}
@@ -111,7 +112,7 @@
{
if (valueToCheck == null)
{
- throw new OperationFailed("Missing required " + valueName, new
OperationFailedFault());
+ throw new OperationFailed("Missing required " + valueName,
WSRPTypeFactory.createOperationFailedFault());
}
}
Modified:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java
===================================================================
---
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -24,6 +24,8 @@
package org.gatein.wsrp.spec.v1;
import junit.framework.TestCase;
+
+import org.gatein.wsrp.WSRPTypeFactory;
import org.oasis.wsrp.v1.V1InvalidSession;
import org.oasis.wsrp.v1.V1OperationFailed;
import org.oasis.wsrp.v2.OperationFailed;
@@ -38,7 +40,7 @@
public void testException() throws Exception
{
Throwable throwable = new Throwable();
- OperationFailed operationFailed = new OperationFailed("foo", new
OperationFailedFault(), throwable);
+ OperationFailed operationFailed = new OperationFailed("foo",
WSRPTypeFactory.createOperationFailedFault(), throwable);
V1OperationFailed v1OperationFailed =
V2ToV1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
assertNotNull(v1OperationFailed);
assertEquals("foo", v1OperationFailed.getMessage());
@@ -48,7 +50,7 @@
public void testExceptionMismatch()
{
Throwable throwable = new Throwable();
- OperationFailed operationFailed = new OperationFailed("foo", new
OperationFailedFault(), throwable);
+ OperationFailed operationFailed = new OperationFailed("foo",
WSRPTypeFactory.createOperationFailedFault(), throwable);
try
{
@@ -64,7 +66,7 @@
public void testExceptionWrongRequestedException()
{
Throwable throwable = new Throwable();
- OperationFailed operationFailed = new OperationFailed("foo", new
OperationFailedFault(), throwable);
+ OperationFailed operationFailed = new OperationFailed("foo",
WSRPTypeFactory.createOperationFailedFault(), throwable);
try
{
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -334,7 +334,16 @@
SecurityContext securityContext = invocation.getSecurityContext();
ParameterValidation.throwIllegalArgExceptionIfNull(securityContext,
SECURITY_CONTEXT);
String authType =
WSRPUtils.convertRequestAuthTypeToWSRPAuthType(securityContext.getAuthType());
- runtimeContext = WSRPTypeFactory.createRuntimeContext(authType);
+
+ String portletInstanceKey = invocation.getInstanceContext().getId();
+ String namespacePrefix = getNamespaceFrom(invocation.getWindowContext());
+
+ if (namespacePrefix == null)
+ {
+ namespacePrefix = getPortletHandle();
+ }
+
+ runtimeContext = WSRPTypeFactory.createRuntimeContext(authType,
portletInstanceKey, namespacePrefix);
// user context
userContext = wsrpConsumer.getUserContextFrom(invocation, runtimeContext);
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/RenderHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/RenderHandler.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/RenderHandler.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -116,8 +116,8 @@
consumer.getMarkupService().getMarkup(request.getRegistrationContext(),
request.getPortletContext(),
request.getRuntimeContext(), request.getUserContext(),
request.getMarkupParams(),
markupContextHolder, sessionContextHolder, new
Holder<List<Extension>>());
- MarkupResponse markupResponse = new MarkupResponse();
- markupResponse.setMarkupContext(markupContextHolder.value);
+
+ MarkupResponse markupResponse =
WSRPTypeFactory.createMarkupResponse(markupContextHolder.value);
markupResponse.setSessionContext(sessionContextHolder.value);
return markupResponse;
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -28,6 +28,7 @@
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.wsrp.WSRPTypeFactory;
import org.gatein.wsrp.api.SessionEvent;
import org.gatein.wsrp.api.SessionEventListener;
import org.gatein.wsrp.consumer.WSRPConsumerImpl;
@@ -204,10 +205,13 @@
SessionParams sessionParams = runtimeContext.getSessionParams();
if (sessionParams == null)
{
- sessionParams = new SessionParams();
+ sessionParams = WSRPTypeFactory.createSessionParams(sessionId);
runtimeContext.setSessionParams(sessionParams);
}
- sessionParams.setSessionID(sessionId);
+ else
+ {
+ sessionParams.setSessionID(sessionId);
+ }
}
}
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/MarkupBehavior.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -169,12 +169,7 @@
@WebParam(name = "sessionContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<SessionContext> sessionContext,
@WebParam(name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<Extension>> extensions) throws AccessDenied,
InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed,
ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, UnsupportedMode,
UnsupportedWindowState
{
- GetMarkup gm = new GetMarkup();
- gm.setMarkupParams(markupParams);
- gm.setPortletContext(portletContext);
- gm.setRegistrationContext(registrationContext);
- gm.setRuntimeContext(runtimeContext);
- gm.setUserContext(userContext);
+ GetMarkup gm = WSRPTypeFactory.createGetMarkup(registrationContext, portletContext,
runtimeContext, userContext, markupParams);
NavigationalContext navigationalContext = markupParams.getNavigationalContext();
String markupString =
getMarkupString(WSRPUtils.getJSR168PortletModeFromWSRPName(markupParams.getMode()),
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/TestProducerBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/TestProducerBehavior.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/TestProducerBehavior.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -23,6 +23,9 @@
package org.gatein.wsrp.test.protocol.v2;
+import java.util.ArrayList;
+import java.util.List;
+
import org.gatein.common.net.media.MediaType;
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.WSRPTypeFactory;
@@ -61,14 +64,21 @@
}
public PortletDescription createPortletDescription(String portletHandle, String
suffix)
- {
- PortletDescription portletDesc = new PortletDescription();
- portletDesc.setPortletHandle(portletHandle);
- MarkupType markupType = new MarkupType();
- markupType.setMimeType(MediaType.TEXT_HTML.getValue());
- markupType.getModes().add(WSRPConstants.VIEW_MODE);
- markupType.getWindowStates().add(WSRPConstants.NORMAL_WINDOW_STATE);
- markupType.getLocales().addAll(WSRPConstants.getDefaultLocales());
+ {
+ String mimeType = MediaType.TEXT_HTML.getValue();
+ List<String> modes = new ArrayList<String>();
+ modes.add(WSRPConstants.VIEW_MODE);
+
+ List<String> windowStates = new ArrayList<String>();
+ windowStates.add(WSRPConstants.NORMAL_WINDOW_STATE);
+
+ MarkupType markupType = WSRPTypeFactory.createMarkupType(mimeType,modes,
windowStates, WSRPConstants.getDefaultLocales());
+
+ List<MarkupType> markupTypes = new ArrayList<MarkupType>();
+ markupTypes.add(markupType);
+
+ PortletDescription portletDesc =
WSRPTypeFactory.createPortletDescription(portletHandle, markupTypes);
+
portletDesc.getMarkupTypes().add(markupType);
String suffixString = suffix == null ? "" : suffix;
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -622,7 +622,7 @@
}
catch (Exception e)
{
- throw new OperationFailed("Operation Failed while trying to
ExportPortlets.", new OperationFailedFault());
+ throw new OperationFailed("Operation Failed while trying to
ExportPortlets.", WSRPTypeFactory.createOperationFailedFault());
}
finally
{
@@ -759,7 +759,7 @@
}
//this method shouldn't return anything
- return new ReturnAny().getExtensions();
+ return WSRPTypeFactory.createReturnAny().getExtensions();
}
public Lifetime setExportLifetime(SetExportLifetime setExportLifetime) throws
OperationFailed, InvalidRegistration, OperationNotSupported
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -86,8 +86,8 @@
{
try
{
- RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData(consumerName, methodGetSupported);
- registrationData.setConsumerAgent(consumerAgent);
+ RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData(consumerName, consumerAgent, methodGetSupported);
+
if (ParameterValidation.existsAndIsNotEmpty(consumerModes))
{
registrationData.getConsumerModes().addAll(consumerModes);
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/MarkupEndpoint.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -125,9 +125,7 @@
{
forceSessionAccess();
- ReleaseSessions releaseSessions = new ReleaseSessions();
- releaseSessions.setRegistrationContext(registrationContext);
- releaseSessions.getSessionIDs().addAll(sessionIDs);
+ ReleaseSessions releaseSessions =
WSRPTypeFactory.createReleaseSessions(registrationContext, sessionIDs);
return producer.releaseSessions(releaseSessions);
}
@@ -139,8 +137,7 @@
{
forceSessionAccess();
- InitCookie initCookie = new InitCookie();
- initCookie.setRegistrationContext(registrationContext);
+ InitCookie initCookie = WSRPTypeFactory.createInitCookie(registrationContext);
return producer.initCookie(initCookie);
}
@@ -149,12 +146,7 @@
{
forceSessionAccess();
- GetMarkup getMarkup = new GetMarkup();
- getMarkup.setRegistrationContext(registrationContext);
- getMarkup.setPortletContext(portletContext);
- getMarkup.setRuntimeContext(runtimeContext);
- getMarkup.setUserContext(userContext);
- getMarkup.setMarkupParams(markupParams);
+ GetMarkup getMarkup = WSRPTypeFactory.createGetMarkup(registrationContext,
portletContext, runtimeContext, userContext, markupParams);
MarkupResponse response = producer.getMarkup(getMarkup);
@@ -177,12 +169,7 @@
ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, UnsupportedMode,
UnsupportedWindowState
{
forceSessionAccess();
- GetResource getResource = new GetResource();
- getResource.setPortletContext(portletContext.value);
- getResource.setRegistrationContext(registrationContext);
- getResource.setResourceParams(resourceParams);
- getResource.setRuntimeContext(runtimeContext);
- getResource.setUserContext(userContext);
+ GetResource getResource = WSRPTypeFactory.createGetResource(registrationContext,
portletContext.value, runtimeContext, userContext, resourceParams);
ResourceResponse response = producer.getResource(getResource);
@@ -196,13 +183,7 @@
{
forceSessionAccess();
- PerformBlockingInteraction performBlockingInteraction = new
PerformBlockingInteraction();
- performBlockingInteraction.setPortletContext(portletContext);
- performBlockingInteraction.setRuntimeContext(runtimeContext);
- performBlockingInteraction.setMarkupParams(markupParams);
- performBlockingInteraction.setInteractionParams(interactionParams);
- performBlockingInteraction.setRegistrationContext(registrationContext);
- performBlockingInteraction.setUserContext(userContext);
+ PerformBlockingInteraction performBlockingInteraction =
WSRPTypeFactory.createPerformBlockingInteraction(registrationContext, portletContext,
runtimeContext, userContext, markupParams, interactionParams);
BlockingInteractionResponse interactionResponse =
producer.performBlockingInteraction(performBlockingInteraction);
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/PortletManagementEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/PortletManagementEndpoint.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/PortletManagementEndpoint.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -106,11 +106,7 @@
throws AccessDenied, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory,
MissingParameters, ModifyRegistrationRequired, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- GetPortletPropertyDescription getPortletPropertyDescription = new
GetPortletPropertyDescription();
- getPortletPropertyDescription.setRegistrationContext(registrationContext);
- getPortletPropertyDescription.setPortletContext(portletContext);
- getPortletPropertyDescription.setUserContext(userContext);
- getPortletPropertyDescription.getDesiredLocales().addAll(desiredLocales);
+ GetPortletPropertyDescription getPortletPropertyDescription =
WSRPTypeFactory.createGetPortletPropertyDescription(registrationContext, portletContext,
userContext, desiredLocales);
PortletPropertyDescriptionResponse descriptionResponse =
producer.getPortletPropertyDescription(getPortletPropertyDescription);
@@ -130,10 +126,7 @@
throws AccessDenied, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory,
MissingParameters, ModifyRegistrationRequired, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- GetPortletDescription getPortletDescription = new GetPortletDescription();
- getPortletDescription.setRegistrationContext(registrationContext);
- getPortletDescription.setPortletContext(portletContext);
- getPortletDescription.setUserContext(userContext);
+ GetPortletDescription getPortletDescription =
WSRPTypeFactory.createGetPortletDescription(registrationContext, portletContext,
userContext);
getPortletDescription.getDesiredLocales().addAll(desiredLocales);
PortletDescriptionResponse description =
producer.getPortletDescription(getPortletDescription);
@@ -155,10 +148,7 @@
throws AccessDenied, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory,
MissingParameters, ModifyRegistrationRequired, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- ClonePortlet clonePortlet = new ClonePortlet();
- clonePortlet.setRegistrationContext(registrationContext);
- clonePortlet.setPortletContext(portletContext);
- clonePortlet.setUserContext(userContext);
+ ClonePortlet clonePortlet = WSRPTypeFactory.createClonePortlet(registrationContext,
portletContext, userContext);
PortletContext response = producer.clonePortlet(clonePortlet);
@@ -175,9 +165,7 @@
@WebParam(name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<Extension>> extensions)
throws InconsistentParameters, InvalidRegistration, MissingParameters,
ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
{
- DestroyPortlets destroyPortlets = new DestroyPortlets();
- destroyPortlets.setRegistrationContext(registrationContext);
- destroyPortlets.getPortletHandles().addAll(portletHandles);
+ DestroyPortlets destroyPortlets =
WSRPTypeFactory.createDestroyPortlets(registrationContext, portletHandles);
DestroyPortletsResponse destroyPortletsResponse =
producer.destroyPortlets(destroyPortlets);
@@ -307,11 +295,8 @@
@WebParam(name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<Extension>> extensions)
throws AccessDenied, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- SetPortletProperties setPortletProperties = new SetPortletProperties();
- setPortletProperties.setRegistrationContext(registrationContext);
- setPortletProperties.setPortletContext(portletContext);
+ SetPortletProperties setPortletProperties =
WSRPTypeFactory.createSetPortletProperties(registrationContext, portletContext,
propertyList);
setPortletProperties.setUserContext(userContext);
- setPortletProperties.setPropertyList(propertyList);
PortletContext response = producer.setPortletProperties(setPortletProperties);
@@ -322,11 +307,7 @@
public void getPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v2:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types") UserContext userContext, @WebParam(name =
"names", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types")
List<String> names, @WebParam(name = "properties", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<Property>> properties, @WebParam(name =
"resetProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<ResetProperty>> resetProperties, @WebParam(name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types",
mode = WebParam.Mode.OUT) Holder<List<Extension>> extensions) throws
AccessDenied, Inconsisten!
tParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, MissingParameters,
ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
{
- GetPortletProperties getPortletProperties = new GetPortletProperties();
- getPortletProperties.setRegistrationContext(registrationContext);
- getPortletProperties.setPortletContext(portletContext);
- getPortletProperties.setUserContext(userContext);
- getPortletProperties.getNames().addAll(names);
+ GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(registrationContext, portletContext,
userContext, names);
PropertyList result = producer.getPortletProperties(getPortletProperties);
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/RegistrationEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/RegistrationEndpoint.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/RegistrationEndpoint.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -23,6 +23,7 @@
package org.gatein.wsrp.endpoints.v2;
+import org.gatein.wsrp.WSRPTypeFactory;
import org.gatein.wsrp.endpoints.WSRPBaseEndpoint;
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.Extension;
@@ -99,9 +100,7 @@
@WebParam(name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT)
Holder<List<Extension>> extensions)
throws InvalidRegistration, MissingParameters, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- ModifyRegistration modifyRegistration = new ModifyRegistration();
- modifyRegistration.setRegistrationContext(registrationContext);
- modifyRegistration.setRegistrationData(registrationData);
+ ModifyRegistration modifyRegistration =
WSRPTypeFactory.createModifyRegistration(registrationContext, registrationData);
RegistrationState result = producer.modifyRegistration(modifyRegistration);
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -208,7 +208,7 @@
// let's see now if we can increment the counter
V1PerformBlockingInteraction performBlockingInteraction =
-
WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
V1InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
interactionParams.setInteractionState(incrementAction.getInteractionState().getStringValue());
producer.performBlockingInteraction(performBlockingInteraction);
@@ -279,7 +279,7 @@
public void testPerformBlockingInteractionRedirect() throws Exception
{
V1PerformBlockingInteraction performBlockingInteraction =
- WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+ createDefaultPerformBlockingInteraction(getDefaultHandle());
V1InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
// crappy way but this is a test! ;)
@@ -318,7 +318,7 @@
public void testPBIWithSessionID() throws Exception
{
String portletHandle = getDefaultHandle();
- V1PerformBlockingInteraction performBlockingInteraction =
WSRP1TypeFactory.createDefaultPerformBlockingInteraction(portletHandle);
+ V1PerformBlockingInteraction performBlockingInteraction =
createDefaultPerformBlockingInteraction(portletHandle);
V1RuntimeContext runtimeContext = performBlockingInteraction.getRuntimeContext();
//the sessionID should never be set by the consumer. Sessions are handled by
cookies instead
@@ -560,7 +560,7 @@
try
{
V1PerformBlockingInteraction action =
-
WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
List<V1NamedString> formParameters =
action.getInteractionParams().getFormParameters();
formParameters.add(namedString);
V1BlockingInteractionResponse actionResponse =
producer.performBlockingInteraction(action);
@@ -579,13 +579,21 @@
checkMarkupResponse(response, "multi: value1, value2");
formParameters.clear();
- formParameters.add(new V1NamedString());
+ //TODO: use the WSRP1TypeFactory to create the named string
+ formParameters.add(createNamedString("foo", null));
actionResponse = producer.performBlockingInteraction(action);
markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
markupRequest.getMarkupParams().setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
response = producer.getMarkup(markupRequest);
checkMarkupResponse(response, "multi: ");
}
+ catch (Exception e)
+ {
+ //Print error to the server logs since arquillian can't handle non
serialzable errors
+ System.out.println("Failure in TestGetMarkupMultiValuedFromParams");
+ e.printStackTrace();
+ throw new Exception(e);
+ }
finally
{
undeploy(multiValuedPortletArchive);
@@ -608,7 +616,7 @@
ExtendedAssert.assertEquals("initial", markupString);
// modify the preference value
- V1PerformBlockingInteraction pbi =
WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ V1PerformBlockingInteraction pbi =
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
pbi.getInteractionParams().setPortletStateChange(V1StateChange.CLONE_BEFORE_WRITE); //
request cloning if needed
String value = "new value";
pbi.getInteractionParams().getFormParameters().add(createNamedString("value",
value));
@@ -710,7 +718,7 @@
try
{
// set appVar to value in the application scope by the first portlet
- V1PerformBlockingInteraction pbi =
WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getPortletHandleFrom("Set"));
+ V1PerformBlockingInteraction pbi =
createDefaultPerformBlockingInteraction(getPortletHandleFrom("Set"));
pbi.getInteractionParams().getFormParameters().add(createNamedString("appVar",
"value"));
producer.performBlockingInteraction(pbi);
@@ -751,7 +759,7 @@
{
configureRegistrationSettings(true, false);
- V1PerformBlockingInteraction pbi =
WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ V1PerformBlockingInteraction pbi =
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
try
{
producer.performBlockingInteraction(pbi);
@@ -791,7 +799,7 @@
private String checkPBIAndGetNavigationalState(String symbol) throws Exception
{
V1PerformBlockingInteraction performBlockingInteraction =
- WSRP1TypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+ createDefaultPerformBlockingInteraction(getDefaultHandle());
V1InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
interactionParams.getFormParameters().add(createNamedString("symbol",
symbol));
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/NeedPortletHandleTest.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/NeedPortletHandleTest.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/NeedPortletHandleTest.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -206,7 +206,7 @@
*/
protected V1GetMarkup createMarkupRequest(String handle) throws RemoteException,
V1InvalidRegistration, V1OperationFailed
{
- V1GetMarkup getMarkup = WSRP1TypeFactory.createDefaultMarkupRequest(handle);
+ V1GetMarkup getMarkup = createDefaultMarkupRequest(handle);
getMarkup.getMarkupParams().getMarkupCharacterSets().add(WSRPConstants.DEFAULT_CHARACTER_SET);
return getMarkup;
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -188,7 +188,7 @@
producer.deregister(rc);
// try to get markup, portlet handle doesn't matter since it should fail before
trying to retrieve the portlet
- V1GetMarkup getMarkup =
WSRP1TypeFactory.createDefaultMarkupRequest("foo");
+ V1GetMarkup getMarkup = createDefaultMarkupRequest("foo");
getMarkup.getMarkupParams().getMarkupCharacterSets().add(WSRPConstants.DEFAULT_CHARACTER_SET);
try
@@ -236,7 +236,7 @@
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().addRegistrationProperty(regProp);
// try to get markup, portlet handle doesn't matter since it should fail before
trying to retrieve the portlet
- V1GetMarkup getMarkup =
WSRP1TypeFactory.createDefaultMarkupRequest("foo");
+ V1GetMarkup getMarkup = createDefaultMarkupRequest("foo");
getMarkup.getMarkupParams().getMarkupCharacterSets().add(WSRPConstants.DEFAULT_CHARACTER_SET);
getMarkup.setRegistrationContext(rc);
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -36,15 +36,19 @@
import org.gatein.wsrp.registration.RegistrationPropertyDescription;
import org.gatein.wsrp.spec.v1.WSRP1TypeFactory;
import org.gatein.wsrp.test.ExtendedAssert;
+import org.oasis.wsrp.v1.V1GetMarkup;
import org.oasis.wsrp.v1.V1GetServiceDescription;
import org.oasis.wsrp.v1.V1LocalizedString;
import org.oasis.wsrp.v1.V1MarkupType;
import org.oasis.wsrp.v1.V1MissingParameters;
import org.oasis.wsrp.v1.V1OperationFailed;
+import org.oasis.wsrp.v1.V1PerformBlockingInteraction;
+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.V1RegistrationData;
+import org.oasis.wsrp.v1.V1RuntimeContext;
import org.oasis.wsrp.v1.V1ServiceDescription;
import javax.xml.namespace.QName;
@@ -265,4 +269,23 @@
// ExtendedAssert.assertTrue(cause instanceof SOAPFaultException);
// ExtendedAssert.assertEquals(errorCode,
((SOAPFaultException)cause).getFault().getLocalPart());
}
+
+
+ protected V1GetMarkup createDefaultMarkupRequest(String handle)
+ {
+ V1PortletContext portletContext = WSRP1TypeFactory.createPortletContext(handle);
+ return WSRP1TypeFactory.createMarkupRequest(portletContext,
createDefaultRuntimeContext(), WSRP1TypeFactory.createDefaultMarkupParams());
+ }
+
+ protected V1PerformBlockingInteraction createDefaultPerformBlockingInteraction(String
handle)
+ {
+ V1PortletContext portletContext = WSRP1TypeFactory.createPortletContext(handle);
+ return WSRP1TypeFactory.createPerformBlockingInteraction(portletContext,
createDefaultRuntimeContext(), WSRP1TypeFactory.createDefaultMarkupParams(),
+ WSRP1TypeFactory.createDefaultInteractionParams());
+ }
+
+ protected V1RuntimeContext createDefaultRuntimeContext()
+ {
+ return
WSRP1TypeFactory.createRuntimeContext(WSRPConstants.NONE_USER_AUTHENTICATION,
"foo", "bar");
+ }
}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -152,8 +152,7 @@
{
// The consumer should never have access to or be able to set a sessionID. Sessions
are handled by the Producer using cookies.
GetMarkup getMarkup = createMarkupRequest();
- SessionParams sessionParams = new SessionParams();
- sessionParams.setSessionID("Hello World");
+ SessionParams sessionParams = WSRPTypeFactory.createSessionParams("Hello
World");
getMarkup.getRuntimeContext().setSessionParams(sessionParams);
try
@@ -204,8 +203,7 @@
WSRPRenderURL julienRender = (WSRPRenderURL)julienURL;
// We're now trying to get a hello for Julien ;)
- NavigationalContext navigationalContext = new NavigationalContext();
-
navigationalContext.setOpaqueValue(julienRender.getNavigationalState().getStringValue());
+ NavigationalContext navigationalContext =
WSRPTypeFactory.createNavigationalContext(julienRender.getNavigationalState().getStringValue(),
null);
gm.getMarkupParams().setNavigationalContext(navigationalContext);
res = producer.getMarkup(gm);
markupString = res.getMarkupContext().getItemString();
@@ -217,8 +215,7 @@
WSRPActionURL incrementAction = (WSRPActionURL)incrementURL;
// let's see now if we can increment the counter
- PerformBlockingInteraction performBlockingInteraction =
-
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ PerformBlockingInteraction performBlockingInteraction =
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
interactionParams.setInteractionState(incrementAction.getInteractionState().getStringValue());
producer.performBlockingInteraction(performBlockingInteraction);
@@ -288,14 +285,11 @@
@Test
public void testPerformBlockingInteractionRedirect() throws Exception
{
- PerformBlockingInteraction performBlockingInteraction =
- WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+ PerformBlockingInteraction performBlockingInteraction =
createDefaultPerformBlockingInteraction(getDefaultHandle());
InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
// crappy way but this is a test! ;)
- NamedString namedString = new NamedString();
- namedString.setName("symbol");
- namedString.setValue("HELP");
+ NamedString namedString = WSRPTypeFactory.createNamedString("symbol",
"HELP");
interactionParams.getFormParameters().add(namedString);
BlockingInteractionResponse response =
producer.performBlockingInteraction(performBlockingInteraction);
@@ -329,12 +323,11 @@
public void testPBIWithSessionID() throws Exception
{
String portletHandle = getDefaultHandle();
- PerformBlockingInteraction performBlockingInteraction =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(portletHandle);
+ PerformBlockingInteraction performBlockingInteraction =
createDefaultPerformBlockingInteraction(portletHandle);
RuntimeContext runtimeContext = performBlockingInteraction.getRuntimeContext();
//the sessionID should never be set by the consumer. Sessions are handled by
cookies instead
- SessionParams sessionParams = new SessionParams();
- sessionParams.setSessionID("Hello World");
+ SessionParams sessionParams = WSRPTypeFactory.createSessionParams("Hello
World");
runtimeContext.setSessionParams(sessionParams);
try
@@ -572,8 +565,7 @@
NamedString namedString = createNamedString("multi",
"value1");
try
{
- PerformBlockingInteraction action =
-
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ PerformBlockingInteraction action =
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
List<NamedString> formParameters =
action.getInteractionParams().getFormParameters();
formParameters.add(namedString);
BlockingInteractionResponse actionResponse =
producer.performBlockingInteraction(action);
@@ -592,7 +584,7 @@
checkMarkupResponse(response, "multi: value1, value2");
formParameters.clear();
- formParameters.add(new NamedString());
+ formParameters.add(WSRPTypeFactory.createNamedString("test", null));
actionResponse = producer.performBlockingInteraction(action);
markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
markupRequest.getMarkupParams().setNavigationalContext(actionResponse.getUpdateResponse().getNavigationalContext());
@@ -621,7 +613,7 @@
ExtendedAssert.assertEquals("initial", markupString);
// modify the preference value
- PerformBlockingInteraction pbi =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ PerformBlockingInteraction pbi =
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
pbi.getInteractionParams().setPortletStateChange(StateChange.CLONE_BEFORE_WRITE); //
request cloning if needed
String value = "new value";
pbi.getInteractionParams().getFormParameters().add(createNamedString("value",
value));
@@ -651,9 +643,7 @@
private NamedString createNamedString(String name, String value)
{
- NamedString namedString = new NamedString();
- namedString.setName(name);
- namedString.setValue(value);
+ NamedString namedString = WSRPTypeFactory.createNamedString(name, value);
return namedString;
}
@@ -723,7 +713,7 @@
try
{
// set appVar to value in the application scope by the first portlet
- PerformBlockingInteraction pbi =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getPortletHandleFrom("Set"));
+ PerformBlockingInteraction pbi =
createDefaultPerformBlockingInteraction(getPortletHandleFrom("Set"));
pbi.getInteractionParams().getFormParameters().add(createNamedString("appVar",
"value"));
producer.performBlockingInteraction(pbi);
@@ -821,7 +811,7 @@
consumerHandle = portletHandle;
}
}
- PerformBlockingInteraction action =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(generatorHandle);
+ PerformBlockingInteraction action =
createDefaultPerformBlockingInteraction(generatorHandle);
List<NamedString> formParameters =
action.getInteractionParams().getFormParameters();
formParameters.add(namedString);
BlockingInteractionResponse actionResponse =
producer.performBlockingInteraction(action);
@@ -837,8 +827,8 @@
// send event
HandleEvents handleEvents = WSRPTypeFactory.createHandleEvents(null,
- WSRPTypeFactory.createPortletContext(consumerHandle),
WSRPTypeFactory.createDefaultRuntimeContext(), null,
- WSRPTypeFactory.createDefaultMarkupParams(),
WSRPTypeFactory.createEventParams(events, StateChange.READ_ONLY));
+ WSRPTypeFactory.createPortletContext(consumerHandle),
createDefaultRuntimeContext(consumerHandle), null,
+ createDefaultMarkupParams(), WSRPTypeFactory.createEventParams(events,
StateChange.READ_ONLY));
HandleEventsResponse handleEventsResponse =
producer.handleEvents(handleEvents);
// no failed events
@@ -880,7 +870,7 @@
consumerHandle = portletHandle;
}
}
- PerformBlockingInteraction action =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(generatorHandle);
+ PerformBlockingInteraction action =
createDefaultPerformBlockingInteraction(generatorHandle);
List<NamedString> formParameters =
action.getInteractionParams().getFormParameters();
formParameters.add(namedString);
BlockingInteractionResponse actionResponse =
producer.performBlockingInteraction(action);
@@ -971,7 +961,7 @@
{
configureRegistrationSettings(true, false);
- PerformBlockingInteraction pbi =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ PerformBlockingInteraction pbi =
createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
try
{
producer.performBlockingInteraction(pbi);
@@ -1010,8 +1000,7 @@
private String checkPBIAndGetNavigationalState(String symbol) throws Exception
{
- PerformBlockingInteraction performBlockingInteraction =
- WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+ PerformBlockingInteraction performBlockingInteraction =
createDefaultPerformBlockingInteraction(getDefaultHandle());
InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
interactionParams.getFormParameters().add(createNamedString("symbol",
symbol));
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/NeedPortletHandleTest.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/NeedPortletHandleTest.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/NeedPortletHandleTest.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -26,11 +26,17 @@
import org.gatein.wsrp.WSRPTypeFactory;
import org.oasis.wsrp.v2.GetMarkup;
import org.oasis.wsrp.v2.GetServiceDescription;
+import org.oasis.wsrp.v2.InteractionParams;
import org.oasis.wsrp.v2.InvalidRegistration;
+import org.oasis.wsrp.v2.MarkupParams;
import org.oasis.wsrp.v2.MarkupResponse;
import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.PerformBlockingInteraction;
+import org.oasis.wsrp.v2.PortletContext;
import org.oasis.wsrp.v2.PortletDescription;
+import org.oasis.wsrp.v2.RuntimeContext;
import org.oasis.wsrp.v2.ServiceDescription;
+import org.oasis.wsrp.v2.StateChange;
import java.rmi.RemoteException;
import java.util.ArrayList;
@@ -202,12 +208,45 @@
*/
protected GetMarkup createMarkupRequest(String handle) throws RemoteException,
InvalidRegistration, OperationFailed
{
- GetMarkup getMarkup = WSRPTypeFactory.createDefaultGetMarkup(handle);
+ GetMarkup getMarkup = createDefaultGetMarkup(handle);
getMarkup.getMarkupParams().getMarkupCharacterSets().add(WSRPConstants.DEFAULT_CHARACTER_SET);
return getMarkup;
}
+
+ protected GetMarkup createDefaultGetMarkup(String handle)
+ {
+ PortletContext portletContext = WSRPTypeFactory.createPortletContext(handle);
+ RuntimeContext runtimeContext = createDefaultRuntimeContext(handle);
+ MarkupParams runtimeParams = createDefaultMarkupParams();
+ return WSRPTypeFactory.createGetMarkup(null, portletContext, runtimeContext, null,
createDefaultMarkupParams());
+ }
+
+ protected PerformBlockingInteraction createDefaultPerformBlockingInteraction(String
handle)
+ {
+ PortletContext portletContext = WSRPTypeFactory.createPortletContext(handle);
+ return WSRPTypeFactory.createPerformBlockingInteraction(null, portletContext,
createDefaultRuntimeContext(handle), null, createDefaultMarkupParams(),
+ createDefaultInteractionParams());
+ }
+
+ protected InteractionParams createDefaultInteractionParams()
+ {
+ return WSRPTypeFactory.createInteractionParams(StateChange.READ_ONLY);
+ }
+
+ protected RuntimeContext createDefaultRuntimeContext(String handle)
+ {
+ String portletInstanceKey = "foo";
+ String namespacePrefix = handle;
+ return WSRPTypeFactory.createRuntimeContext(WSRPConstants.NONE_USER_AUTHENTICATION,
portletInstanceKey, namespacePrefix);
+ }
+ protected MarkupParams createDefaultMarkupParams()
+ {
+ return WSRPTypeFactory.createMarkupParams(false, WSRPConstants.getDefaultLocales(),
WSRPConstants.getDefaultMimeTypes(),
+ WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE);
+ }
+
protected String getPortletHandleFrom(String partialHandle)
{
List<String> handles = getHandlesForCurrentlyDeployedArchive();
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2010-09-03
12:31:59 UTC (rev 4041)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2010-09-03
21:19:40 UTC (rev 4042)
@@ -203,21 +203,31 @@
@Test
public void testExportRegistrationRequired() throws Exception
{
-
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
+ try
+ {
+
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
- RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData("CONSUMER", true);
- RegistrationContext registrationContext = producer.register(registrationData);
+ RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData("CONSUMER",
"CONSUMERAGENT.0.0", true);
+ RegistrationContext registrationContext = producer.register(registrationData);
- List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
+ List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
- boolean exportByValueRequired = true;
- Lifetime lifetime = null;
- UserContext userContext = null;
- ExportPortlets exportPortlets =
WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts, userContext,
lifetime, exportByValueRequired);
+ boolean exportByValueRequired = true;
+ Lifetime lifetime = null;
+ UserContext userContext = null;
+ ExportPortlets exportPortlets =
WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts, userContext,
lifetime, exportByValueRequired);
- ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
+ ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
- checkValidHandle(response, getDefaultHandle());
+ checkValidHandle(response, getDefaultHandle());
+ }
+ catch (Exception e)
+ {
+ //arquillian can't handle non serializable exceptions, print error message
to the server logs
+ System.out.println("An exception occured calling " + this.getClass() +
" testExportRegistrationRequired");
+ e.printStackTrace();
+ throw new Exception (e);
+ }
}
@Test
@@ -381,40 +391,50 @@
@Test
public void testImportRegistrationRequired() throws Exception
{
-
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
- RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData("CONSUMER", true);
- RegistrationContext registrationContext = producer.register(registrationData);
+ try
+ {
+
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
+ RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData("CONSUMER",
"CONSUMERAGENT.0.0", true);
+ RegistrationContext registrationContext = producer.register(registrationData);
- String importID = "foo";
+ String importID = "foo";
- Lifetime lifetime = null;
- UserContext userContext = null;
+ Lifetime lifetime = null;
+ UserContext userContext = null;
- List<String> portletList = new ArrayList<String>();
- portletList.add(getDefaultHandle());
- ExportContext exportContextData = new ExportContext();
- byte[] importContext = exportContextData.encodeAsBytes();
+ List<String> portletList = new ArrayList<String>();
+ portletList.add(getDefaultHandle());
+ ExportContext exportContextData = new ExportContext();
+ byte[] importContext = exportContextData.encodeAsBytes();
- ImportPortlet importPortlet = createSimpleImportPortlet(importID,
getDefaultHandle());
- List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
+ ImportPortlet importPortlet = createSimpleImportPortlet(importID,
getDefaultHandle());
+ List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
- ImportPortlets importPortlets =
WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
- ImportPortletsResponse response = producer.importPortlets(importPortlets);
+ ImportPortlets importPortlets =
WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
+ ImportPortletsResponse response = producer.importPortlets(importPortlets);
- assertEquals(1, response.getImportedPortlets().size());
- ImportedPortlet portlet = response.getImportedPortlets().get(0);
+ assertEquals(1, response.getImportedPortlets().size());
+ ImportedPortlet portlet = response.getImportedPortlets().get(0);
- assertEquals(importID, portlet.getImportID());
+ assertEquals(importID, portlet.getImportID());
- PortletContext portletContext = portlet.getNewPortletContext();
+ PortletContext portletContext = portlet.getNewPortletContext();
- //check that the new portlet handle is valid and we can access the portlet
- GetMarkup markup = createMarkupRequest(portletContext.getPortletHandle());
- markup.setRegistrationContext(registrationContext);
+ //check that the new portlet handle is valid and we can access the portlet
+ GetMarkup markup = createMarkupRequest(portletContext.getPortletHandle());
+ markup.setRegistrationContext(registrationContext);
- MarkupResponse markupResponse = producer.getMarkup(markup);
- assertNotNull(markupResponse.getMarkupContext());
- assertEquals("<p>symbol unset stock value: value unset</p>",
new String(markupResponse.getMarkupContext().getItemString()));
+ MarkupResponse markupResponse = producer.getMarkup(markup);
+ assertNotNull(markupResponse.getMarkupContext());
+ assertEquals("<p>symbol unset stock value: value
unset</p>", new String(markupResponse.getMarkupContext().getItemString()));
+ }
+ catch (Exception e)
+ {
+ //arquillian can't handle non serializable exceptions, print error message
to the server logs
+ System.out.println("An exception occured calling " + this.getClass() +
" testImportRegistrationRequired");
+ e.printStackTrace();
+ throw new Exception (e);
+ }
}
@Test
@@ -959,7 +979,7 @@
protected PortletContext performBlockingInteractionOnSessionPortlet(String handle,
String value, StateChange stateChange) throws Exception
{
//perform a blocking interaction to set a state on the portlet;
- PerformBlockingInteraction pbi =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(handle);
+ PerformBlockingInteraction pbi = createDefaultPerformBlockingInteraction(handle);
pbi.getInteractionParams().setPortletStateChange(stateChange);
NamedString namedString = WSRPTypeFactory.createNamedString("value",
value);
pbi.getInteractionParams().getFormParameters().add(namedString);