From do-not-reply at jboss.org Thu Jun 10 04:41:10 2010 Content-Type: multipart/mixed; boundary="===============6744000497341355643==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: gatein-commits at lists.jboss.org Subject: [gatein-commits] gatein SVN: r3293 - in components/wsrp/trunk: common/src/main/java/org/gatein/wsrp/spec/v1 and 3 other directories. Date: Thu, 10 Jun 2010 04:41:10 -0400 Message-ID: <201006100841.o5A8fAXm001043@svn01.web.mwc.hst.phx2.redhat.com> --===============6744000497341355643== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: chris.laprun(a)jboss.com Date: 2010-06-10 04:41:09 -0400 (Thu, 10 Jun 2010) New Revision: 3293 Added: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV= 2Converter.java components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV= 1Converter.java Removed: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1C= onverter.java Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP1= TypeFactory.java components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1C= onverterTestCase.java components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1= /V1MarkupService.java components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1= /V1ServiceDescriptionService.java components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/en= dpoints/v1/MarkupEndpoint.java components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/en= dpoints/v1/ServiceDescriptionEndpoint.java Log: - Split V2V1Converter into 2 classes one for V2 to V1 and another for V1 to= V2. - Renamed constants so that they're shorter and less redundant now that the= V2V1Converter has been split. - Moved transform method to WSRPUtils. Should consider moving it to common,= maybe re-implementing that portion of Google collections to avoid dependen= cy. Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUt= ils.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.ja= va 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.ja= va 2010-06-10 08:41:09 UTC (rev 3293) @@ -23,6 +23,8 @@ = package org.gatein.wsrp; = +import com.google.common.base.Function; +import com.google.common.collect.Lists; import org.gatein.common.i18n.LocaleFormat; import org.gatein.common.net.URLTools; import org.gatein.common.util.ConversionException; @@ -501,6 +503,27 @@ } = /** + * Todo: Should be moved to common module? + * + * @param fromList + * @param function + * @param + * @param + * @return + */ + public static List transform(List fromList, Function function) + { + if (fromList =3D=3D null) + { + return null; + } + else + { + return Lists.transform(fromList, function); + } + } + + /** * @author Chris Laprun * @version $Revision$ */ Added: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V= 1ToV2Converter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1To= V2Converter.java (rev 0) +++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1To= V2Converter.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -0,0 +1,876 @@ +/* + * JBoss, a division of Red Hat + * Copyright 2010, Red Hat Middleware, LLC, and individual + * contributors as indicated by the @authors tag. See the + * copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.gatein.wsrp.spec.v1; + +import com.google.common.base.Function; +import com.google.common.collect.Lists; +import org.gatein.common.NotYetImplemented; +import org.gatein.pc.api.OpaqueStateString; +import org.gatein.wsrp.WSRPExceptionFactory; +import org.gatein.wsrp.WSRPTypeFactory; +import org.gatein.wsrp.WSRPUtils; +import org.oasis.wsrp.v1.V1ClientData; +import org.oasis.wsrp.v1.V1Contact; +import org.oasis.wsrp.v1.V1CookieProtocol; +import org.oasis.wsrp.v1.V1EmployerInfo; +import org.oasis.wsrp.v1.V1Extension; +import org.oasis.wsrp.v1.V1InteractionParams; +import org.oasis.wsrp.v1.V1ItemDescription; +import org.oasis.wsrp.v1.V1LocalizedString; +import org.oasis.wsrp.v1.V1MarkupParams; +import org.oasis.wsrp.v1.V1MarkupType; +import org.oasis.wsrp.v1.V1ModelDescription; +import org.oasis.wsrp.v1.V1ModelTypes; +import org.oasis.wsrp.v1.V1NamedString; +import org.oasis.wsrp.v1.V1Online; +import org.oasis.wsrp.v1.V1PersonName; +import org.oasis.wsrp.v1.V1PortletContext; +import org.oasis.wsrp.v1.V1PortletDescription; +import org.oasis.wsrp.v1.V1Postal; +import org.oasis.wsrp.v1.V1PropertyDescription; +import org.oasis.wsrp.v1.V1RegistrationContext; +import org.oasis.wsrp.v1.V1Resource; +import org.oasis.wsrp.v1.V1ResourceList; +import org.oasis.wsrp.v1.V1ResourceValue; +import org.oasis.wsrp.v1.V1RuntimeContext; +import org.oasis.wsrp.v1.V1ServiceDescription; +import org.oasis.wsrp.v1.V1StateChange; +import org.oasis.wsrp.v1.V1Telecom; +import org.oasis.wsrp.v1.V1TelephoneNum; +import org.oasis.wsrp.v1.V1Templates; +import org.oasis.wsrp.v1.V1UploadContext; +import org.oasis.wsrp.v1.V1UserContext; +import org.oasis.wsrp.v1.V1UserProfile; +import org.oasis.wsrp.v2.ClientData; +import org.oasis.wsrp.v2.Contact; +import org.oasis.wsrp.v2.CookieProtocol; +import org.oasis.wsrp.v2.EmployerInfo; +import org.oasis.wsrp.v2.Extension; +import org.oasis.wsrp.v2.InteractionParams; +import org.oasis.wsrp.v2.ItemDescription; +import org.oasis.wsrp.v2.LocalizedString; +import org.oasis.wsrp.v2.MarkupParams; +import org.oasis.wsrp.v2.MarkupType; +import org.oasis.wsrp.v2.ModelDescription; +import org.oasis.wsrp.v2.ModelTypes; +import org.oasis.wsrp.v2.NamedString; +import org.oasis.wsrp.v2.Online; +import org.oasis.wsrp.v2.PersonName; +import org.oasis.wsrp.v2.PortletContext; +import org.oasis.wsrp.v2.PortletDescription; +import org.oasis.wsrp.v2.Postal; +import org.oasis.wsrp.v2.PropertyDescription; +import org.oasis.wsrp.v2.RegistrationContext; +import org.oasis.wsrp.v2.Resource; +import org.oasis.wsrp.v2.ResourceList; +import org.oasis.wsrp.v2.ResourceValue; +import org.oasis.wsrp.v2.RuntimeContext; +import org.oasis.wsrp.v2.ServiceDescription; +import org.oasis.wsrp.v2.SessionParams; +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.UploadContext; +import org.oasis.wsrp.v2.UserContext; +import org.oasis.wsrp.v2.UserProfile; + +import java.util.List; + +/** + * @author Chris Laprun + * @version $Revision$ + */ +public class V1ToV2Converter +{ + public static final V1ToV2Extension EXTENSION =3D new V1ToV2Extension(); + public static final V1ToV2MarkupType MARKUPTYPE =3D new V1ToV2MarkupTyp= e(); + public static final V1ToV2PortletDescription PORTLETDESCRIPTION =3D new= V1ToV2PortletDescription(); + public static final V1ToV2LocalizedString LOCALIZEDSTRING =3D new V1ToV= 2LocalizedString(); + public static final V1ToV2ItemDescription ITEMDESCRIPTION =3D new V1ToV= 2ItemDescription(); + public static final V1ToV2PropertyDescription PROPERTYDESCRIPTION =3D n= ew V1ToV2PropertyDescription(); + public static final V1ToV2Resource RESOURCE =3D new V1ToV2Resource(); + public static final V1ToV2ResourceValue RESOURCEVALUE =3D new V1ToV2Res= ourceValue(); + public static final V1ToV2NamedString NAMEDSTRING =3D new V1ToV2NamedSt= ring(); + public static final V1ToV2UploadContext UPLOADCONTEXT =3D new V1ToV2Upl= oadContext(); + + public static MarkupParams toV2MarkupParams(V1MarkupParams v1MarkupPara= ms) + { + if (v1MarkupParams !=3D null) + { + MarkupParams markupParams =3D WSRPTypeFactory.createMarkupParams(= v1MarkupParams.isSecureClientCommunication(), + v1MarkupParams.getLocales(), v1MarkupParams.getMimeTypes(), v1= MarkupParams.getMode(), + v1MarkupParams.getWindowState()); + markupParams.setClientData(toV2ClientData(v1MarkupParams.getClien= tData())); + + // we can't create an opaquestatestring if with a null string, so= need to check + if (v1MarkupParams.getNavigationalState() !=3D null) + { + markupParams.setNavigationalContext(WSRPTypeFactory.createNavi= gationalContextOrNull( + new OpaqueStateString(v1MarkupParams.getNavigationalState()= ), null)); + } + markupParams.setValidateTag(v1MarkupParams.getValidateTag()); + + List charSets =3D v1MarkupParams.getMarkupCharacterSets(); + if (charSets !=3D null) + { + markupParams.getMarkupCharacterSets().addAll(charSets); + } + List validNewModes =3D v1MarkupParams.getValidNewModes(); + if (validNewModes !=3D null) + { + markupParams.getValidNewModes().addAll(validNewModes); + } + List validNewWindowStates =3D v1MarkupParams.getValidNewW= indowStates(); + if (validNewWindowStates !=3D null) + { + markupParams.getValidNewWindowStates().addAll(validNewWindowSt= ates); + } + + List extensions =3D WSRPUtils.transform(v1MarkupParams= .getExtensions(), EXTENSION); + if (extensions !=3D null) + { + markupParams.getExtensions().addAll(extensions); + } + return markupParams; + } + else + { + return null; + } + } + + public static ClientData toV2ClientData(V1ClientData v1ClientData) + { + if (v1ClientData !=3D null) + { + ClientData clientData =3D WSRPTypeFactory.createClientData(v1Clie= ntData.getUserAgent()); + + List extensions =3D v1ClientData.getExtensions(); + if (extensions !=3D null) + { + clientData.getExtensions().addAll(Lists.transform(extensions, = EXTENSION)); + } + + return clientData; + } + else + { + return null; + } + } + + public static PortletContext toV2PortletContext(V1PortletContext v1Port= letContext) + { + if (v1PortletContext !=3D null) + { + PortletContext portletContext =3D WSRPTypeFactory.createPortletCo= ntext(v1PortletContext.getPortletHandle(), v1PortletContext.getPortletState= ()); + + List extensions =3D v1PortletContext.getExtensions(); + if (extensions !=3D null) + { + portletContext.getExtensions().addAll(WSRPUtils.transform(exte= nsions, EXTENSION)); + } + + return portletContext; + } + else + { + return null; + } + } + + public static RegistrationContext toV2RegistrationContext(V1Registratio= nContext registrationContext) + { + if (registrationContext !=3D null) + { + RegistrationContext result =3D WSRPTypeFactory.createRegistration= Context(registrationContext.getRegistrationHandle()); + result.setRegistrationState(registrationContext.getRegistrationSt= ate()); + List extensions =3D WSRPUtils.transform(registrationCo= ntext.getExtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + + public static RuntimeContext toV2RuntimeContext(V1RuntimeContext v1Runt= imeContext) + { + if (v1RuntimeContext !=3D null) + { + RuntimeContext runtimeContext =3D WSRPTypeFactory.createRuntimeCo= ntext(v1RuntimeContext.getUserAuthentication()); + runtimeContext.setNamespacePrefix(v1RuntimeContext.getNamespacePr= efix()); + runtimeContext.setPortletInstanceKey(v1RuntimeContext.getPortletI= nstanceKey()); + + //TODO: handle the SessionParams better + SessionParams sessionParams =3D new SessionParams(); + sessionParams.setSessionID(v1RuntimeContext.getSessionID()); + + runtimeContext.setSessionParams(sessionParams); + runtimeContext.setTemplates(toV2Templates(v1RuntimeContext.getTem= plates())); + + List extensions =3D v1RuntimeContext.getExtensions(); + if (extensions !=3D null) + { + runtimeContext.getExtensions().addAll(WSRPUtils.transform(exte= nsions, EXTENSION)); + } + + return runtimeContext; + } + else + { + return null; + } + } + + public static Templates toV2Templates(V1Templates v1Templates) + { + if (v1Templates !=3D null) + { + //TODO: should we be using the WSRP1TypeFactory,createTemplates(P= ortletInvocationContext) instead? + Templates templates =3D new Templates(); + templates.setBlockingActionTemplate(v1Templates.getBlockingAction= Template()); + templates.setDefaultTemplate(v1Templates.getDefaultTemplate()); + templates.setRenderTemplate(v1Templates.getRenderTemplate()); + templates.setResourceTemplate(v1Templates.getResourceTemplate()); + templates.setSecureBlockingActionTemplate(v1Templates.getSecureBl= ockingActionTemplate()); + templates.setSecureRenderTemplate(v1Templates.getSecureRenderTemp= late()); + templates.setSecureResourceTemplate(v1Templates.getSecureResource= Template()); + + List extensions =3D v1Templates.getExtensions(); + if (extensions !=3D null) + { + templates.getExtensions().addAll(WSRPUtils.transform(extension= s, EXTENSION)); + } + + return templates; + } + else + { + return null; + } + } + + public static UserContext toV2UserContext(V1UserContext v1UserContext) + { + if (v1UserContext !=3D null) + { + UserContext userContext =3D WSRPTypeFactory.createUserContext(v1U= serContext.getUserContextKey()); + userContext.setProfile(toV2UserProfile(v1UserContext.getProfile()= )); + + List extensions =3D v1UserContext.getExtensions(); + if (extensions !=3D null) + { + userContext.getExtensions().addAll(WSRPUtils.transform(extensi= ons, EXTENSION)); + } + + if (v1UserContext.getUserCategories() !=3D null) + { + userContext.getUserCategories().addAll(v1UserContext.getUserCa= tegories()); + } + + return userContext; + } + else + { + return null; + } + } + + public static UserProfile toV2UserProfile(V1UserProfile v1UserProfile) + { + if (v1UserProfile !=3D null) + { + UserProfile userProfile =3D new UserProfile(); + userProfile.setBdate(v1UserProfile.getBdate()); + userProfile.setBusinessInfo(toV2Context(v1UserProfile.getBusiness= Info())); + userProfile.setEmployerInfo(toV2EmployerInfo(v1UserProfile.getEmp= loyerInfo())); + userProfile.setGender(v1UserProfile.getGender()); + userProfile.setHomeInfo(toV2Context(v1UserProfile.getHomeInfo())); + userProfile.setName(toV2PersonName(v1UserProfile.getName())); + + return userProfile; + } + else + { + return null; + } + } + + public static EmployerInfo toV2EmployerInfo(V1EmployerInfo v1EmployerIn= fo) + { + if (v1EmployerInfo !=3D null) + { + EmployerInfo employerInfo =3D new EmployerInfo(); + employerInfo.setDepartment(v1EmployerInfo.getDepartment()); + employerInfo.setEmployer(v1EmployerInfo.getEmployer()); + employerInfo.setJobtitle(v1EmployerInfo.getJobtitle()); + + List extensions =3D v1EmployerInfo.getExtensions(); + if (extensions !=3D null) + { + employerInfo.getExtensions().addAll(WSRPUtils.transform(extens= ions, EXTENSION)); + } + + return employerInfo; + } + else + { + return null; + } + } + + public static PersonName toV2PersonName(V1PersonName v1PersonName) + { + if (v1PersonName !=3D null) + { + PersonName personName =3D 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()); + + List extensions =3D v1PersonName.getExtensions(); + if (extensions !=3D null) + { + personName.getExtensions().addAll(WSRPUtils.transform(extensio= ns, EXTENSION)); + } + + return personName; + } + else + { + return null; + } + } + + public static Contact toV2Context(V1Contact v1Contact) + { + if (v1Contact !=3D null) + { + Contact contact =3D new Contact(); + contact.setOnline(toV2Online(v1Contact.getOnline())); + contact.setPostal(toV2Postal(v1Contact.getPostal())); + contact.setTelecom(toV2Telecom(v1Contact.getTelecom())); + + List extensions =3D v1Contact.getExtensions(); + if (extensions !=3D null) + { + contact.getExtensions().addAll(WSRPUtils.transform(extensions,= EXTENSION)); + } + + return contact; + } + else + { + return null; + } + } + + public static Online toV2Online(V1Online v1Online) + { + if (v1Online !=3D null) + { + Online online =3D new Online(); + online.setEmail(v1Online.getEmail()); + online.setUri(v1Online.getUri()); + + List extensions =3D v1Online.getExtensions(); + if (extensions !=3D null) + { + online.getExtensions().addAll(WSRPUtils.transform(extensions, = EXTENSION)); + } + + return online; + } + else + { + return null; + } + } + + public static Postal toV2Postal(V1Postal v1Postal) + { + if (v1Postal !=3D null) + { + Postal postal =3D 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()); + + List extensions =3D v1Postal.getExtensions(); + if (extensions !=3D null) + { + postal.getExtensions().addAll(WSRPUtils.transform(extensions, = EXTENSION)); + } + + return postal; + } + else + { + return null; + } + } + + public static Telecom toV2Telecom(V1Telecom v1Telecom) + { + if (v1Telecom !=3D null) + { + Telecom telecom =3D new Telecom(); + telecom.setFax(toV2TelephoneNum(v1Telecom.getFax())); + telecom.setMobile(toV2TelephoneNum(v1Telecom.getMobile())); + telecom.setPager(toV2TelephoneNum(v1Telecom.getPager())); + telecom.setTelephone(toV2TelephoneNum(v1Telecom.getTelephone())); + + List extensions =3D v1Telecom.getExtensions(); + if (extensions !=3D null) + { + telecom.getExtensions().addAll(WSRPUtils.transform(extensions,= EXTENSION)); + } + + return telecom; + } + else + { + return null; + } + } + + public static TelephoneNum toV2TelephoneNum(V1TelephoneNum v1TelephoneN= um) + { + if (v1TelephoneNum !=3D null) + { + TelephoneNum telephoneNum =3D new TelephoneNum(); + telephoneNum.setComment(v1TelephoneNum.getComment()); + telephoneNum.setExt(v1TelephoneNum.getExt()); + telephoneNum.setIntcode(v1TelephoneNum.getIntcode()); + telephoneNum.setLoccode(v1TelephoneNum.getLoccode()); + telephoneNum.setNumber(v1TelephoneNum.getNumber()); + + List extensions =3D v1TelephoneNum.getExtensions(); + if (extensions !=3D null) + { + telephoneNum.getExtensions().addAll(WSRPUtils.transform(extens= ions, EXTENSION)); + } + + return telephoneNum; + } + else + { + return null; + } + } + + public static ServiceDescription toV2ServiceDescription(V1ServiceDescri= ption v1ServiceDescription) + { + throw new NotYetImplemented(); + } + + public static E toV2Exception(Class v2Exceptio= nClass, Exception v1Exception) + { + if (!"org.oasis.wsrp.v2".equals(v2ExceptionClass.getPackage().getNam= e())) + { + throw new IllegalArgumentException("Specified exception class is = not a WSRP 2 exception: " + v2ExceptionClass); + } + + Class v1ExceptionClass =3D v1Exception.getClass= (); + String v1Name =3D v1ExceptionClass.getSimpleName(); + int v1Index =3D v1Name.indexOf("V1"); + if (v1Index !=3D 0 && !"org.oasis.wsrp.v1".equals(v1ExceptionClass.g= etPackage().getName())) + { + throw new IllegalArgumentException("Specified exception is not a = WSRP 1 exception: " + v1Exception); + } + + String v2Name =3D v2ExceptionClass.getSimpleName(); + // V2 class name should match V1 class name minus "V1" + if (!v2Name.equals(v1Name.substring(2))) + { + throw new IllegalArgumentException("Exception names do not match.= Requested: " + v2Name + + ", was given: " + v1Name); + } + + return WSRPExceptionFactory.createWSException(v2ExceptionClass, v1Ex= ception.getMessage(), v1Exception.getCause()); + } + + public static InteractionParams toV2InteractionParams(V1InteractionPara= ms v1InteractionParams) + { + if (v1InteractionParams !=3D null) + { + InteractionParams interactionParams =3D WSRPTypeFactory.createInt= eractionParams(toV2StateChange(v1InteractionParams.getPortletStateChange())= ); + interactionParams.setInteractionState(v1InteractionParams.getInte= ractionState()); + interactionParams.getExtensions().addAll(Lists.transform(v1Intera= ctionParams.getExtensions(), EXTENSION)); + interactionParams.getFormParameters().addAll(Lists.transform(v1In= teractionParams.getFormParameters(), NAMEDSTRING)); + interactionParams.getUploadContexts().addAll(Lists.transform(v1In= teractionParams.getUploadContexts(), UPLOADCONTEXT)); + + return interactionParams; + } + else + { + return null; + } + } + + public static StateChange toV2StateChange(V1StateChange v1StateChange) + { + if (v1StateChange !=3D null) + { + return StateChange.valueOf((v1StateChange.value())); + } + else + { + return null; + } + } + + public static LocalizedString toV2LocalizedString(V1LocalizedString loc= alizedString) + { + return LOCALIZEDSTRING.apply(localizedString); + } + + public static CookieProtocol toV2CookieProtocol(V1CookieProtocol v1Cook= ieProtocol) + { + if (v1CookieProtocol !=3D null) + { + return CookieProtocol.fromValue(v1CookieProtocol.value()); + } + else + { + return null; + } + } + + public static ModelDescription toV2ModelDescription(V1ModelDescription = v1ModelDescription) + { + if (v1ModelDescription !=3D null) + { + ModelDescription result =3D WSRPTypeFactory.createModelDescriptio= n(WSRPUtils.transform(v1ModelDescription.getPropertyDescriptions(), PROPERT= YDESCRIPTION)); + List extensions =3D WSRPUtils.transform(v1ModelDescrip= tion.getExtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + result.setModelTypes(toV2ModelTypes(v1ModelDescription.getModelTy= pes())); + + return result; + } + else + { + return null; + } + } + + public static ModelTypes toV2ModelTypes(V1ModelTypes modelTypes) + { + if (modelTypes !=3D null) + { + ModelTypes result =3D new ModelTypes(); + result.setAny(modelTypes.getAny()); + return result; + } + else + { + return null; + } + } + + public static ResourceList toV2ResourceList(V1ResourceList v1ResourceLi= st) + { + if (v1ResourceList !=3D null) + { + ResourceList result =3D new ResourceList(); + + List extensions =3D WSRPUtils.transform(v1ResourceList= .getExtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + List resources =3D WSRPUtils.transform(v1ResourceList.g= etResources(), RESOURCE); + if (resources !=3D null) + { + result.getResources().addAll(resources); + } + + return result; + } + else + { + return null; + } + } + + public static class V1ToV2Extension implements Function + { + public Extension apply(V1Extension from) + { + if (from !=3D null) + { + Extension extension =3D new Extension(); + extension.setAny(from.getAny()); + return extension; + } + else + { + return null; + } + } + } + + public static class V1ToV2PortletDescription implements Function + { + + public PortletDescription apply(V1PortletDescription from) + { + if (from !=3D null) + { + PortletDescription result =3D WSRPTypeFactory.createPortletDes= cription(from.getPortletHandle(), + WSRPUtils.transform(from.getMarkupTypes(), MARKUPTYPE)); + result.setDescription(LOCALIZEDSTRING.apply(from.getDescriptio= n())); + result.setDisplayName(LOCALIZEDSTRING.apply(from.getDisplayNam= e())); + List extensions =3D WSRPUtils.transform(from.getExt= ensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + List keywords =3D WSRPUtils.transform(from.ge= tKeywords(), LOCALIZEDSTRING); + if (keywords !=3D null) + { + result.getKeywords().addAll(keywords); + } + List userCategories =3D from.getUserCategories(); + if (userCategories !=3D null) + { + result.getUserCategories().addAll(userCategories); + } + List userProfileItems =3D from.getUserProfileItems(); + if (userProfileItems !=3D null) + { + result.getUserProfileItems().addAll(userProfileItems); + } + result.setDefaultMarkupSecure(from.isDefaultMarkupSecure()); + result.setDoesUrlTemplateProcessing(from.isDoesUrlTemplateProc= essing()); + result.setTemplatesStoredInSession(from.isTemplatesStoredInSes= sion()); + result.setHasUserSpecificState(from.isHasUserSpecificState()); + result.setOnlySecure(from.isOnlySecure()); + result.setUserContextStoredInSession(from.isUserContextStoredI= nSession()); + result.setUsesMethodGet(from.isUsesMethodGet()); + result.setShortTitle(LOCALIZEDSTRING.apply(from.getShortTitle(= ))); + result.setTitle(LOCALIZEDSTRING.apply(from.getTitle())); + + result.setGroupID(from.getGroupID()); + return result; + } + else + { + return null; + } + } + } + + public static class V1ToV2ItemDescription implements Function + { + + public ItemDescription apply(V1ItemDescription from) + { + if (from !=3D null) + { + ItemDescription result =3D new ItemDescription(); + result.setItemName(from.getItemName()); + result.setDescription(LOCALIZEDSTRING.apply(from.getDescriptio= n())); + List extensions =3D WSRPUtils.transform(from.getExt= ensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + return result; + } + else + { + return null; + } + } + } + + public static class V1ToV2NamedString implements Function + { + public NamedString apply(V1NamedString v1NamedString) + { + if (v1NamedString !=3D null) + { + NamedString result =3D new NamedString(); + result.setName(v1NamedString.getName()); + result.setValue(v1NamedString.getValue()); + return result; + } + else + { + return null; + } + } + } + + public static class V1ToV2UploadContext implements Function + { + + public UploadContext apply(V1UploadContext v1UploadContext) + { + if (v1UploadContext !=3D null) + { + UploadContext result =3D WSRPTypeFactory.createUploadContext(v= 1UploadContext.getMimeType(), v1UploadContext.getUploadData()); + result.getExtensions().addAll(Lists.transform(v1UploadContext.= getExtensions(), EXTENSION)); + result.getMimeAttributes().addAll(Lists.transform(v1UploadCont= ext.getMimeAttributes(), NAMEDSTRING)); + + return result; + } + else + { + return null; + } + } + + } + + public static class V1ToV2MarkupType implements Function + { + + public MarkupType apply(V1MarkupType from) + { + if (from !=3D null) + { + MarkupType result =3D WSRPTypeFactory.createMarkupType(from.ge= tMimeType(), from.getModes(), from.getWindowStates(), from.getLocales()); + List extensions =3D WSRPUtils.transform(from.getExt= ensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + } + + public static class V1ToV2LocalizedString implements Function + { + + public LocalizedString apply(V1LocalizedString from) + { + if (from !=3D null) + { + return WSRPTypeFactory.createLocalizedString(from.getLang(), f= rom.getResourceName(), from.getValue()); + } + else + { + return null; + } + + } + } + + public static class V1ToV2Resource implements Function + { + public Resource apply(V1Resource from) + { + if (from !=3D null) + { + Resource result =3D new Resource(); + result.setResourceName(from.getResourceName()); + List values =3D WSRPUtils.transform(from.getVal= ues(), RESOURCEVALUE); + if (values !=3D null) + { + result.getValues().addAll(values); + } + + return result; + } + else + { + return null; + } + } + + } + + public static class V1ToV2ResourceValue implements Function + { + public ResourceValue apply(V1ResourceValue from) + { + if (from !=3D null) + { + ResourceValue result =3D new ResourceValue(); + result.setLang(from.getLang()); + result.setValue(from.getValue()); + List extensions =3D WSRPUtils.transform(from.getExt= ensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + } + + public static class V1ToV2PropertyDescription implements Function + { + public PropertyDescription apply(V1PropertyDescription from) + { + if (from !=3D null) + { + PropertyDescription result =3D WSRPTypeFactory.createPropertyD= escription(from.getName(), from.getType()); + result.setHint(toV2LocalizedString(from.getHint())); + result.setLabel(toV2LocalizedString(from.getLabel())); + List extensions =3D WSRPUtils.transform(from.getExt= ensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + } +} Copied: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/= V2ToV1Converter.java (from rev 3284, components/wsrp/trunk/common/src/main/= java/org/gatein/wsrp/spec/v1/V2V1Converter.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2To= V1Converter.java (rev 0) +++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2To= V1Converter.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -0,0 +1,981 @@ +/* + * JBoss, a division of Red Hat + * Copyright 2010, Red Hat Middleware, LLC, and individual + * contributors as indicated by the @authors tag. See the + * copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * = = + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.gatein.wsrp.spec.v1; + +import com.google.common.base.Function; +import com.google.common.collect.Lists; +import org.gatein.common.NotYetImplemented; +import org.gatein.wsrp.WSRPUtils; +import org.oasis.wsrp.v1.V1CacheControl; +import org.oasis.wsrp.v1.V1ClientData; +import org.oasis.wsrp.v1.V1Contact; +import org.oasis.wsrp.v1.V1CookieProtocol; +import org.oasis.wsrp.v1.V1EmployerInfo; +import org.oasis.wsrp.v1.V1Extension; +import org.oasis.wsrp.v1.V1InteractionParams; +import org.oasis.wsrp.v1.V1ItemDescription; +import org.oasis.wsrp.v1.V1LocalizedString; +import org.oasis.wsrp.v1.V1MarkupContext; +import org.oasis.wsrp.v1.V1MarkupParams; +import org.oasis.wsrp.v1.V1MarkupType; +import org.oasis.wsrp.v1.V1ModelDescription; +import org.oasis.wsrp.v1.V1ModelTypes; +import org.oasis.wsrp.v1.V1NamedString; +import org.oasis.wsrp.v1.V1Online; +import org.oasis.wsrp.v1.V1PersonName; +import org.oasis.wsrp.v1.V1PortletContext; +import org.oasis.wsrp.v1.V1PortletDescription; +import org.oasis.wsrp.v1.V1Postal; +import org.oasis.wsrp.v1.V1PropertyDescription; +import org.oasis.wsrp.v1.V1RegistrationContext; +import org.oasis.wsrp.v1.V1Resource; +import org.oasis.wsrp.v1.V1ResourceList; +import org.oasis.wsrp.v1.V1ResourceValue; +import org.oasis.wsrp.v1.V1RuntimeContext; +import org.oasis.wsrp.v1.V1SessionContext; +import org.oasis.wsrp.v1.V1StateChange; +import org.oasis.wsrp.v1.V1Telecom; +import org.oasis.wsrp.v1.V1TelephoneNum; +import org.oasis.wsrp.v1.V1Templates; +import org.oasis.wsrp.v1.V1UpdateResponse; +import org.oasis.wsrp.v1.V1UploadContext; +import org.oasis.wsrp.v1.V1UserContext; +import org.oasis.wsrp.v1.V1UserProfile; +import org.oasis.wsrp.v2.CacheControl; +import org.oasis.wsrp.v2.ClientData; +import org.oasis.wsrp.v2.Contact; +import org.oasis.wsrp.v2.CookieProtocol; +import org.oasis.wsrp.v2.EmployerInfo; +import org.oasis.wsrp.v2.Extension; +import org.oasis.wsrp.v2.InteractionParams; +import org.oasis.wsrp.v2.ItemDescription; +import org.oasis.wsrp.v2.LocalizedString; +import org.oasis.wsrp.v2.MarkupContext; +import org.oasis.wsrp.v2.MarkupParams; +import org.oasis.wsrp.v2.MarkupType; +import org.oasis.wsrp.v2.ModelDescription; +import org.oasis.wsrp.v2.ModelTypes; +import org.oasis.wsrp.v2.NamedString; +import org.oasis.wsrp.v2.Online; +import org.oasis.wsrp.v2.PersonName; +import org.oasis.wsrp.v2.PortletContext; +import org.oasis.wsrp.v2.PortletDescription; +import org.oasis.wsrp.v2.Postal; +import org.oasis.wsrp.v2.PropertyDescription; +import org.oasis.wsrp.v2.RegistrationContext; +import org.oasis.wsrp.v2.Resource; +import org.oasis.wsrp.v2.ResourceList; +import org.oasis.wsrp.v2.ResourceValue; +import org.oasis.wsrp.v2.RuntimeContext; +import org.oasis.wsrp.v2.SessionContext; +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 java.util.List; + +/** + * @author Chris Laprun + * @version $Revision$ + */ +public class V2ToV1Converter +{ + + public static final V2ToV1Extension EXTENSION =3D new V2ToV1Extension(); + public static final V2ToV1MarkupType MARKUPTYPE =3D new V2ToV1MarkupTyp= e(); + public static final V2ToV1PortletDescription PORTLETDESCRIPTION =3D new= V2ToV1PortletDescription(); + public static final V2ToV1LocalizedString LOCALIZEDSTRING =3D new V2ToV= 1LocalizedString(); + public static final V2ToV1ItemDescription ITEMDESCRIPTION =3D new V2ToV= 1ItemDescription(); + public static final V2ToV1PropertyDescription PROPERTYDESCRIPTION =3D n= ew V2ToV1PropertyDescription(); + public static final V2ToV1Resource RESOURCE =3D new V2ToV1Resource(); + public static final V2ToV1ResourceValue RESOURCEVALUE =3D new V2ToV1Res= ourceValue(); + public static final V2ToV1NamedString NAMEDSTRING =3D new V2ToV1NamedSt= ring(); + public static final V2ToV1UploadContext UPLOADCONTEXT =3D new V2ToV1Upl= oadContext(); + + + public static V1PortletDescription toV1PortletDescription(PortletDescri= ption portletDescription) + { + throw new NotYetImplemented(); + } + + public static V1PortletContext toV1PortletContext(PortletContext portle= tContext) + { + if (portletContext !=3D null) + { + V1PortletContext v1PortletContext =3D WSRP1TypeFactory.createPort= letContext(portletContext.getPortletHandle(), portletContext.getPortletStat= e()); + + List extensions =3D WSRPUtils.transform(portletConte= xt.getExtensions(), EXTENSION); + if (extensions !=3D null) + { + v1PortletContext.getExtensions().addAll(extensions); + } + + return v1PortletContext; + } + else + { + return null; + } + } + + public static V1MarkupParams toV1MarkupParams(MarkupParams markupParams) + { + if (markupParams !=3D null) + { + V1MarkupParams v1MarkupParams =3D WSRP1TypeFactory.createMarkupPa= rams(markupParams.isSecureClientCommunication(), markupParams.getLocales(), + markupParams.getMimeTypes(), markupParams.getMode(), markupPar= ams.getWindowState()); + + v1MarkupParams.setClientData(toV1ClientData(markupParams.getClien= tData())); + v1MarkupParams.setNavigationalState(markupParams.getNavigationalC= ontext().getOpaqueValue()); + v1MarkupParams.setValidateTag(markupParams.getValidateTag()); + + List charSets =3D markupParams.getMarkupCharacterSets(); + if (charSets !=3D null) + { + v1MarkupParams.getMarkupCharacterSets().addAll(charSets); + } + + List validNewModes =3D markupParams.getValidNewModes(); + if (validNewModes !=3D null) + { + v1MarkupParams.getValidNewModes().addAll(validNewModes); + } + + List validNewWindowStates =3D markupParams.getValidNewWin= dowStates(); + if (validNewWindowStates !=3D null) + { + v1MarkupParams.getValidNewWindowStates().addAll(validNewWindow= States); + } + + List extensions =3D WSRPUtils.transform(markupParams= .getExtensions(), EXTENSION); + if (extensions !=3D null) + { + v1MarkupParams.getExtensions().addAll(extensions); + } + + return v1MarkupParams; + } + else + { + return null; + } + } + + private static V1ClientData toV1ClientData(ClientData clientData) + { + if (clientData !=3D null) + { + V1ClientData v1ClientData =3D WSRP1TypeFactory.createClientData(c= lientData.getUserAgent()); + + List extensions =3D clientData.getExtensions(); + if (extensions !=3D null) + { + v1ClientData.getExtensions().addAll(Lists.transform(extensions= , EXTENSION)); + } + + return v1ClientData; + } + else + { + return null; + } + } + + public static V1RuntimeContext toV1RuntimeContext(RuntimeContext runtim= eContext) + { + if (runtimeContext !=3D null) + { + V1RuntimeContext v1RuntimeContext =3D WSRP1TypeFactory.createRunt= imeContext(runtimeContext.getUserAuthentication()); + v1RuntimeContext.setNamespacePrefix(runtimeContext.getNamespacePr= efix()); + v1RuntimeContext.setPortletInstanceKey(runtimeContext.getPortletI= nstanceKey()); + v1RuntimeContext.setSessionID(runtimeContext.getSessionParams().g= etSessionID()); + v1RuntimeContext.setTemplates(V2ToV1Converter.toV1Templates(runti= meContext.getTemplates())); + + List extensions =3D runtimeContext.getExtensions(); + if (extensions !=3D null) + { + v1RuntimeContext.getExtensions().addAll(WSRPUtils.transform(ex= tensions, EXTENSION)); + } + + return v1RuntimeContext; + } + else + { + return null; + } + } + + public static V1Templates toV1Templates(Templates templates) + { + if (templates !=3D null) + { + //TODO: should we be using the WSRP1TypeFactory,createTemplates(P= ortletInvocationContext) instead? + V1Templates v1Templates =3D new V1Templates(); + v1Templates.setBlockingActionTemplate(templates.getBlockingAction= Template()); + v1Templates.setDefaultTemplate(templates.getDefaultTemplate()); + v1Templates.setRenderTemplate(templates.getRenderTemplate()); + v1Templates.setResourceTemplate(templates.getResourceTemplate()); + v1Templates.setSecureBlockingActionTemplate(templates.getSecureBl= ockingActionTemplate()); + v1Templates.setSecureRenderTemplate(templates.getSecureRenderTemp= late()); + v1Templates.setSecureResourceTemplate(templates.getSecureResource= Template()); + + List extensions =3D templates.getExtensions(); + if (extensions !=3D null) + { + v1Templates.getExtensions().addAll(WSRPUtils.transform(extensi= ons, EXTENSION)); + } + + return v1Templates; + } + else + { + return null; + } + } + + public static V1UserContext toV1UserContext(UserContext userContext) + { + if (userContext !=3D null) + { + V1UserContext v1UserContext =3D WSRP1TypeFactory.createUserContex= t(userContext.getUserContextKey()); + + v1UserContext.setProfile(toV1UserProfile(userContext.getProfile()= )); + + List extensions =3D userContext.getExtensions(); + if (extensions !=3D null) + { + v1UserContext.getExtensions().addAll(WSRPUtils.transform(exten= sions, EXTENSION)); + } + + if (userContext.getUserCategories() !=3D null) + { + v1UserContext.getUserCategories().addAll(userContext.getUserCa= tegories()); + } + + return v1UserContext; + } + else + { + return null; + } + } + + public static V1UserProfile toV1UserProfile(UserProfile userProfile) + { + if (userProfile !=3D null) + { + V1UserProfile v1UserProfile =3D new V1UserProfile(); + v1UserProfile.setBdate(userProfile.getBdate()); + v1UserProfile.setBusinessInfo(toV1Context(userProfile.getBusiness= Info())); + v1UserProfile.setEmployerInfo(toV1EmployerInfo(userProfile.getEmp= loyerInfo())); + v1UserProfile.setGender(userProfile.getGender()); + v1UserProfile.setHomeInfo(toV1Context(userProfile.getHomeInfo())); + v1UserProfile.setName(toV1PersonName(userProfile.getName())); + + return v1UserProfile; + } + else + { + return null; + } + } + + public static V1EmployerInfo toV1EmployerInfo(EmployerInfo employerInfo) + { + if (employerInfo !=3D null) + { + V1EmployerInfo v1EmployerInfo =3D new V1EmployerInfo(); + v1EmployerInfo.setDepartment(employerInfo.getDepartment()); + v1EmployerInfo.setEmployer(employerInfo.getEmployer()); + v1EmployerInfo.setJobtitle(employerInfo.getJobtitle()); + + List extensions =3D employerInfo.getExtensions(); + if (extensions !=3D null) + { + v1EmployerInfo.getExtensions().addAll(WSRPUtils.transform(exte= nsions, EXTENSION)); + } + + return v1EmployerInfo; + } + else + { + return null; + } + } + + public static V1PersonName toV1PersonName(PersonName personName) + { + if (personName !=3D null) + { + V1PersonName v1PersonName =3D new V1PersonName(); + v1PersonName.setFamily(personName.getFamily()); + v1PersonName.setGiven(personName.getGiven()); + v1PersonName.setMiddle(personName.getMiddle()); + v1PersonName.setNickname(personName.getNickname()); + v1PersonName.setPrefix(personName.getPrefix()); + v1PersonName.setSuffix(personName.getSuffix()); + + List extensions =3D personName.getExtensions(); + if (extensions !=3D null) + { + v1PersonName.getExtensions().addAll(WSRPUtils.transform(extens= ions, EXTENSION)); + } + + return v1PersonName; + } + else + { + return null; + } + } + + public static V1Contact toV1Context(Contact contact) + { + if (contact !=3D null) + { + V1Contact v1Contact =3D new V1Contact(); + v1Contact.setOnline(toV1Online(contact.getOnline())); + v1Contact.setPostal(toV1Postal(contact.getPostal())); + v1Contact.setTelecom(toV1Telecom(contact.getTelecom())); + + List extensions =3D contact.getExtensions(); + if (extensions !=3D null) + { + v1Contact.getExtensions().addAll(WSRPUtils.transform(extension= s, EXTENSION)); + } + + return v1Contact; + } + else + { + return null; + } + } + + public static V1Online toV1Online(Online online) + { + if (online !=3D null) + { + V1Online v1Online =3D new V1Online(); + v1Online.setEmail(online.getEmail()); + v1Online.setUri(online.getUri()); + + List extensions =3D online.getExtensions(); + if (extensions !=3D null) + { + v1Online.getExtensions().addAll(WSRPUtils.transform(extensions= , EXTENSION)); + } + + return v1Online; + } + else + { + return null; + } + } + + public static V1Postal toV1Postal(Postal postal) + { + if (postal !=3D null) + { + V1Postal v1Postal =3D new V1Postal(); + v1Postal.setCity(postal.getCity()); + v1Postal.setCountry(postal.getCountry()); + v1Postal.setName(postal.getName()); + v1Postal.setOrganization(postal.getOrganization()); + v1Postal.setPostalcode(postal.getPostalcode()); + v1Postal.setStateprov(postal.getStateprov()); + v1Postal.setStreet(postal.getStreet()); + + List extensions =3D postal.getExtensions(); + if (extensions !=3D null) + { + v1Postal.getExtensions().addAll(WSRPUtils.transform(extensions= , EXTENSION)); + } + + return v1Postal; + } + else + { + return null; + } + } + + public static V1Telecom toV1Telecom(Telecom telecom) + { + if (telecom !=3D null) + { + V1Telecom v1Telecom =3D new V1Telecom(); + v1Telecom.setFax(toV1TelephoneNum(telecom.getFax())); + v1Telecom.setMobile(toV1TelephoneNum(telecom.getMobile())); + v1Telecom.setPager(toV1TelephoneNum(telecom.getPager())); + v1Telecom.setTelephone(toV1TelephoneNum(telecom.getTelephone())); + + List extensions =3D telecom.getExtensions(); + if (extensions !=3D null) + { + v1Telecom.getExtensions().addAll(WSRPUtils.transform(extension= s, EXTENSION)); + } + + return v1Telecom; + } + else + { + return null; + } + } + + public static V1TelephoneNum toV1TelephoneNum(TelephoneNum telephoneNum) + { + if (telephoneNum !=3D null) + { + V1TelephoneNum v1TelephoneNum =3D new V1TelephoneNum(); + v1TelephoneNum.setComment(telephoneNum.getComment()); + v1TelephoneNum.setExt(telephoneNum.getExt()); + v1TelephoneNum.setIntcode(telephoneNum.getIntcode()); + v1TelephoneNum.setLoccode(telephoneNum.getLoccode()); + v1TelephoneNum.setNumber(telephoneNum.getNumber()); + + List extensions =3D telephoneNum.getExtensions(); + if (extensions !=3D null) + { + v1TelephoneNum.getExtensions().addAll(WSRPUtils.transform(exte= nsions, EXTENSION)); + } + + return v1TelephoneNum; + } + else + { + return null; + } + } + + public static V1MarkupContext toV1MarkupContext(MarkupContext markupCon= text) + { + if (markupContext !=3D null) + { + V1MarkupContext v1MarkupContext =3D new V1MarkupContext(); + v1MarkupContext.setMarkupBinary(markupContext.getItemBinary()); + v1MarkupContext.setMarkupString(markupContext.getItemString()); + v1MarkupContext.setCacheControl(toV1CacheControl(markupContext.ge= tCacheControl())); + v1MarkupContext.setLocale(markupContext.getLocale()); + v1MarkupContext.setMimeType(markupContext.getMimeType()); + v1MarkupContext.setPreferredTitle(markupContext.getPreferredTitle= ()); + v1MarkupContext.setRequiresUrlRewriting(markupContext.isRequiresR= ewriting()); + v1MarkupContext.setUseCachedMarkup(markupContext.isUseCachedItem(= )); + + List extensions =3D markupContext.getExtensions(); + if (extensions !=3D null) + { + v1MarkupContext.getExtensions().addAll(WSRPUtils.transform(ext= ensions, EXTENSION)); + } + + return v1MarkupContext; + } + else + { + return null; + } + } + + public static V1CacheControl toV1CacheControl(CacheControl cacheControl) + { + if (cacheControl !=3D null) + { + V1CacheControl v1CacheControl =3D WSRP1TypeFactory.createCacheCon= trol(cacheControl.getExpires(), cacheControl.getUserScope()); + v1CacheControl.setValidateTag(cacheControl.getValidateTag()); + + List extensions =3D cacheControl.getExtensions(); + if (extensions !=3D null) + { + v1CacheControl.getExtensions().addAll(WSRPUtils.transform(exte= nsions, EXTENSION)); + } + + return v1CacheControl; + } + else + { + return null; + } + } + + public static V1RegistrationContext toV1RegistrationContext(Registratio= nContext registrationContext) + { + if (registrationContext !=3D null) + { + V1RegistrationContext result =3D WSRP1TypeFactory.createRegistrat= ionContext(registrationContext.getRegistrationHandle()); + result.setRegistrationState(registrationContext.getRegistrationSt= ate()); + List extensions =3D WSRPUtils.transform(registration= Context.getExtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + return result; + } + else + { + return null; + } + } + + public static E toV1Exception(Class v1Exceptio= nClass, Exception v2Exception) + { + if (!"org.oasis.wsrp.v1".equals(v1ExceptionClass.getPackage().getNam= e())) + { + throw new IllegalArgumentException("Specified exception class is = not a WSRP 1 exception: " + v1ExceptionClass); + } + + Class v2ExceptionClass =3D v2Exception.getClass= (); + String v1Name =3D v2ExceptionClass.getSimpleName(); + if (!"org.oasis.wsrp.v2".equals(v2ExceptionClass.getPackage().getNam= e())) + { + throw new IllegalArgumentException("Specified exception is not a = WSRP 2 exception: " + v2Exception); + } + + String v2Name =3D v2ExceptionClass.getSimpleName(); + // V1 class name should match V2 class name plus "V1" + if (!v2Name.equals(v1Name.substring(2))) + { + throw new IllegalArgumentException("Exception names do not match.= Requested: " + v1Name + + ", was given: " + v2Name); + } + + return WSRP1ExceptionFactory.createWSException(v1ExceptionClass, v2E= xception.getMessage(), v2Exception.getCause()); + } + + public static V1CookieProtocol toV1CookieProtocol(CookieProtocol requir= esInitCookie) + { + if (requiresInitCookie !=3D null) + { + return V1CookieProtocol.fromValue(requiresInitCookie.value()); + } + else + { + return null; + } + } + + public static V1ModelDescription toV1ModelDescription(ModelDescription = modelDescription) + { + if (modelDescription !=3D null) + { + V1ModelDescription result =3D WSRP1TypeFactory.createModelDescrip= tion(WSRPUtils.transform(modelDescription.getPropertyDescriptions(), PROPER= TYDESCRIPTION)); + List extensions =3D WSRPUtils.transform(modelDescrip= tion.getExtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + result.setModelTypes(toV1ModelTypes(modelDescription.getModelType= s())); + + return result; + } + else + { + return null; + } + } + + public static V1ModelTypes toV1ModelTypes(ModelTypes modelTypes) + { + if (modelTypes !=3D null) + { + V1ModelTypes result =3D new V1ModelTypes(); + result.setAny(modelTypes.getAny()); + return result; + } + else + { + return null; + } + } + + public static V1ResourceList toV1ResourceList(ResourceList resourceList) + { + if (resourceList !=3D null) + { + V1ResourceList result =3D new V1ResourceList(); + List extensions =3D WSRPUtils.transform(resourceList= .getExtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + List v1Resources =3D WSRPUtils.transform(resourceList= .getResources(), RESOURCE); + if (v1Resources !=3D null) + { + result.getResources().addAll(v1Resources); + } + return result; + } + else + { + return null; + } + } + + public static V1InteractionParams toV1InteractionParams(InteractionPara= ms interactionParams) + { + if (interactionParams !=3D null) + { + V1InteractionParams v1InteractionParams =3D WSRP1TypeFactory.crea= teInteractionParams(toV1StateChange(interactionParams.getPortletStateChange= ())); + v1InteractionParams.setInteractionState(interactionParams.getInte= ractionState()); + + List extensions =3D interactionParams.getExtensions(); + if (extensions !=3D null) + { + v1InteractionParams.getExtensions().addAll(Lists.transform(ext= ensions, EXTENSION)); + } + + List formParameters =3D interactionParams.getFormPar= ameters(); + if (formParameters !=3D null) + { + v1InteractionParams.getFormParameters().addAll(Lists.transform= (formParameters, NAMEDSTRING)); + } + + List uploadContext =3D interactionParams.getUpload= Contexts(); + if (uploadContext !=3D null) + { + v1InteractionParams.getUploadContexts().addAll(Lists.transform= (uploadContext, UPLOADCONTEXT)); + } + + return v1InteractionParams; + } + else + { + return null; + } + } + + + public static V1StateChange toV1StateChange(StateChange stateChange) + { + if (stateChange !=3D null) + { + return V1StateChange.valueOf(stateChange.value()); + } + else + { + return null; + } + } + + public static V1UpdateResponse toV1UpdateResponse(UpdateResponse update= Response) + { + if (updateResponse !=3D null) + { + V1UpdateResponse v1UpdateResponse =3D WSRP1TypeFactory.createUpda= teResponse(); + v1UpdateResponse.setMarkupContext(toV1MarkupContext(updateRespons= e.getMarkupContext())); + v1UpdateResponse.setNavigationalState(updateResponse.getNavigatio= nalContext().getOpaqueValue()); + v1UpdateResponse.setNewWindowState(updateResponse.getNewWindowSta= te()); + v1UpdateResponse.setPortletContext(toV1PortletContext(updateRespo= nse.getPortletContext())); + v1UpdateResponse.setSessionContext(toV1SessionContext(updateRespo= nse.getSessionContext())); + v1UpdateResponse.setNewMode(updateResponse.getNewMode()); + return v1UpdateResponse; + } + else + { + return null; + } + } + + public static V1LocalizedString toV1LocalizedString(LocalizedString loc= alizedString) + { + return LOCALIZEDSTRING.apply(localizedString); + } + + public static V1SessionContext toV1SessionContext(SessionContext sessio= nContext) + { + if (sessionContext !=3D null) + { + V1SessionContext v1SessionContext =3D WSRP1TypeFactory.createSess= ionContext(sessionContext.getSessionID(), sessionContext.getExpires().intVa= lue()); + v1SessionContext.getExtensions().addAll(Lists.transform(sessionCo= ntext.getExtensions(), EXTENSION)); + + return v1SessionContext; + } + else + { + return null; + } + } + + private static class V2ToV1Extension implements Function + { + public V1Extension apply(Extension from) + { + if (from !=3D null) + { + V1Extension extension =3D new V1Extension(); + extension.setAny(from.getAny()); + return extension; + } + else + { + return null; + } + } + } + + private static class V2ToV1PortletDescription implements Function + { + + public V1PortletDescription apply(PortletDescription from) + { + if (from !=3D null) + { + V1PortletDescription result =3D WSRP1TypeFactory.createPortlet= Description(from.getPortletHandle(), + WSRPUtils.transform(from.getMarkupTypes(), MARKUPTYPE)); + result.setDescription(LOCALIZEDSTRING.apply(from.getDescriptio= n())); + result.setDisplayName(LOCALIZEDSTRING.apply(from.getDisplayNam= e())); + List extensions =3D WSRPUtils.transform(from.getE= xtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + List keywords =3D WSRPUtils.transform(from.= getKeywords(), LOCALIZEDSTRING); + if (keywords !=3D null) + { + result.getKeywords().addAll(keywords); + } + List userCategories =3D from.getUserCategories(); + if (userCategories !=3D null) + { + result.getUserCategories().addAll(userCategories); + } + List userProfileItems =3D from.getUserProfileItems(); + if (userProfileItems !=3D null) + { + result.getUserProfileItems().addAll(userProfileItems); + } + result.setDefaultMarkupSecure(from.isDefaultMarkupSecure()); + result.setDoesUrlTemplateProcessing(from.isDoesUrlTemplateProc= essing()); + result.setTemplatesStoredInSession(from.isTemplatesStoredInSes= sion()); + result.setHasUserSpecificState(from.isHasUserSpecificState()); + result.setOnlySecure(from.isOnlySecure()); + result.setUserContextStoredInSession(from.isUserContextStoredI= nSession()); + result.setUsesMethodGet(from.isUsesMethodGet()); + result.setShortTitle(LOCALIZEDSTRING.apply(from.getShortTitle(= ))); + result.setTitle(LOCALIZEDSTRING.apply(from.getTitle())); + + result.setGroupID(from.getGroupID()); + return result; + } + else + { + return null; + } + } + } + + private static class V2ToV1ItemDescription implements Function + { + + public V1ItemDescription apply(ItemDescription from) + { + if (from !=3D null) + { + V1ItemDescription result =3D new V1ItemDescription(); + result.setItemName(from.getItemName()); + result.setDescription(LOCALIZEDSTRING.apply(from.getDescriptio= n())); + List extensions =3D WSRPUtils.transform(from.getE= xtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + return result; + } + else + { + return null; + } + } + } + + + public static class V2ToV1NamedString implements Function + { + public V1NamedString apply(NamedString namedString) + { + if (namedString !=3D null) + { + V1NamedString result =3D new V1NamedString(); + result.setName(namedString.getName()); + result.setValue(namedString.getValue()); + return result; + } + else + { + return null; + } + } + } + + public static class V2ToV1UploadContext implements Function + { + + public V1UploadContext apply(UploadContext uploadContext) + { + if (uploadContext !=3D null) + { + V1UploadContext result =3D WSRP1TypeFactory.createUploadContex= t(uploadContext.getMimeType(), uploadContext.getUploadData()); + + List extensions =3D uploadContext.getExtensions(); + if (extensions !=3D null) + { + result.getExtensions().addAll(Lists.transform(extensions, E= XTENSION)); + } + + List mimeAttributes =3D uploadContext.getMimeAttr= ibutes(); + if (mimeAttributes !=3D null) + { + result.getMimeAttributes().addAll(Lists.transform(mimeAttri= butes, NAMEDSTRING)); + } + + return result; + } + else + { + return null; + } + } + + } + + private static class V2ToV1MarkupType implements Function + { + + public V1MarkupType apply(MarkupType from) + { + if (from !=3D null) + { + V1MarkupType result =3D WSRP1TypeFactory.createMarkupType(from= .getMimeType(), from.getModes(), from.getWindowStates(), from.getLocales()); + List extensions =3D WSRPUtils.transform(from.getE= xtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + } + + private static class V2ToV1LocalizedString implements Function + { + + public V1LocalizedString apply(LocalizedString from) + { + if (from !=3D null) + { + return WSRP1TypeFactory.createLocalizedString(from.getLang(), = from.getResourceName(), from.getValue()); + } + else + { + return null; + } + + } + } + + private static class V2ToV1PropertyDescription implements Function + { + + public V1PropertyDescription apply(PropertyDescription from) + { + if (from !=3D null) + { + V1PropertyDescription result =3D WSRP1TypeFactory.createProper= tyDescription(from.getName().toString(), from.getType()); + result.setHint(toV1LocalizedString(from.getHint())); + result.setLabel(toV1LocalizedString(from.getLabel())); + List extensions =3D WSRPUtils.transform(from.getE= xtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + } + + private static class V2ToV1Resource implements Function + { + public V1Resource apply(Resource from) + { + if (from !=3D null) + { + V1Resource result =3D new V1Resource(); + result.setResourceName(from.getResourceName()); + List values =3D WSRPUtils.transform(from.getV= alues(), RESOURCEVALUE); + if (values !=3D null) + { + result.getValues().addAll(values); + } + + return result; + } + else + { + return null; + } + } + + } + + private static class V2ToV1ResourceValue implements Function + { + public V1ResourceValue apply(ResourceValue from) + { + if (from !=3D null) + { + V1ResourceValue result =3D new V1ResourceValue(); + result.setLang(from.getLang()); + result.setValue(from.getValue()); + List extensions =3D WSRPUtils.transform(from.getE= xtensions(), EXTENSION); + if (extensions !=3D null) + { + result.getExtensions().addAll(extensions); + } + + return result; + } + else + { + return null; + } + } + } + +} Deleted: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1= /V2V1Converter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1= Converter.java 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2V1= Converter.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -1,1770 +0,0 @@ -/* - * JBoss, a division of Red Hat - * Copyright 2010, Red Hat Middleware, LLC, and individual - * contributors as indicated by the @authors tag. See the - * copyright.txt in the distribution for a full listing of - * individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.gatein.wsrp.spec.v1; - -import com.google.common.base.Function; -import com.google.common.collect.Lists; -import org.gatein.common.NotYetImplemented; -import org.gatein.pc.api.OpaqueStateString; -import org.gatein.wsrp.WSRPExceptionFactory; -import org.gatein.wsrp.WSRPTypeFactory; -import org.oasis.wsrp.v1.V1CacheControl; -import org.oasis.wsrp.v1.V1ClientData; -import org.oasis.wsrp.v1.V1Contact; -import org.oasis.wsrp.v1.V1CookieProtocol; -import org.oasis.wsrp.v1.V1EmployerInfo; -import org.oasis.wsrp.v1.V1Extension; -import org.oasis.wsrp.v1.V1Fault; -import org.oasis.wsrp.v1.V1InteractionParams; -import org.oasis.wsrp.v1.V1ItemDescription; -import org.oasis.wsrp.v1.V1LocalizedString; -import org.oasis.wsrp.v1.V1MarkupContext; -import org.oasis.wsrp.v1.V1MarkupParams; -import org.oasis.wsrp.v1.V1MarkupType; -import org.oasis.wsrp.v1.V1ModelDescription; -import org.oasis.wsrp.v1.V1ModelTypes; -import org.oasis.wsrp.v1.V1NamedString; -import org.oasis.wsrp.v1.V1Online; -import org.oasis.wsrp.v1.V1PersonName; -import org.oasis.wsrp.v1.V1PortletContext; -import org.oasis.wsrp.v1.V1PortletDescription; -import org.oasis.wsrp.v1.V1Postal; -import org.oasis.wsrp.v1.V1PropertyDescription; -import org.oasis.wsrp.v1.V1RegistrationContext; -import org.oasis.wsrp.v1.V1Resource; -import org.oasis.wsrp.v1.V1ResourceList; -import org.oasis.wsrp.v1.V1ResourceValue; -import org.oasis.wsrp.v1.V1RuntimeContext; -import org.oasis.wsrp.v1.V1ServiceDescription; -import org.oasis.wsrp.v1.V1SessionContext; -import org.oasis.wsrp.v1.V1StateChange; -import org.oasis.wsrp.v1.V1Telecom; -import org.oasis.wsrp.v1.V1TelephoneNum; -import org.oasis.wsrp.v1.V1Templates; -import org.oasis.wsrp.v1.V1UpdateResponse; -import org.oasis.wsrp.v1.V1UploadContext; -import org.oasis.wsrp.v1.V1UserContext; -import org.oasis.wsrp.v1.V1UserProfile; -import org.oasis.wsrp.v2.CacheControl; -import org.oasis.wsrp.v2.ClientData; -import org.oasis.wsrp.v2.Contact; -import org.oasis.wsrp.v2.CookieProtocol; -import org.oasis.wsrp.v2.EmployerInfo; -import org.oasis.wsrp.v2.Extension; -import org.oasis.wsrp.v2.InteractionParams; -import org.oasis.wsrp.v2.ItemDescription; -import org.oasis.wsrp.v2.LocalizedString; -import org.oasis.wsrp.v2.MarkupContext; -import org.oasis.wsrp.v2.MarkupParams; -import org.oasis.wsrp.v2.MarkupType; -import org.oasis.wsrp.v2.ModelDescription; -import org.oasis.wsrp.v2.ModelTypes; -import org.oasis.wsrp.v2.NamedString; -import org.oasis.wsrp.v2.Online; -import org.oasis.wsrp.v2.PersonName; -import org.oasis.wsrp.v2.PortletContext; -import org.oasis.wsrp.v2.PortletDescription; -import org.oasis.wsrp.v2.Postal; -import org.oasis.wsrp.v2.PropertyDescription; -import org.oasis.wsrp.v2.RegistrationContext; -import org.oasis.wsrp.v2.Resource; -import org.oasis.wsrp.v2.ResourceList; -import org.oasis.wsrp.v2.ResourceValue; -import org.oasis.wsrp.v2.RuntimeContext; -import org.oasis.wsrp.v2.ServiceDescription; -import org.oasis.wsrp.v2.SessionContext; -import org.oasis.wsrp.v2.SessionParams; -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 java.util.List; - -/** - * @author Chris Laprun - * @version $Revision$ - */ -public class V2V1Converter -{ - public static final V1ToV2Extension V1_TO_V2_EXTENSION =3D new V1ToV2Ex= tension(); - - public static final V2ToV1Extension V2_TO_V1_EXTENSION =3D new V2ToV1Ex= tension(); - public static final V2ToV1MarkupType V2_TO_V1_MARKUPTYPE =3D new V2ToV1= MarkupType(); - public static final V1ToV2MarkupType V1_TO_V2_MARKUPTYPE =3D new V1ToV2= MarkupType(); - public static final V2ToV1PortletDescription V2_TO_V1_PORTLETDESCRIPTIO= N =3D new V2ToV1PortletDescription(); - public static final V1ToV2PortletDescription V1_TO_V2_PORTLETDESCRIPTIO= N =3D new V1ToV2PortletDescription(); - public static final V2ToV1LocalizedString V2_TO_V1_LOCALIZEDSTRING =3D = new V2ToV1LocalizedString(); - public static final V1ToV2LocalizedString V1_TO_V2_LOCALIZEDSTRING =3D = new V1ToV2LocalizedString(); - public static final V2ToV1ItemDescription V2_TO_V1_ITEMDESCRIPTION =3D = new V2ToV1ItemDescription(); - - public static final V1ToV2ItemDescription V1_TO_V2_ITEMDESCRIPTION =3D = new V1ToV2ItemDescription(); - public static final V2ToV1PropertyDescription V2_TO_V1_PROPERTYDESCRIPT= ION =3D new V2ToV1PropertyDescription(); - public static final V2ToV1Resource V2_TO_V1_RESOURCE =3D new V2ToV1Reso= urce(); - public static final V2ToV1ResourceValue V2_TO_V1_RESOURCEVALUE =3D new = V2ToV1ResourceValue(); - public static final V1ToV2PropertyDescription V1_TO_V2_PROPERTYDESCRIPT= ION =3D new V1ToV2PropertyDescription(); - public static final V1ToV2Resource V1_TO_V2_RESOURCE =3D new V1ToV2Reso= urce(); - private static final V1ToV2ResourceValue V1_TO_V2_RESOURCEVALUE =3D new= V1ToV2ResourceValue(); - - - public static final V1ToV2NamedString V1_TO_V2_NAMEDSTRING =3D new V1To= V2NamedString(); - public static final V2ToV1NamedString V2_TO_V1_NAMEDSTRING =3D new V2To= V1NamedString(); - public static final V1ToV2UploadContext V1_TO_V2_UPLOADCONTEXT =3D new = V1ToV2UploadContext(); - public static final V2ToV1UploadContext V2_TO_V1_UPLOADCONTEXT =3D new = V2ToV1UploadContext(); - - public static List transform(List fromList, Function function) - { - if (fromList =3D=3D null) - { - return null; - } - else - { - return Lists.transform(fromList, function); - } - } - - - public static V1PortletDescription toV1PortletDescription(PortletDescri= ption portletDescription) - { - throw new NotYetImplemented(); - } - - public static V1PortletContext toV1PortletContext(PortletContext portle= tContext) - { - if (portletContext !=3D null) - { - V1PortletContext v1PortletContext =3D WSRP1TypeFactory.createPort= letContext(portletContext.getPortletHandle(), portletContext.getPortletStat= e()); - = - List extensions =3D V2V1Converter.transform(portletC= ontext.getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - v1PortletContext.getExtensions().addAll(extensions); - } - = - return v1PortletContext; - } - else - { - return null; - } - } - - public static MarkupParams toV2MarkupParams(V1MarkupParams v1MarkupPara= ms) - { - if (v1MarkupParams !=3D null) - { - MarkupParams markupParams =3D WSRPTypeFactory.createMarkupParams(= v1MarkupParams.isSecureClientCommunication(), - v1MarkupParams.getLocales(), v1MarkupParams.getMimeTypes(), v1= MarkupParams.getMode(), - v1MarkupParams.getWindowState()); - markupParams.setClientData(toV2ClientData(v1MarkupParams.getClien= tData())); - = - // we can't create an opaquestatestring if with a null string, so= need to check - if (v1MarkupParams.getNavigationalState() !=3D null) - { - markupParams.setNavigationalContext(WSRPTypeFactory.createNavi= gationalContextOrNull( - new OpaqueStateString(v1MarkupParams.getNavigationalStat= e()), null)); - } - markupParams.setValidateTag(v1MarkupParams.getValidateTag()); - - List charSets =3D v1MarkupParams.getMarkupCharacterSets(); - if (charSets !=3D null) - { - markupParams.getMarkupCharacterSets().addAll(charSets); - } - List validNewModes =3D v1MarkupParams.getValidNewModes(); - if (validNewModes !=3D null) - { - markupParams.getValidNewModes().addAll(validNewModes); - } - List validNewWindowStates =3D v1MarkupParams.getValidNewW= indowStates(); - if (validNewWindowStates !=3D null) - { - markupParams.getValidNewWindowStates().addAll(validNewWindowSt= ates); - } - - List extensions =3D V2V1Converter.transform(v1MarkupPa= rams.getExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - markupParams.getExtensions().addAll(extensions); - } - return markupParams; - } - else - { - return null; - } - } - - public static V1MarkupParams toV1MarkupParams(MarkupParams markupParams) - { - if (markupParams !=3D null) - { - V1MarkupParams v1MarkupParams =3D WSRP1TypeFactory.createMarkupPa= rams(markupParams.isSecureClientCommunication(), markupParams.getLocales(), = - markupParams.getMimeTypes(), markupParams.getMode(), markup= Params.getWindowState()); - = - v1MarkupParams.setClientData(toV1ClientData(markupParams.getClien= tData())); - v1MarkupParams.setNavigationalState(markupParams.getNavigationalC= ontext().getOpaqueValue()); - v1MarkupParams.setValidateTag(markupParams.getValidateTag()); - = - List charSets =3D markupParams.getMarkupCharacterSets(); - if (charSets !=3D null) - { - v1MarkupParams.getMarkupCharacterSets().addAll(charSets); - } - = - List validNewModes =3D markupParams.getValidNewModes(); - if (validNewModes !=3D null) - { - v1MarkupParams.getValidNewModes().addAll(validNewModes); - } - = - List validNewWindowStates =3D markupParams.getValidNewWin= dowStates(); - if (validNewWindowStates !=3D null) - { - v1MarkupParams.getValidNewWindowStates().addAll(validNewWindow= States); - } - = - List extensions =3D V2V1Converter.transform(markupPa= rams.getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - v1MarkupParams.getExtensions().addAll(extensions); - } - = - return v1MarkupParams; - } - else - { - return null; - } - } - - private static ClientData toV2ClientData(V1ClientData v1ClientData) - { - if (v1ClientData !=3D null) - { - ClientData clientData =3D WSRPTypeFactory.createClientData(v1Clie= ntData.getUserAgent()); - = - List extensions =3D v1ClientData.getExtensions(); - if (extensions !=3D null) - { - clientData.getExtensions().addAll(Lists.transform(extensions, = V1_TO_V2_EXTENSION)); - } - - return clientData; = - } - else - { - return null; - } - } - - private static V1ClientData toV1ClientData(ClientData clientData) - { - if (clientData !=3D null) - { - V1ClientData v1ClientData =3D WSRP1TypeFactory.createClientData(c= lientData.getUserAgent()); - = - List extensions =3D clientData.getExtensions(); - if (extensions !=3D null) - { - v1ClientData.getExtensions().addAll(Lists.transform(extensions= , V2_TO_V1_EXTENSION)); - } - - return v1ClientData; - } - else - { - return null; - } - } - = - public static PortletContext toV2PortletContext(V1PortletContext v1Port= letContext) - { - if (v1PortletContext !=3D null) - { - PortletContext portletContext =3D WSRPTypeFactory.createPortletCo= ntext(v1PortletContext.getPortletHandle(), v1PortletContext.getPortletState= ()); - = - List extensions =3D v1PortletContext.getExtensions(); - if (extensions !=3D null) - { - portletContext.getExtensions().addAll(V2V1Converter.transform(= extensions, V1_TO_V2_EXTENSION)); - } - = - return portletContext; - } - else - { - return null; - } - } - - public static RegistrationContext toV2RegistrationContext(V1Registratio= nContext registrationContext) - { - if (registrationContext !=3D null) - { - RegistrationContext result =3D WSRPTypeFactory.createRegistration= Context(registrationContext.getRegistrationHandle()); - result.setRegistrationState(registrationContext.getRegistrationSt= ate()); - List extensions =3D V2V1Converter.transform(registrati= onContext.getExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - - public static RuntimeContext toV2RuntimeContext(V1RuntimeContext v1Runt= imeContext) - { - if (v1RuntimeContext !=3D null) - { - RuntimeContext runtimeContext =3D WSRPTypeFactory.createRuntimeCo= ntext(v1RuntimeContext.getUserAuthentication()); - runtimeContext.setNamespacePrefix(v1RuntimeContext.getNamespacePr= efix()); - runtimeContext.setPortletInstanceKey(v1RuntimeContext.getPortletI= nstanceKey()); - = - //TODO: handle the SessionParams better - SessionParams sessionParams =3D new SessionParams(); - sessionParams.setSessionID(v1RuntimeContext.getSessionID()); - = - runtimeContext.setSessionParams(sessionParams); - runtimeContext.setTemplates(V2V1Converter.toV2Templates(v1Runtime= Context.getTemplates())); - = - List extensions =3D v1RuntimeContext.getExtensions(); - if (extensions !=3D null) - { - runtimeContext.getExtensions().addAll(V2V1Converter.transform(= extensions, V1_TO_V2_EXTENSION)); - } - = - return runtimeContext; - } - else - { - return null; - } - } - - public static V1RuntimeContext toV1RuntimeContext(RuntimeContext runtim= eContext) - { - if (runtimeContext !=3D null) - { - V1RuntimeContext v1RuntimeContext =3D WSRP1TypeFactory.createRunt= imeContext(runtimeContext.getUserAuthentication()); - v1RuntimeContext.setNamespacePrefix(runtimeContext.getNamespacePr= efix()); - v1RuntimeContext.setPortletInstanceKey(runtimeContext.getPortletI= nstanceKey()); - v1RuntimeContext.setSessionID(runtimeContext.getSessionParams().g= etSessionID()); - v1RuntimeContext.setTemplates(V2V1Converter.toV1Templates(runtime= Context.getTemplates())); - = - List extensions =3D runtimeContext.getExtensions(); - if (extensions !=3D null) - { - v1RuntimeContext.getExtensions().addAll(V2V1Converter.transfor= m(extensions, V2_TO_V1_EXTENSION)); - } - = - return v1RuntimeContext; - } - else - { - return null; - } - } - = - public static V1Templates toV1Templates(Templates templates) - { - if (templates !=3D null) - { - //TODO: should we be using the WSRP1TypeFactory,createTemplates(P= ortletInvocationContext) instead? - V1Templates v1Templates =3D new V1Templates(); - v1Templates.setBlockingActionTemplate(templates.getBlockingAction= Template()); - v1Templates.setDefaultTemplate(templates.getDefaultTemplate()); - v1Templates.setRenderTemplate(templates.getRenderTemplate()); - v1Templates.setResourceTemplate(templates.getResourceTemplate()); - v1Templates.setSecureBlockingActionTemplate(templates.getSecureBl= ockingActionTemplate()); - v1Templates.setSecureRenderTemplate(templates.getSecureRenderTemp= late()); - v1Templates.setSecureResourceTemplate(templates.getSecureResource= Template()); - = - List extensions =3D templates.getExtensions(); - if (extensions !=3D null) - { - v1Templates.getExtensions().addAll(V2V1Converter.transform(ext= ensions, V2_TO_V1_EXTENSION)); - } - = - return v1Templates; - } - else - { - return null; - } - } - = - public static Templates toV2Templates(V1Templates v1Templates) - { - if (v1Templates !=3D null) - { - //TODO: should we be using the WSRP1TypeFactory,createTemplates(P= ortletInvocationContext) instead? - Templates templates =3D new Templates(); - templates.setBlockingActionTemplate(v1Templates.getBlockingAction= Template()); - templates.setDefaultTemplate(v1Templates.getDefaultTemplate()); - templates.setRenderTemplate(v1Templates.getRenderTemplate()); - templates.setResourceTemplate(v1Templates.getResourceTemplate()); - templates.setSecureBlockingActionTemplate(v1Templates.getSecureBl= ockingActionTemplate()); - templates.setSecureRenderTemplate(v1Templates.getSecureRenderTemp= late()); - templates.setSecureResourceTemplate(v1Templates.getSecureResource= Template()); - = - List extensions =3D v1Templates.getExtensions(); - if (extensions !=3D null) - { - templates.getExtensions().addAll(V2V1Converter.transform(exten= sions, V1_TO_V2_EXTENSION)); - } - = - return templates; - } - else - { - return null; - } - } - = - public static UserContext toV2UserContext(V1UserContext v1UserContext) - { - if (v1UserContext !=3D null) - { - UserContext userContext =3D WSRPTypeFactory.createUserContext(v1U= serContext.getUserContextKey()); - userContext.setProfile(toV2UserProfile(v1UserContext.getProfile()= )); - = - List extensions =3D v1UserContext.getExtensions(); - if (extensions !=3D null) - { - userContext.getExtensions().addAll(V2V1Converter.transform(ext= ensions, V1_TO_V2_EXTENSION)); - } - = - if (v1UserContext.getUserCategories() !=3D null) - { - userContext.getUserCategories().addAll(v1UserContext.getUserCa= tegories()); - } - = - return userContext; - } - else - { - return null; - } - } - - public static V1UserContext toV1UserContext(UserContext userContext) - { - if (userContext !=3D null) - { - V1UserContext v1UserContext =3D WSRP1TypeFactory.createUserContex= t(userContext.getUserContextKey()); - = - v1UserContext.setProfile(toV1UserProfile(userContext.getProfile()= )); - = - List extensions =3D userContext.getExtensions(); - if (extensions !=3D null) - { - v1UserContext.getExtensions().addAll(V2V1Converter.transform(e= xtensions, V2_TO_V1_EXTENSION)); - } - = - if (userContext.getUserCategories() !=3D null) - { - v1UserContext.getUserCategories().addAll(userContext.getUserCa= tegories()); - } - = - return v1UserContext; - } - else - { - return null; - } - } - = - public static V1UserProfile toV1UserProfile (UserProfile userProfile) - { - if (userProfile !=3D null) - { - V1UserProfile v1UserProfile =3D new V1UserProfile(); - v1UserProfile.setBdate(userProfile.getBdate()); - v1UserProfile.setBusinessInfo(toV1Context(userProfile.getBusiness= Info())); - v1UserProfile.setEmployerInfo(toV1EmployerInfo(userProfile.getEmp= loyerInfo())); - v1UserProfile.setGender(userProfile.getGender()); - v1UserProfile.setHomeInfo(toV1Context(userProfile.getHomeInfo())); - v1UserProfile.setName(toV1PersonName(userProfile.getName())); - = - return v1UserProfile; - } - else - { - return null; - } - } - = - public static UserProfile toV2UserProfile (V1UserProfile v1UserProfile) - { - if (v1UserProfile !=3D null) - { - UserProfile userProfile =3D new UserProfile(); - userProfile.setBdate(v1UserProfile.getBdate()); - userProfile.setBusinessInfo(toV2Context(v1UserProfile.getBusiness= Info())); - userProfile.setEmployerInfo(toV2EmployerInfo(v1UserProfile.getEmp= loyerInfo())); - userProfile.setGender(v1UserProfile.getGender()); - userProfile.setHomeInfo(toV2Context(v1UserProfile.getHomeInfo())); - userProfile.setName(toV2PersonName(v1UserProfile.getName())); - = - return userProfile; - } - else - { - return null; - } - } - = - public static V1EmployerInfo toV1EmployerInfo (EmployerInfo employerInf= o) - { - if (employerInfo !=3D null) - { - V1EmployerInfo v1EmployerInfo =3D new V1EmployerInfo(); - v1EmployerInfo.setDepartment(employerInfo.getDepartment()); - v1EmployerInfo.setEmployer(employerInfo.getEmployer()); - v1EmployerInfo.setJobtitle(employerInfo.getJobtitle()); - = - List extensions =3D employerInfo.getExtensions(); - if (extensions !=3D null) - { - v1EmployerInfo.getExtensions().addAll(V2V1Converter.transform(= extensions, V2_TO_V1_EXTENSION)); - } - - return v1EmployerInfo; - } - else - { - return null; - } - } - = - public static EmployerInfo toV2EmployerInfo (V1EmployerInfo v1EmployerI= nfo) - { - if (v1EmployerInfo !=3D null) - { - EmployerInfo employerInfo =3D new EmployerInfo(); - employerInfo.setDepartment(v1EmployerInfo.getDepartment()); - employerInfo.setEmployer(v1EmployerInfo.getEmployer()); - employerInfo.setJobtitle(v1EmployerInfo.getJobtitle()); - = - List extensions =3D v1EmployerInfo.getExtensions(); - if (extensions !=3D null) - { - employerInfo.getExtensions().addAll(V2V1Converter.transform(ex= tensions, V1_TO_V2_EXTENSION)); - } - - return employerInfo; - } - else - { - return null; - } - } - = - public static V1PersonName toV1PersonName (PersonName personName) - { - if (personName !=3D null) - { - V1PersonName v1PersonName =3D new V1PersonName(); - v1PersonName.setFamily(personName.getFamily()); - v1PersonName.setGiven(personName.getGiven()); - v1PersonName.setMiddle(personName.getMiddle()); - v1PersonName.setNickname(personName.getNickname()); - v1PersonName.setPrefix(personName.getPrefix()); - v1PersonName.setSuffix(personName.getSuffix()); - = - List extensions =3D personName.getExtensions(); - if (extensions !=3D null) - { - v1PersonName.getExtensions().addAll(V2V1Converter.transform(ex= tensions, V2_TO_V1_EXTENSION)); - } - = - return v1PersonName; - } - else - { - return null; - } - } - = - public static PersonName toV2PersonName (V1PersonName v1PersonName) - { - if (v1PersonName !=3D null) - { - PersonName personName =3D 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()); - = - List extensions =3D v1PersonName.getExtensions(); - if (extensions !=3D null) - { - personName.getExtensions().addAll(V2V1Converter.transform(exte= nsions, V1_TO_V2_EXTENSION)); - } - = - return personName; - } - else - { - return null; - } - } - = - public static V1Contact toV1Context (Contact contact) - { - if (contact !=3D null) - { - V1Contact v1Contact=3D new V1Contact(); - v1Contact.setOnline(toV1Online(contact.getOnline())); - v1Contact.setPostal(toV1Postal(contact.getPostal())); - v1Contact.setTelecom(toV1Telecom(contact.getTelecom())); - = - List extensions =3D contact.getExtensions(); - if (extensions !=3D null) - { - v1Contact.getExtensions().addAll(V2V1Converter.transform(exten= sions, V2_TO_V1_EXTENSION)); - } - = - return v1Contact; - } - else - { - return null; - } - } - = - public static Contact toV2Context (V1Contact v1Contact) - { - if (v1Contact !=3D null) - { - Contact contact=3D new Contact(); - contact.setOnline(toV2Online(v1Contact.getOnline())); - contact.setPostal(toV2Postal(v1Contact.getPostal())); - contact.setTelecom(toV2Telecom(v1Contact.getTelecom())); - = - List extensions =3D v1Contact.getExtensions(); - if (extensions !=3D null) - { - contact.getExtensions().addAll(V2V1Converter.transform(extensi= ons, V1_TO_V2_EXTENSION)); - } - = - return contact; - } - else - { - return null; - } - } - = - public static V1Online toV1Online (Online online) - { - if (online !=3D null) - { - V1Online v1Online =3D new V1Online(); - v1Online.setEmail(online.getEmail()); - v1Online.setUri(online.getUri()); - = - List extensions =3D online.getExtensions(); - if (extensions !=3D null) - { - v1Online.getExtensions().addAll(V2V1Converter.transform(extens= ions, V2_TO_V1_EXTENSION)); - } - = - return v1Online; - } - else - { - return null; - } - } - = - public static Online toV2Online (V1Online v1Online) - { - if (v1Online !=3D null) - { - Online online =3D new Online(); - online.setEmail(v1Online.getEmail()); - online.setUri(v1Online.getUri()); - = - List extensions =3D v1Online.getExtensions(); - if (extensions !=3D null) - { - online.getExtensions().addAll(V2V1Converter.transform(extensio= ns, V1_TO_V2_EXTENSION)); - } - = - return online; - } - else - { - return null; - } - } - = - public static V1Postal toV1Postal (Postal postal) - { - if (postal !=3D null) - { - V1Postal v1Postal =3D new V1Postal(); - v1Postal.setCity(postal.getCity()); - v1Postal.setCountry(postal.getCountry()); - v1Postal.setName(postal.getName()); - v1Postal.setOrganization(postal.getOrganization()); - v1Postal.setPostalcode(postal.getPostalcode()); - v1Postal.setStateprov(postal.getStateprov()); - v1Postal.setStreet(postal.getStreet()); - = - List extensions =3D postal.getExtensions(); - if (extensions !=3D null) - { - v1Postal.getExtensions().addAll(V2V1Converter.transform(extens= ions, V2_TO_V1_EXTENSION)); - } - = - return v1Postal; - } - else - { - return null; - } - } - = - public static Postal toV2Postal (V1Postal v1Postal) - { - if (v1Postal !=3D null) - { - Postal postal =3D 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()); - = - List extensions =3D v1Postal.getExtensions(); - if (extensions !=3D null) - { - postal.getExtensions().addAll(V2V1Converter.transform(extensio= ns, V1_TO_V2_EXTENSION)); - } - = - return postal; - } - else - { - return null; - } - } - = - public static V1Telecom toV1Telecom(Telecom telecom) - { - if (telecom !=3D null) - { - V1Telecom v1Telecom =3D new V1Telecom(); - v1Telecom.setFax(toV1TelephoneNum(telecom.getFax())); - v1Telecom.setMobile(toV1TelephoneNum(telecom.getMobile())); - v1Telecom.setPager(toV1TelephoneNum(telecom.getPager())); - v1Telecom.setTelephone(toV1TelephoneNum(telecom.getTelephone())); - = - List extensions =3D telecom.getExtensions(); - if (extensions !=3D null) - { - v1Telecom.getExtensions().addAll(V2V1Converter.transform(exten= sions, V2_TO_V1_EXTENSION)); - } - = - return v1Telecom; - } - else - { - return null; - } - } - = - public static Telecom toV2Telecom(V1Telecom v1Telecom) - { - if (v1Telecom !=3D null) - { - Telecom telecom =3D new Telecom(); - telecom.setFax(toV2TelephoneNum(v1Telecom.getFax())); - telecom.setMobile(toV2TelephoneNum(v1Telecom.getMobile())); - telecom.setPager(toV2TelephoneNum(v1Telecom.getPager())); - telecom.setTelephone(toV2TelephoneNum(v1Telecom.getTelephone())); - = - List extensions =3D v1Telecom.getExtensions(); - if (extensions !=3D null) - { - telecom.getExtensions().addAll(V2V1Converter.transform(extensi= ons, V1_TO_V2_EXTENSION)); - } - = - return telecom; - } - else - { - return null; - } - } - = - public static V1TelephoneNum toV1TelephoneNum (TelephoneNum telephoneNu= m) - { - if (telephoneNum !=3D null) - { - V1TelephoneNum v1TelephoneNum =3D new V1TelephoneNum(); - v1TelephoneNum.setComment(telephoneNum.getComment()); - v1TelephoneNum.setExt(telephoneNum.getExt()); - v1TelephoneNum.setIntcode(telephoneNum.getIntcode()); - v1TelephoneNum.setLoccode(telephoneNum.getLoccode()); - v1TelephoneNum.setNumber(telephoneNum.getNumber()); - = - List extensions =3D telephoneNum.getExtensions(); - if (extensions !=3D null) - { - v1TelephoneNum.getExtensions().addAll(V2V1Converter.transform(= extensions, V2_TO_V1_EXTENSION)); - } - = - return v1TelephoneNum; - } - else - { - return null; - } - } - = - public static TelephoneNum toV2TelephoneNum (V1TelephoneNum v1Telephone= Num) - { - if (v1TelephoneNum !=3D null) - { - TelephoneNum telephoneNum =3D new TelephoneNum(); - telephoneNum.setComment(v1TelephoneNum.getComment()); - telephoneNum.setExt(v1TelephoneNum.getExt()); - telephoneNum.setIntcode(v1TelephoneNum.getIntcode()); - telephoneNum.setLoccode(v1TelephoneNum.getLoccode()); - telephoneNum.setNumber(v1TelephoneNum.getNumber()); - = - List extensions =3D v1TelephoneNum.getExtensions(); - if (extensions !=3D null) - { - telephoneNum.getExtensions().addAll(V2V1Converter.transform(ex= tensions, V1_TO_V2_EXTENSION)); - } - = - return telephoneNum; - } - else - { - return null; - } - } - = - public static V1MarkupContext toV1MarkupContext(MarkupContext markupCon= text) - { - if (markupContext !=3D null) - { - V1MarkupContext v1MarkupContext =3D new V1MarkupContext(); - v1MarkupContext.setMarkupBinary(markupContext.getItemBinary()); - v1MarkupContext.setMarkupString(markupContext.getItemString()); - v1MarkupContext.setCacheControl(toV1CacheControl(markupContext.ge= tCacheControl())); - v1MarkupContext.setLocale(markupContext.getLocale()); - v1MarkupContext.setMimeType(markupContext.getMimeType()); - v1MarkupContext.setPreferredTitle(markupContext.getPreferredTitle= ()); - v1MarkupContext.setRequiresUrlRewriting(markupContext.isRequiresR= ewriting()); - v1MarkupContext.setUseCachedMarkup(markupContext.isUseCachedItem(= )); - = - List extensions =3D markupContext.getExtensions(); - if (extensions !=3D null) - { - v1MarkupContext.getExtensions().addAll(V2V1Converter.transform= (extensions, V2_TO_V1_EXTENSION)); - } - = - return v1MarkupContext; - } - else - { - return null; - } - } - = - public static V1CacheControl toV1CacheControl(CacheControl cacheControl) - { - if (cacheControl !=3D null) - { - V1CacheControl v1CacheControl =3D WSRP1TypeFactory.createCacheCon= trol(cacheControl.getExpires(), cacheControl.getUserScope()); - v1CacheControl.setValidateTag(cacheControl.getValidateTag()); - = - List extensions =3D cacheControl.getExtensions(); - if (extensions !=3D null) - { - v1CacheControl.getExtensions().addAll(V2V1Converter.transform(= extensions, V2_TO_V1_EXTENSION)); - } - - return v1CacheControl; - } - else - { - return null; - } - } - - public static ServiceDescription toV2ServiceDescription(V1ServiceDescri= ption v1ServiceDescription) - { - throw new NotYetImplemented(); - } - - public static V1RegistrationContext toV1RegistrationContext(Registratio= nContext registrationContext) - { - if (registrationContext !=3D null) - { - V1RegistrationContext result =3D WSRP1TypeFactory.createRegistrat= ionContext(registrationContext.getRegistrationHandle()); - result.setRegistrationState(registrationContext.getRegistrationSt= ate()); - List extensions =3D V2V1Converter.transform(registra= tionContext.getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - return result; - } - else - { - return null; - } - } - - public static E toV2Exception(Class v2Exceptio= nClass, Exception v1Exception) - { - if (!"org.oasis.wsrp.v2".equals(v2ExceptionClass.getPackage().getNam= e())) - { - throw new IllegalArgumentException("Specified exception class is = not a WSRP 2 exception: " + v2ExceptionClass); - } - - Class v1ExceptionClass =3D v1Exception.getClass= (); - String v1Name =3D v1ExceptionClass.getSimpleName(); - int v1Index =3D v1Name.indexOf("V1"); - if (v1Index !=3D 0 && !"org.oasis.wsrp.v1".equals(v1ExceptionClass.g= etPackage().getName())) - { - throw new IllegalArgumentException("Specified exception is not a = WSRP 1 exception: " + v1Exception); - } - - String v2Name =3D v2ExceptionClass.getSimpleName(); - // V2 class name should match V1 class name minus "V1" - if (!v2Name.equals(v1Name.substring(2))) - { - throw new IllegalArgumentException("Exception names do not match.= Requested: " + v2Name - + ", was given: " + v1Name); - } - - return WSRPExceptionFactory.createWSException(v2ExceptionClass, v1Ex= ception.getMessage(), v1Exception.getCause()); - } - - public static E toV1Exception(Class v1Exceptio= nClass, Exception v2Exception) - { - if (!"org.oasis.wsrp.v1".equals(v1ExceptionClass.getPackage().getNam= e())) - { - throw new IllegalArgumentException("Specified exception class is = not a WSRP 1 exception: " + v1ExceptionClass); - } - - Class v2ExceptionClass =3D v2Exception.getClass= (); - String v1Name =3D v2ExceptionClass.getSimpleName(); - if (!"org.oasis.wsrp.v2".equals(v2ExceptionClass.getPackage().getNam= e())) - { - throw new IllegalArgumentException("Specified exception is not a = WSRP 2 exception: " + v2Exception); - } - - String v2Name =3D v2ExceptionClass.getSimpleName(); - // V1 class name should match V2 class name plus "V1" - if (!v2Name.equals(v1Name.substring(2))) - { - throw new IllegalArgumentException("Exception names do not match.= Requested: " + v1Name - + ", was given: " + v2Name); - } - - return WSRP1ExceptionFactory.createWSException(v1ExceptionClass, v2E= xception.getMessage(), v2Exception.getCause()); - } - - public static V1CookieProtocol toV1CookieProtocol(CookieProtocol requir= esInitCookie) - { - if (requiresInitCookie !=3D null) - { - return V1CookieProtocol.fromValue(requiresInitCookie.value()); - } - else - { - return null; - } - } - - public static V1ModelDescription toV1ModelDescription(ModelDescription = modelDescription) - { - if (modelDescription !=3D null) - { - V1ModelDescription result =3D WSRP1TypeFactory.createModelDescrip= tion(V2V1Converter.transform(modelDescription.getPropertyDescriptions(), V2= _TO_V1_PROPERTYDESCRIPTION)); - List extensions =3D V2V1Converter.transform(modelDes= cription.getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - result.setModelTypes(toV1ModelTypes(modelDescription.getModelType= s())); - - return result; - } - else - { - return null; - } - } - - public static V1ModelTypes toV1ModelTypes(ModelTypes modelTypes) - { - if (modelTypes !=3D null) - { - V1ModelTypes result =3D new V1ModelTypes(); - result.setAny(modelTypes.getAny()); - return result; - } - else - { - return null; - } - } - - public static V1ResourceList toV1ResourceList(ResourceList resourceList) - { - if (resourceList !=3D null) - { - V1ResourceList result =3D new V1ResourceList(); - List extensions =3D V2V1Converter.transform(resource= List.getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - List v1Resources =3D V2V1Converter.transform(resource= List.getResources(), V2_TO_V1_RESOURCE); - if (v1Resources !=3D null) - { - result.getResources().addAll(v1Resources); - } - return result; - } - else - { - return null; - } - } - - public static InteractionParams toV2InteractionParams(V1InteractionPara= ms v1InteractionParams) - { - if (v1InteractionParams !=3D null) - { - InteractionParams interactionParams =3D WSRPTypeFactory.createInt= eractionParams(toV2StateChange(v1InteractionParams.getPortletStateChange())= ); - interactionParams.setInteractionState(v1InteractionParams.getInte= ractionState()); - interactionParams.getExtensions().addAll(Lists.transform(v1Intera= ctionParams.getExtensions(), V1_TO_V2_EXTENSION)); - interactionParams.getFormParameters().addAll(Lists.transform(v1In= teractionParams.getFormParameters(), V1_TO_V2_NAMEDSTRING)); - interactionParams.getUploadContexts().addAll(Lists.transform(v1In= teractionParams.getUploadContexts(), V1_TO_V2_UPLOADCONTEXT)); - - return interactionParams; - } - else - { - return null; - } - } - = - public static V1InteractionParams toV1InteractionParams(InteractionPara= ms interactionParams) - { - if (interactionParams !=3D null) - { - V1InteractionParams v1InteractionParams =3D WSRP1TypeFactory.crea= teInteractionParams(toV1StateChange(interactionParams.getPortletStateChange= ())); - v1InteractionParams.setInteractionState(interactionParams.getInte= ractionState()); - = - List extensions =3D interactionParams.getExtensions(); - if (extensions !=3D null) - { - v1InteractionParams.getExtensions().addAll(Lists.transform(ext= ensions, V2_TO_V1_EXTENSION)); - } - = - List formParameters =3D interactionParams.getFormPar= ameters(); - if (formParameters !=3D null) - { - v1InteractionParams.getFormParameters().addAll(Lists.transform= (formParameters, V2_TO_V1_NAMEDSTRING)); - } - = - List uploadContext =3D interactionParams.getUpload= Contexts(); - if (uploadContext !=3D null) - { - v1InteractionParams.getUploadContexts().addAll(Lists.transform= (uploadContext, V2_TO_V1_UPLOADCONTEXT)); - } - = - return v1InteractionParams; - } - else - { - return null; - } - } - = - - public static StateChange toV2StateChange(V1StateChange v1StateChange) - { - if (v1StateChange !=3D null) - { - return StateChange.valueOf((v1StateChange.value())); - } - else - { - return null; - } - } - = - public static V1StateChange toV1StateChange(StateChange stateChange) - { - if (stateChange !=3D null) - { - return V1StateChange.valueOf(stateChange.value()); - } - else - { - return null; - } - } - - public static V1UpdateResponse toV1UpdateResponse(UpdateResponse update= Response) - { - if (updateResponse !=3D null) - { - V1UpdateResponse v1UpdateResponse =3D WSRP1TypeFactory.createUpda= teResponse(); - v1UpdateResponse.setMarkupContext(toV1MarkupContext(updateRespons= e.getMarkupContext())); - v1UpdateResponse.setNavigationalState(updateResponse.getNavigatio= nalContext().getOpaqueValue()); - v1UpdateResponse.setNewWindowState(updateResponse.getNewWindowSta= te()); - v1UpdateResponse.setPortletContext(toV1PortletContext(updateRespo= nse.getPortletContext())); - v1UpdateResponse.setSessionContext(toV1SessionContext(updateRespo= nse.getSessionContext())); - v1UpdateResponse.setNewMode(updateResponse.getNewMode()); - return v1UpdateResponse; - } - else - { - return null; - } - } - - public static V1LocalizedString toV1LocalizedString(LocalizedString loc= alizedString) - { - return V2_TO_V1_LOCALIZEDSTRING.apply(localizedString); - } - - public static V1SessionContext toV1SessionContext(SessionContext sessio= nContext) - { - if (sessionContext !=3D null) - { - V1SessionContext v1SessionContext =3D WSRP1TypeFactory.createSess= ionContext(sessionContext.getSessionID(), sessionContext.getExpires().intVa= lue()); - v1SessionContext.getExtensions().addAll(Lists.transform(sessionCo= ntext.getExtensions(), V2_TO_V1_EXTENSION)); - - return v1SessionContext; - } - else - { - return null; - } - } - - public static LocalizedString toV2LocalizedString(V1LocalizedString loc= alizedString) - { - return V1_TO_V2_LOCALIZEDSTRING.apply(localizedString); - } - - public static CookieProtocol toV2CookieProtocol(V1CookieProtocol v1Cook= ieProtocol) - { - if (v1CookieProtocol !=3D null) - { - return CookieProtocol.fromValue(v1CookieProtocol.value()); - } - else - { - return null; - } - } - - public static ModelDescription toV2ModelDescription(V1ModelDescription = v1ModelDescription) - { - if (v1ModelDescription !=3D null) - { - ModelDescription result =3D WSRPTypeFactory.createModelDescriptio= n(V2V1Converter.transform(v1ModelDescription.getPropertyDescriptions(), V1_= TO_V2_PROPERTYDESCRIPTION)); - List extensions =3D V2V1Converter.transform(v1ModelDes= cription.getExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - result.setModelTypes(toV2ModelTypes(v1ModelDescription.getModelTy= pes())); - - return result; - } - else - { - return null; - } - } - - private static ModelTypes toV2ModelTypes(V1ModelTypes modelTypes) - { - if (modelTypes !=3D null) - { - ModelTypes result =3D new ModelTypes(); - result.setAny(modelTypes.getAny()); - return result; - } - else - { - return null; - } - } - - public static ResourceList toV2ResourceList(V1ResourceList v1ResourceLi= st) - { - if (v1ResourceList !=3D null) - { - ResourceList result =3D new ResourceList(); - - List extensions =3D V2V1Converter.transform(v1Resource= List.getExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - List resources =3D V2V1Converter.transform(v1ResourceLi= st.getResources(), V1_TO_V2_RESOURCE); - if (resources !=3D null) - { - result.getResources().addAll(resources); - } - - return result; - } - else - { - return null; - } - } - - private static class V1ToV2Extension implements Function - { - public Extension apply(V1Extension from) - { - if (from !=3D null) - { - Extension extension =3D new Extension(); - extension.setAny(from.getAny()); - return extension; - } - else - { - return null; - } - } - } - - private static class V2ToV1Extension implements Function - { - public V1Extension apply(Extension from) - { - if (from !=3D null) - { - V1Extension extension =3D new V1Extension(); - extension.setAny(from.getAny()); - return extension; - } - else - { - return null; - } - } - } - - private static class V2ToV1PortletDescription implements Function - { - - public V1PortletDescription apply(PortletDescription from) - { - if (from !=3D null) - { - V1PortletDescription result =3D WSRP1TypeFactory.createPortlet= Description(from.getPortletHandle(), - V2V1Converter.transform(from.getMarkupTypes(), V2_TO_V1_MAR= KUPTYPE)); - result.setDescription(V2_TO_V1_LOCALIZEDSTRING.apply(from.getD= escription())); - result.setDisplayName(V2_TO_V1_LOCALIZEDSTRING.apply(from.getD= isplayName())); - List extensions =3D V2V1Converter.transform(from.= getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - List keywords =3D V2V1Converter.transform(f= rom.getKeywords(), V2_TO_V1_LOCALIZEDSTRING); - if (keywords !=3D null) - { - result.getKeywords().addAll(keywords); - } - List userCategories =3D from.getUserCategories(); - if (userCategories !=3D null) - { - result.getUserCategories().addAll(userCategories); - } - List userProfileItems =3D from.getUserProfileItems(); - if (userProfileItems !=3D null) - { - result.getUserProfileItems().addAll(userProfileItems); - } - result.setDefaultMarkupSecure(from.isDefaultMarkupSecure()); - result.setDoesUrlTemplateProcessing(from.isDoesUrlTemplateProc= essing()); - result.setTemplatesStoredInSession(from.isTemplatesStoredInSes= sion()); - result.setHasUserSpecificState(from.isHasUserSpecificState()); - result.setOnlySecure(from.isOnlySecure()); - result.setUserContextStoredInSession(from.isUserContextStoredI= nSession()); - result.setUsesMethodGet(from.isUsesMethodGet()); - result.setShortTitle(V2_TO_V1_LOCALIZEDSTRING.apply(from.getSh= ortTitle())); - result.setTitle(V2_TO_V1_LOCALIZEDSTRING.apply(from.getTitle()= )); - - result.setGroupID(from.getGroupID()); - return result; - } - else - { - return null; - } - } - } - - private static class V1ToV2PortletDescription implements Function - { - - public PortletDescription apply(V1PortletDescription from) - { - if (from !=3D null) - { - PortletDescription result =3D WSRPTypeFactory.createPortletDes= cription(from.getPortletHandle(), - V2V1Converter.transform(from.getMarkupTypes(), V1_TO_V2_MAR= KUPTYPE)); - result.setDescription(V1_TO_V2_LOCALIZEDSTRING.apply(from.getD= escription())); - result.setDisplayName(V1_TO_V2_LOCALIZEDSTRING.apply(from.getD= isplayName())); - List extensions =3D V2V1Converter.transform(from.ge= tExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - List keywords =3D V2V1Converter.transform(fro= m.getKeywords(), V1_TO_V2_LOCALIZEDSTRING); - if (keywords !=3D null) - { - result.getKeywords().addAll(keywords); - } - List userCategories =3D from.getUserCategories(); - if (userCategories !=3D null) - { - result.getUserCategories().addAll(userCategories); - } - List userProfileItems =3D from.getUserProfileItems(); - if (userProfileItems !=3D null) - { - result.getUserProfileItems().addAll(userProfileItems); - } - result.setDefaultMarkupSecure(from.isDefaultMarkupSecure()); - result.setDoesUrlTemplateProcessing(from.isDoesUrlTemplateProc= essing()); - result.setTemplatesStoredInSession(from.isTemplatesStoredInSes= sion()); - result.setHasUserSpecificState(from.isHasUserSpecificState()); - result.setOnlySecure(from.isOnlySecure()); - result.setUserContextStoredInSession(from.isUserContextStoredI= nSession()); - result.setUsesMethodGet(from.isUsesMethodGet()); - result.setShortTitle(V1_TO_V2_LOCALIZEDSTRING.apply(from.getSh= ortTitle())); - result.setTitle(V1_TO_V2_LOCALIZEDSTRING.apply(from.getTitle()= )); - - result.setGroupID(from.getGroupID()); - return result; - } - else - { - return null; - } - } - } - - private static class V2ToV1ItemDescription implements Function - { - - public V1ItemDescription apply(ItemDescription from) - { - if (from !=3D null) - { - V1ItemDescription result =3D new V1ItemDescription(); - result.setItemName(from.getItemName()); - result.setDescription(V2_TO_V1_LOCALIZEDSTRING.apply(from.getD= escription())); - List extensions =3D V2V1Converter.transform(from.= getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - return result; - } - else - { - return null; - } - } - } - - private static class V1ToV2ItemDescription implements Function - { - - public ItemDescription apply(V1ItemDescription from) - { - if (from !=3D null) - { - ItemDescription result =3D new ItemDescription(); - result.setItemName(from.getItemName()); - result.setDescription(V1_TO_V2_LOCALIZEDSTRING.apply(from.getD= escription())); - List extensions =3D V2V1Converter.transform(from.ge= tExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - return result; - } - else - { - return null; - } - } - } - - - public static class V1ToV2NamedString implements Function - { - public NamedString apply(V1NamedString v1NamedString) - { - if (v1NamedString !=3D null) - { - NamedString result =3D new NamedString(); - result.setName(v1NamedString.getName()); - result.setValue(v1NamedString.getValue()); - return result; - } - else - { - return null; - } - } - } - - public static class V2ToV1NamedString implements Function - { - public V1NamedString apply(NamedString namedString) - { - if (namedString !=3D null) - { - V1NamedString result =3D new V1NamedString(); - result.setName(namedString.getName()); - result.setValue(namedString.getValue()); - return result; - } - else - { - return null; - } - } - } - = - public static class V1ToV2UploadContext implements Function - { - - public UploadContext apply(V1UploadContext v1UploadContext) - { - if (v1UploadContext !=3D null) - { - UploadContext result =3D WSRPTypeFactory.createUploadContext(v= 1UploadContext.getMimeType(), v1UploadContext.getUploadData()); - result.getExtensions().addAll(Lists.transform(v1UploadContext.= getExtensions(), V1_TO_V2_EXTENSION)); - result.getMimeAttributes().addAll(Lists.transform(v1UploadCont= ext.getMimeAttributes(), V1_TO_V2_NAMEDSTRING)); - - return result; - } - else - { - return null; - } - } - - } - = - public static class V2ToV1UploadContext implements Function - { - - public V1UploadContext apply(UploadContext uploadContext) - { - if (uploadContext !=3D null) - { - V1UploadContext result =3D WSRP1TypeFactory.createUploadContex= t(uploadContext.getMimeType(), uploadContext.getUploadData()); - = - List extensions =3D uploadContext.getExtensions(); - if (extensions !=3D null) - { - result.getExtensions().addAll(Lists.transform(extensions, V= 2_TO_V1_EXTENSION)); - } - = - List mimeAttributes =3D uploadContext.getMimeAttr= ibutes(); - if (mimeAttributes !=3D null) - { - result.getMimeAttributes().addAll(Lists.transform(mimeAttri= butes, V2_TO_V1_NAMEDSTRING)); - } - = - return result; - } - else - { - return null; - } - } - = - } - - private static class V2ToV1MarkupType implements Function - { - - public V1MarkupType apply(MarkupType from) - { - if (from !=3D null) - { - V1MarkupType result =3D WSRP1TypeFactory.createMarkupType(from= .getMimeType(), from.getModes(), from.getWindowStates(), from.getLocales()); - List extensions =3D V2V1Converter.transform(from.= getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - } - - private static class V1ToV2MarkupType implements Function - { - - public MarkupType apply(V1MarkupType from) - { - if (from !=3D null) - { - MarkupType result =3D WSRPTypeFactory.createMarkupType(from.ge= tMimeType(), from.getModes(), from.getWindowStates(), from.getLocales()); - List extensions =3D V2V1Converter.transform(from.ge= tExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - } - - private static class V2ToV1LocalizedString implements Function - { - - public V1LocalizedString apply(LocalizedString from) - { - if (from !=3D null) - { - return WSRP1TypeFactory.createLocalizedString(from.getLang(), = from.getResourceName(), from.getValue()); - } - else - { - return null; - } - - } - } - - private static class V1ToV2LocalizedString implements Function - { - - public LocalizedString apply(V1LocalizedString from) - { - if (from !=3D null) - { - return WSRPTypeFactory.createLocalizedString(from.getLang(), f= rom.getResourceName(), from.getValue()); - } - else - { - return null; - } - - } - } - - private static class V2ToV1PropertyDescription implements Function - { - - public V1PropertyDescription apply(PropertyDescription from) - { - if (from !=3D null) - { - V1PropertyDescription result =3D WSRP1TypeFactory.createProper= tyDescription(from.getName().toString(), from.getType()); - result.setHint(toV1LocalizedString(from.getHint())); - result.setLabel(toV1LocalizedString(from.getLabel())); - List extensions =3D V2V1Converter.transform(from.= getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - } - - private static class V2ToV1Resource implements Function - { - public V1Resource apply(Resource from) - { - if (from !=3D null) - { - V1Resource result =3D new V1Resource(); - result.setResourceName(from.getResourceName()); - List values =3D V2V1Converter.transform(from.= getValues(), V2_TO_V1_RESOURCEVALUE); - if (values !=3D null) - { - result.getValues().addAll(values); - } - - return result; - } - else - { - return null; - } - } - - } - - private static class V2ToV1ResourceValue implements Function - { - public V1ResourceValue apply(ResourceValue from) - { - if (from !=3D null) - { - V1ResourceValue result =3D new V1ResourceValue(); - result.setLang(from.getLang()); - result.setValue(from.getValue()); - List extensions =3D V2V1Converter.transform(from.= getExtensions(), V2_TO_V1_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - } - - private static class V1ToV2Resource implements Function - { - public Resource apply(V1Resource from) - { - if (from !=3D null) - { - Resource result =3D new Resource(); - result.setResourceName(from.getResourceName()); - List values =3D V2V1Converter.transform(from.ge= tValues(), V1_TO_V2_RESOURCEVALUE); - if (values !=3D null) - { - result.getValues().addAll(values); - } - - return result; - } - else - { - return null; - } - } - - } - - private static class V1ToV2ResourceValue implements Function - { - public ResourceValue apply(V1ResourceValue from) - { - if (from !=3D null) - { - ResourceValue result =3D new ResourceValue(); - result.setLang(from.getLang()); - result.setValue(from.getValue()); - List extensions =3D V2V1Converter.transform(from.ge= tExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - } - - private static class V1ToV2PropertyDescription implements Function - { - public PropertyDescription apply(V1PropertyDescription from) - { - if (from !=3D null) - { - PropertyDescription result =3D WSRPTypeFactory.createPropertyD= escription(from.getName(), from.getType()); - result.setHint(toV2LocalizedString(from.getHint())); - result.setLabel(toV2LocalizedString(from.getLabel())); - List extensions =3D V2V1Converter.transform(from.ge= tExtensions(), V1_TO_V2_EXTENSION); - if (extensions !=3D null) - { - result.getExtensions().addAll(extensions); - } - - return result; - } - else - { - return null; - } - } - } -} Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v= 1/WSRP1TypeFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP= 1TypeFactory.java 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/WSRP= 1TypeFactory.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -314,7 +314,7 @@ */ public static V1PortletDescription createPortletDescription(org.gatein.= pc.api.PortletContext portletContext, List markupTypes) { - V1PortletContext context =3D V2V1Converter.toV1PortletContext(WSRPUt= ils.convertToWSRPPortletContext(portletContext)); + V1PortletContext context =3D V2ToV1Converter.toV1PortletContext(WSRP= Utils.convertToWSRPPortletContext(portletContext)); = ParameterValidation.throwIllegalArgExceptionIfNull(markupTypes, "Mar= kupType"); if (markupTypes.isEmpty()) Modified: components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v= 1/V2V1ConverterTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1= ConverterTestCase.java 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1= ConverterTestCase.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -1,24 +1,25 @@ /* -* JBoss, a division of Red Hat -* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as = indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ + * JBoss, a division of Red Hat + * Copyright 2010, Red Hat Middleware, LLC, and individual + * contributors as indicated by the @authors tag. See the + * copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = package org.gatein.wsrp.spec.v1; = @@ -38,7 +39,7 @@ { Throwable throwable =3D new Throwable(); V1OperationFailed v1OF =3D new V1OperationFailed("foo", new V1Operat= ionFailedFault(), throwable); - OperationFailed operationFailed =3D V2V1Converter.toV2Exception(Oper= ationFailed.class, v1OF); + OperationFailed operationFailed =3D V1ToV2Converter.toV2Exception(Op= erationFailed.class, v1OF); assertNotNull(operationFailed); assertEquals("foo", operationFailed.getMessage()); assertEquals(throwable, operationFailed.getCause()); @@ -51,7 +52,7 @@ = try { - V2V1Converter.toV2Exception(InvalidSession.class, v1OF); + V1ToV2Converter.toV2Exception(InvalidSession.class, v1OF); fail("Should have failed as requested v2 exception doesn't match = specified v1"); } catch (IllegalArgumentException e) @@ -67,7 +68,7 @@ = try { - V2V1Converter.toV2Exception(IllegalArgumentException.class, v1OF); + V1ToV2Converter.toV2Exception(IllegalArgumentException.class, v1O= F); fail("Should have failed as requested exception is not a WSRP 2 e= xception class"); } catch (IllegalArgumentException e) @@ -80,7 +81,7 @@ { try { - V2V1Converter.toV2Exception(OperationFailed.class, new IllegalArg= umentException()); + V1ToV2Converter.toV2Exception(OperationFailed.class, new IllegalA= rgumentException()); fail("Should have failed as specified exception is not a WSRP 1 e= xception"); } catch (IllegalArgumentException e) Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/serv= ices/v1/V1MarkupService.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v= 1/V1MarkupService.java 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v= 1/V1MarkupService.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -1,30 +1,33 @@ /* -* JBoss, a division of Red Hat -* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as = indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ + * JBoss, a division of Red Hat + * Copyright 2010, Red Hat Middleware, LLC, and individual + * contributors as indicated by the @authors tag. See the + * copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = package org.gatein.wsrp.services.v1; = import org.gatein.common.NotYetImplemented; +import org.gatein.wsrp.WSRPUtils; import org.gatein.wsrp.services.MarkupService; -import org.gatein.wsrp.spec.v1.V2V1Converter; +import org.gatein.wsrp.spec.v1.V1ToV2Converter; +import org.gatein.wsrp.spec.v1.V2ToV1Converter; import org.oasis.wsrp.v1.V1AccessDenied; import org.oasis.wsrp.v1.V1Extension; import org.oasis.wsrp.v1.V1InconsistentParameters; @@ -95,75 +98,75 @@ { try { - service.getMarkup( - V2V1Converter.toV1RegistrationContext(registrationContext), - V2V1Converter.toV1PortletContext(portletContext), - V2V1Converter.toV1RuntimeContext(runtimeContext), - V2V1Converter.toV1UserContext(userContext), - V2V1Converter.toV1MarkupParams(markupParams), - new Holder(V2V1Converter.toV1MarkupContext(= markupContext.value)), - new Holder(V2V1Converter.toV1SessionContex= t(sessionContext.value)), - new Holder>(V2V1Converter.transform(extens= ions.value, V2V1Converter.V2_TO_V1_EXTENSION))); + service.getMarkup( + V2ToV1Converter.toV1RegistrationContext(registrationContext), + V2ToV1Converter.toV1PortletContext(portletContext), + V2ToV1Converter.toV1RuntimeContext(runtimeContext), + V2ToV1Converter.toV1UserContext(userContext), + V2ToV1Converter.toV1MarkupParams(markupParams), + new Holder(V2ToV1Converter.toV1MarkupContext(= markupContext.value)), + new Holder(V2ToV1Converter.toV1SessionContex= t(sessionContext.value)), + new Holder>(WSRPUtils.transform(extensions.v= alue, V2ToV1Converter.EXTENSION))); } catch (V1AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(AccessDenied.class, accessDenie= d); + throw V2ToV1Converter.toV1Exception(AccessDenied.class, accessDen= ied); } catch (V1InconsistentParameters inconsistentParameters) { - throw V2V1Converter.toV1Exception(InconsistentParameters.class, i= nconsistentParameters); + throw V2ToV1Converter.toV1Exception(InconsistentParameters.class,= inconsistentParameters); } catch (V1InvalidCookie invalidCookie) { - throw V2V1Converter.toV1Exception(InvalidCookie.class, invalidCoo= kie); + throw V2ToV1Converter.toV1Exception(InvalidCookie.class, invalidC= ookie); } catch (V1InvalidHandle invalidHandle) { - throw V2V1Converter.toV1Exception(InvalidHandle.class, invalidHan= dle); + throw V2ToV1Converter.toV1Exception(InvalidHandle.class, invalidH= andle); } catch (V1InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(InvalidRegistration.class, inva= lidRegistration); + throw V2ToV1Converter.toV1Exception(InvalidRegistration.class, in= validRegistration); } catch (V1InvalidSession invalidSession) { - throw V2V1Converter.toV1Exception(InvalidSession.class, invalidSe= ssion); + throw V2ToV1Converter.toV1Exception(InvalidSession.class, invalid= Session); } catch (V1InvalidUserCategory invalidUserCategory) { - throw V2V1Converter.toV1Exception(InvalidUserCategory.class, inva= lidUserCategory); + throw V2ToV1Converter.toV1Exception(InvalidUserCategory.class, in= validUserCategory); } catch (V1MissingParameters missingParameter) { - throw V2V1Converter.toV1Exception(MissingParameters.class, missin= gParameter); + throw V2ToV1Converter.toV1Exception(MissingParameters.class, miss= ingParameter); } catch (V1OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(OperationFailed.class, operatio= nFailed); + throw V2ToV1Converter.toV1Exception(OperationFailed.class, operat= ionFailed); } catch (V1UnsupportedLocale unsupportedLocale) { - throw V2V1Converter.toV1Exception(UnsupportedLocale.class, unsupp= ortedLocale); + throw V2ToV1Converter.toV1Exception(UnsupportedLocale.class, unsu= pportedLocale); } catch (V1UnsupportedMimeType unsupportedMimeType) { - throw V2V1Converter.toV1Exception(UnsupportedMimeType.class, unsu= pportedMimeType); + throw V2ToV1Converter.toV1Exception(UnsupportedMimeType.class, un= supportedMimeType); } catch (V1UnsupportedMode unsupportedMode) { - throw V2V1Converter.toV1Exception(UnsupportedMode.class, unsuppor= tedMode); + throw V2ToV1Converter.toV1Exception(UnsupportedMode.class, unsupp= ortedMode); } catch (V1UnsupportedWindowState unsupportedWindowState) { - throw V2V1Converter.toV1Exception(UnsupportedWindowState.class, u= nsupportedWindowState); + throw V2ToV1Converter.toV1Exception(UnsupportedWindowState.class,= unsupportedWindowState); } - = + } = @Override public void getResource(RegistrationContext registrationContext, Holder= portletContext, RuntimeContext runtimeContext, UserContext= userContext, ResourceParams resourceParams, Holder resour= ceContext, Holder sessionContext, Holder> e= xtensions) throws AccessDenied, InconsistentParameters, InvalidCookie, Inva= lidHandle, InvalidRegistration, InvalidSession, InvalidUserCategory, Missin= gParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSuppo= rted, ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, Unsupporte= dMode, UnsupportedWindowState { - = + throw new NotYetImplemented(); } = @@ -173,71 +176,71 @@ try { service.performBlockingInteraction( - V2V1Converter.toV1RegistrationContext(registrationContext), = - V2V1Converter.toV1PortletContext(portletContext), - V2V1Converter.toV1RuntimeContext(runtimeContext), - V2V1Converter.toV1UserContext(userContext), - V2V1Converter.toV1MarkupParams(markupParams), - V2V1Converter.toV1InteractionParams(interactionParams), - new Holder(V2V1Converter.toV1UpdateRespon= se(updateResponse.value)), - redirectURL, = - new Holder>(V2V1Converter.transform(exten= sions.value, V2V1Converter.V2_TO_V1_EXTENSION))); + V2ToV1Converter.toV1RegistrationContext(registrationContext), + V2ToV1Converter.toV1PortletContext(portletContext), + V2ToV1Converter.toV1RuntimeContext(runtimeContext), + V2ToV1Converter.toV1UserContext(userContext), + V2ToV1Converter.toV1MarkupParams(markupParams), + V2ToV1Converter.toV1InteractionParams(interactionParams), + new Holder(V2ToV1Converter.toV1UpdateRespons= e(updateResponse.value)), + redirectURL, + new Holder>(WSRPUtils.transform(extensions.v= alue, V2ToV1Converter.EXTENSION))); } catch (V1AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(AccessDenied.class, accessDenie= d); + throw V2ToV1Converter.toV1Exception(AccessDenied.class, accessDen= ied); } catch (V1InconsistentParameters inconsistentParameters) { - throw V2V1Converter.toV1Exception(InconsistentParameters.class, i= nconsistentParameters); + throw V2ToV1Converter.toV1Exception(InconsistentParameters.class,= inconsistentParameters); } catch (V1InvalidCookie invalidCookie) { - throw V2V1Converter.toV1Exception(InvalidCookie.class, invalidCoo= kie); + throw V2ToV1Converter.toV1Exception(InvalidCookie.class, invalidC= ookie); } catch (V1InvalidHandle invalidHandle) { - throw V2V1Converter.toV1Exception(InvalidHandle.class, invalidHan= dle); + throw V2ToV1Converter.toV1Exception(InvalidHandle.class, invalidH= andle); } catch (V1InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(InvalidRegistration.class, inva= lidRegistration); + throw V2ToV1Converter.toV1Exception(InvalidRegistration.class, in= validRegistration); } catch (V1InvalidSession invalidSession) { - throw V2V1Converter.toV1Exception(InvalidSession.class, invalidSe= ssion); + throw V2ToV1Converter.toV1Exception(InvalidSession.class, invalid= Session); } catch (V1InvalidUserCategory invalidUserCategory) { - throw V2V1Converter.toV1Exception(InvalidUserCategory.class, inva= lidUserCategory); + throw V2ToV1Converter.toV1Exception(InvalidUserCategory.class, in= validUserCategory); } catch (V1MissingParameters missingParameters) { - throw V2V1Converter.toV1Exception(MissingParameters.class, missin= gParameters); + throw V2ToV1Converter.toV1Exception(MissingParameters.class, miss= ingParameters); } catch (V1OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(OperationFailed.class, operatio= nFailed); + throw V2ToV1Converter.toV1Exception(OperationFailed.class, operat= ionFailed); } catch (V1PortletStateChangeRequired portletStateChangeRequired) { - throw V2V1Converter.toV1Exception(PortletStateChangeRequired.clas= s, portletStateChangeRequired); + throw V2ToV1Converter.toV1Exception(PortletStateChangeRequired.cl= ass, portletStateChangeRequired); } catch (V1UnsupportedLocale unsupportedLocale) { - throw V2V1Converter.toV1Exception(UnsupportedLocale.class, unsupp= ortedLocale); + throw V2ToV1Converter.toV1Exception(UnsupportedLocale.class, unsu= pportedLocale); } catch (V1UnsupportedMimeType unsupportedMimeType) { - throw V2V1Converter.toV1Exception(UnsupportedMimeType.class, unsu= pportedMimeType); + throw V2ToV1Converter.toV1Exception(UnsupportedMimeType.class, un= supportedMimeType); } catch (V1UnsupportedMode unsupportedMode) { - throw V2V1Converter.toV1Exception(UnsupportedMode.class, unsuppor= tedMode); + throw V2ToV1Converter.toV1Exception(UnsupportedMode.class, unsupp= ortedMode); } catch (V1UnsupportedWindowState unsupportedWindowState) { - throw V2V1Converter.toV1Exception(UnsupportedWindowState.class, u= nsupportedWindowState); + throw V2ToV1Converter.toV1Exception(UnsupportedWindowState.class,= unsupportedWindowState); } } = @@ -252,23 +255,23 @@ { try { - return V2V1Converter.transform(service.releaseSessions(V2V1Conver= ter.toV1RegistrationContext(registrationContext),sessionIDs), V2V1Converter= .V1_TO_V2_EXTENSION); + return WSRPUtils.transform(service.releaseSessions(V2ToV1Converte= r.toV1RegistrationContext(registrationContext), sessionIDs), V1ToV2Converte= r.EXTENSION); } catch (V1AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(AccessDenied.class, accessDenie= d); + throw V2ToV1Converter.toV1Exception(AccessDenied.class, accessDen= ied); } catch (V1InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(InvalidRegistration.class, inva= lidRegistration); + throw V2ToV1Converter.toV1Exception(InvalidRegistration.class, in= validRegistration); } catch (V1MissingParameters missingParameters) { - throw V2V1Converter.toV1Exception(MissingParameters.class, missin= gParameters); + throw V2ToV1Converter.toV1Exception(MissingParameters.class, miss= ingParameters); } catch (V1OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(OperationFailed.class, operatio= nFailed); + throw V2ToV1Converter.toV1Exception(OperationFailed.class, operat= ionFailed); } } = @@ -277,19 +280,19 @@ { try { - return V2V1Converter.transform(service.initCookie(V2V1Converter.t= oV1RegistrationContext(registrationContext)), V2V1Converter.V1_TO_V2_EXTENS= ION); + return WSRPUtils.transform(service.initCookie(V2ToV1Converter.toV= 1RegistrationContext(registrationContext)), V1ToV2Converter.EXTENSION); } catch (V1AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(AccessDenied.class, accessDenie= d); + throw V2ToV1Converter.toV1Exception(AccessDenied.class, accessDen= ied); } catch (V1InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(InvalidRegistration.class, inva= lidRegistration); + throw V2ToV1Converter.toV1Exception(InvalidRegistration.class, in= validRegistration); } catch (V1OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(OperationFailed.class, operatio= nFailed); + throw V2ToV1Converter.toV1Exception(OperationFailed.class, operat= ionFailed); } } } Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/serv= ices/v1/V1ServiceDescriptionService.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v= 1/V1ServiceDescriptionService.java 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v= 1/V1ServiceDescriptionService.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -23,8 +23,10 @@ = package org.gatein.wsrp.services.v1; = +import org.gatein.wsrp.WSRPUtils; import org.gatein.wsrp.services.ServiceDescriptionService; -import org.gatein.wsrp.spec.v1.V2V1Converter; +import org.gatein.wsrp.spec.v1.V1ToV2Converter; +import org.gatein.wsrp.spec.v1.V2ToV1Converter; import org.oasis.wsrp.v1.V1CookieProtocol; import org.oasis.wsrp.v1.V1Extension; import org.oasis.wsrp.v1.V1InvalidRegistration; @@ -78,7 +80,7 @@ Holder mayReturnRegistrationState, Holder> = extensions) throws InvalidRegistration, ModifyRegistrationRequired, OperationFai= led, ResourceSuspended { - V1RegistrationContext v1RegistrationContext =3D V2V1Converter.toV1Re= gistrationContext(registrationContext); + V1RegistrationContext v1RegistrationContext =3D V2ToV1Converter.toV1= RegistrationContext(registrationContext); Holder> v1OfferedPortlets =3D new Holder<= List>(); Holder> v1UserCategories =3D new Holder>(); Holder> v1ProfileITems =3D new Holder>(); @@ -99,21 +101,21 @@ } catch (V1InvalidRegistration v1InvalidRegistration) { - throw V2V1Converter.toV2Exception(InvalidRegistration.class, v1In= validRegistration); + throw V1ToV2Converter.toV2Exception(InvalidRegistration.class, v1= InvalidRegistration); } catch (V1OperationFailed v1OperationFailed) { - throw V2V1Converter.toV2Exception(OperationFailed.class, v1Operat= ionFailed); + throw V1ToV2Converter.toV2Exception(OperationFailed.class, v1Oper= ationFailed); } = - offeredPortlets.value =3D V2V1Converter.transform(v1OfferedPortlets.= value, V2V1Converter.V1_TO_V2_PORTLETDESCRIPTION); - userCategoryDescriptions.value =3D V2V1Converter.transform(v1UserCat= egories.value, V2V1Converter.V1_TO_V2_ITEMDESCRIPTION); + offeredPortlets.value =3D WSRPUtils.transform(v1OfferedPortlets.valu= e, V1ToV2Converter.PORTLETDESCRIPTION); + userCategoryDescriptions.value =3D WSRPUtils.transform(v1UserCategor= ies.value, V1ToV2Converter.ITEMDESCRIPTION); // customUserProfileItemDescriptions.value =3D description.getCustomU= serProfileItemDescriptions(); - customWindowStateDescriptions.value =3D V2V1Converter.transform(v1Wi= ndowStates.value, V2V1Converter.V1_TO_V2_ITEMDESCRIPTION); - customModeDescriptions.value =3D V2V1Converter.transform(v1Modes.val= ue, V2V1Converter.V1_TO_V2_ITEMDESCRIPTION); - requiresInitCookie.value =3D V2V1Converter.toV2CookieProtocol(v1Cook= ie.value); - registrationPropertyDescription.value =3D V2V1Converter.toV2ModelDes= cription(v1RegistrationProperties.value); - resourceList.value =3D V2V1Converter.toV2ResourceList(v1Resources.va= lue); - extensions.value =3D V2V1Converter.transform(v1Extensions.value, V2V= 1Converter.V1_TO_V2_EXTENSION); + customWindowStateDescriptions.value =3D WSRPUtils.transform(v1Window= States.value, V1ToV2Converter.ITEMDESCRIPTION); + customModeDescriptions.value =3D WSRPUtils.transform(v1Modes.value, = V1ToV2Converter.ITEMDESCRIPTION); + requiresInitCookie.value =3D V1ToV2Converter.toV2CookieProtocol(v1Co= okie.value); + registrationPropertyDescription.value =3D V1ToV2Converter.toV2ModelD= escription(v1RegistrationProperties.value); + resourceList.value =3D V1ToV2Converter.toV2ResourceList(v1Resources.= value); + extensions.value =3D WSRPUtils.transform(v1Extensions.value, V1ToV2C= onverter.EXTENSION); } } Modified: components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/= wsrp/endpoints/v1/MarkupEndpoint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/e= ndpoints/v1/MarkupEndpoint.java 2010-06-10 07:58:14 UTC (rev 3292) +++ components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/e= ndpoints/v1/MarkupEndpoint.java 2010-06-10 08:41:09 UTC (rev 3293) @@ -25,7 +25,8 @@ = import com.google.common.collect.Lists; import org.gatein.wsrp.endpoints.WSRPBaseEndpoint; -import org.gatein.wsrp.spec.v1.V2V1Converter; +import org.gatein.wsrp.spec.v1.V1ToV2Converter; +import org.gatein.wsrp.spec.v1.V2ToV1Converter; import org.oasis.wsrp.v1.V1AccessDenied; import org.oasis.wsrp.v1.V1Extension; import org.oasis.wsrp.v1.V1InconsistentParameters; @@ -112,13 +113,13 @@ forceSessionAccess(); = PerformBlockingInteraction performBlockingInteraction =3D new Perfor= mBlockingInteraction(); - performBlockingInteraction.setPortletContext(V2V1Converter.toV2Portl= etContext(portletContext)); - performBlockingInteraction.setRuntimeContext(V2V1Converter.toV2Runti= meContext(runtimeContext)); - performBlockingInteraction.setMarkupParams(V2V1Converter.toV2MarkupP= arams(markupParams)); - performBlockingInteraction.setInteractionParams(V2V1Converter.toV2In= teractionParams(interactionParams)); + performBlockingInteraction.setPortletContext(V1ToV2Converter.toV2Por= tletContext(portletContext)); + performBlockingInteraction.setRuntimeContext(V1ToV2Converter.toV2Run= timeContext(runtimeContext)); + performBlockingInteraction.setMarkupParams(V1ToV2Converter.toV2Marku= pParams(markupParams)); + performBlockingInteraction.setInteractionParams(V1ToV2Converter.toV2= InteractionParams(interactionParams)); = - performBlockingInteraction.setRegistrationContext(V2V1Converter.toV2= RegistrationContext(registrationContext)); - performBlockingInteraction.setUserContext(V2V1Converter.toV2UserCont= ext(userContext)); + performBlockingInteraction.setRegistrationContext(V1ToV2Converter.to= V2RegistrationContext(registrationContext)); + performBlockingInteraction.setUserContext(V1ToV2Converter.toV2UserCo= ntext(userContext)); = BlockingInteractionResponse interactionResponse =3D null; try @@ -128,64 +129,64 @@ } catch (InvalidCookie invalidCookie) { - throw V2V1Converter.toV1Exception(V1InvalidCookie.class, invalidC= ookie); + throw V2ToV1Converter.toV1Exception(V1InvalidCookie.class, invali= dCookie); } catch (InvalidHandle invalidHandle) { - throw V2V1Converter.toV1Exception(V1InvalidHandle.class, invalidH= andle); + throw V2ToV1Converter.toV1Exception(V1InvalidHandle.class, invali= dHandle); } catch (InvalidSession invalidSession) { - throw V2V1Converter.toV1Exception(V1InvalidSession.class, invalid= Session); + throw V2ToV1Converter.toV1Exception(V1InvalidSession.class, inval= idSession); } catch (UnsupportedMode unsupportedMode) { - throw V2V1Converter.toV1Exception(V1UnsupportedMode.class, unsupp= ortedMode); + throw V2ToV1Converter.toV1Exception(V1UnsupportedMode.class, unsu= pportedMode); } catch (UnsupportedMimeType unsupportedMimeType) { - throw V2V1Converter.toV1Exception(V1UnsupportedMimeType.class, un= supportedMimeType); + throw V2ToV1Converter.toV1Exception(V1UnsupportedMimeType.class, = unsupportedMimeType); } catch (OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(V1OperationFailed.class, operat= ionFailed); + throw V2ToV1Converter.toV1Exception(V1OperationFailed.class, oper= ationFailed); } catch (UnsupportedWindowState unsupportedWindowState) { - throw V2V1Converter.toV1Exception(V1UnsupportedWindowState.class,= unsupportedWindowState); + throw V2ToV1Converter.toV1Exception(V1UnsupportedWindowState.clas= s, unsupportedWindowState); } catch (UnsupportedLocale unsupportedLocale) { - throw V2V1Converter.toV1Exception(V1UnsupportedLocale.class, unsu= pportedLocale); + throw V2ToV1Converter.toV1Exception(V1UnsupportedLocale.class, un= supportedLocale); } catch (AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDen= ied); + throw V2ToV1Converter.toV1Exception(V1AccessDenied.class, accessD= enied); } catch (PortletStateChangeRequired portletStateChangeRequired) { - throw V2V1Converter.toV1Exception(V1PortletStateChangeRequired.cl= ass, portletStateChangeRequired); + throw V2ToV1Converter.toV1Exception(V1PortletStateChangeRequired.= class, portletStateChangeRequired); } catch (InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(V1InvalidRegistration.class, in= validRegistration); + throw V2ToV1Converter.toV1Exception(V1InvalidRegistration.class, = invalidRegistration); } catch (MissingParameters missingParameters) { - throw V2V1Converter.toV1Exception(V1MissingParameters.class, miss= ingParameters); + throw V2ToV1Converter.toV1Exception(V1MissingParameters.class, mi= ssingParameters); } catch (InvalidUserCategory invalidUserCategory) { - throw V2V1Converter.toV1Exception(V1InvalidUserCategory.class, in= validUserCategory); + throw V2ToV1Converter.toV1Exception(V1InvalidUserCategory.class, = invalidUserCategory); } catch (InconsistentParameters inconsistentParameters) { - throw V2V1Converter.toV1Exception(V1InconsistentParameters.class,= inconsistentParameters); + throw V2ToV1Converter.toV1Exception(V1InconsistentParameters.clas= s, inconsistentParameters); } = - updateResponse.value =3D V2V1Converter.toV1UpdateResponse(interactio= nResponse.getUpdateResponse()); + updateResponse.value =3D V2ToV1Converter.toV1UpdateResponse(interact= ionResponse.getUpdateResponse()); redirectURL.value =3D interactionResponse.getRedirectURL(); - extensions.value =3D Lists.transform(interactionResponse.getExtensio= ns(), V2V1Converter.V2_TO_V1_EXTENSION); + extensions.value =3D Lists.transform(interactionResponse.getExtensio= ns(), V2ToV1Converter.EXTENSION); } = public List releaseSessions( @@ -196,7 +197,7 @@ forceSessionAccess(); = ReleaseSessions releaseSessions =3D new ReleaseSessions(); - releaseSessions.setRegistrationContext(V2V1Converter.toV2Registratio= nContext(registrationContext)); + releaseSessions.setRegistrationContext(V1ToV2Converter.toV2Registrat= ionContext(registrationContext)); releaseSessions.getSessionIDs().addAll(sessionIDs); = ReturnAny returnAny; @@ -206,22 +207,22 @@ } catch (InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(V1InvalidRegistration.class, in= validRegistration); + throw V2ToV1Converter.toV1Exception(V1InvalidRegistration.class, = invalidRegistration); } catch (OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(V1OperationFailed.class, operat= ionFailed); + throw V2ToV1Converter.toV1Exception(V1OperationFailed.class, oper= ationFailed); } catch (MissingParameters missingParameters) { - throw V2V1Converter.toV1Exception(V1MissingParameters.class, miss= ingParameters); + throw V2ToV1Converter.toV1Exception(V1MissingParameters.class, mi= ssingParameters); } catch (AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDen= ied); + throw V2ToV1Converter.toV1Exception(V1AccessDenied.class, accessD= enied); } = - return Lists.transform(returnAny.getExtensions(), V2V1Converter.V2_T= O_V1_EXTENSION); + return Lists.transform(returnAny.getExtensions(), V2ToV1Converter.EX= TENSION); } = public void getMarkup( @@ -240,11 +241,11 @@ forceSessionAccess(); = GetMarkup getMarkup =3D new GetMarkup(); - getMarkup.setRegistrationContext(V2V1Converter.toV2RegistrationConte= xt(registrationContext)); - getMarkup.setPortletContext(V2V1Converter.toV2PortletContext(portlet= Context)); - getMarkup.setRuntimeContext(V2V1Converter.toV2RuntimeContext(runtime= Context)); - getMarkup.setUserContext(V2V1Converter.toV2UserContext(userContext)); - getMarkup.setMarkupParams(V2V1Converter.toV2MarkupParams(markupParam= s)); + getMarkup.setRegistrationContext(V1ToV2Converter.toV2RegistrationCon= text(registrationContext)); + getMarkup.setPortletContext(V1ToV2Converter.toV2PortletContext(portl= etContext)); + getMarkup.setRuntimeContext(V1ToV2Converter.toV2RuntimeContext(runti= meContext)); + getMarkup.setUserContext(V1ToV2Converter.toV2UserContext(userContext= )); + getMarkup.setMarkupParams(V1ToV2Converter.toV2MarkupParams(markupPar= ams)); = MarkupResponse response; try @@ -253,60 +254,60 @@ } catch (UnsupportedWindowState unsupportedWindowState) { - throw V2V1Converter.toV1Exception(V1UnsupportedWindowState.class,= unsupportedWindowState); + throw V2ToV1Converter.toV1Exception(V1UnsupportedWindowState.clas= s, unsupportedWindowState); } catch (InvalidCookie invalidCookie) { - throw V2V1Converter.toV1Exception(V1InvalidCookie.class, invalidC= ookie); + throw V2ToV1Converter.toV1Exception(V1InvalidCookie.class, invali= dCookie); } catch (InvalidSession invalidSession) { - throw V2V1Converter.toV1Exception(V1InvalidSession.class, invalid= Session); + throw V2ToV1Converter.toV1Exception(V1InvalidSession.class, inval= idSession); } catch (AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDen= ied); + throw V2ToV1Converter.toV1Exception(V1AccessDenied.class, accessD= enied); } catch (InconsistentParameters inconsistentParameters) { - throw V2V1Converter.toV1Exception(V1InconsistentParameters.class,= inconsistentParameters); + throw V2ToV1Converter.toV1Exception(V1InconsistentParameters.clas= s, inconsistentParameters); } catch (InvalidHandle invalidHandle) { - throw V2V1Converter.toV1Exception(V1InvalidHandle.class, invalidH= andle); + throw V2ToV1Converter.toV1Exception(V1InvalidHandle.class, invali= dHandle); } catch (UnsupportedLocale unsupportedLocale) { - throw V2V1Converter.toV1Exception(V1UnsupportedLocale.class, unsu= pportedLocale); + throw V2ToV1Converter.toV1Exception(V1UnsupportedLocale.class, un= supportedLocale); } catch (UnsupportedMode unsupportedMode) { - throw V2V1Converter.toV1Exception(V1UnsupportedMode.class, unsupp= ortedMode); + throw V2ToV1Converter.toV1Exception(V1UnsupportedMode.class, unsu= pportedMode); } catch (OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(V1OperationFailed.class, operat= ionFailed); + throw V2ToV1Converter.toV1Exception(V1OperationFailed.class, oper= ationFailed); } catch (MissingParameters missingParameters) { - throw V2V1Converter.toV1Exception(V1MissingParameters.class, miss= ingParameters); + throw V2ToV1Converter.toV1Exception(V1MissingParameters.class, mi= ssingParameters); } catch (InvalidUserCategory invalidUserCategory) { - throw V2V1Converter.toV1Exception(V1InvalidUserCategory.class, in= validUserCategory); + throw V2ToV1Converter.toV1Exception(V1InvalidUserCategory.class, = invalidUserCategory); } catch (InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(V1InvalidRegistration.class, in= validRegistration); + throw V2ToV1Converter.toV1Exception(V1InvalidRegistration.class, = invalidRegistration); } catch (UnsupportedMimeType unsupportedMimeType) { - throw V2V1Converter.toV1Exception(V1UnsupportedMimeType.class, un= supportedMimeType); + throw V2ToV1Converter.toV1Exception(V1UnsupportedMimeType.class, = unsupportedMimeType); } = - markupContext.value =3D V2V1Converter.toV1MarkupContext(response.get= MarkupContext()); - sessionContext.value =3D V2V1Converter.toV1SessionContext(response.g= etSessionContext()); - extensions.value =3D Lists.transform(response.getExtensions(), V2V1C= onverter.V2_TO_V1_EXTENSION); + markupContext.value =3D V2ToV1Converter.toV1MarkupContext(response.g= etMarkupContext()); + sessionContext.value =3D V2ToV1Converter.toV1SessionContext(response= .getSessionContext()); + extensions.value =3D Lists.transform(response.getExtensions(), V2ToV= 1Converter.EXTENSION); } = public List initCookie( @@ -316,7 +317,7 @@ forceSessionAccess(); = InitCookie initCookie =3D new InitCookie(); - initCookie.setRegistrationContext(V2V1Converter.toV2RegistrationCont= ext(registrationContext)); + initCookie.setRegistrationContext(V1ToV2Converter.toV2RegistrationCo= ntext(registrationContext)); = ReturnAny returnAny; try @@ -325,17 +326,17 @@ } catch (AccessDenied accessDenied) { - throw V2V1Converter.toV1Exception(V1AccessDenied.class, accessDen= ied); + throw V2ToV1Converter.toV1Exception(V1AccessDenied.class, accessD= enied); } catch (OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(V1OperationFailed.class, operat= ionFailed); + throw V2ToV1Converter.toV1Exception(V1OperationFailed.class, oper= ationFailed); } catch (InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(V1InvalidRegistration.class, in= validRegistration); + throw V2ToV1Converter.toV1Exception(V1InvalidRegistration.class, = invalidRegistration); } = - return Lists.transform(returnAny.getExtensions(), V2V1Converter.V2_T= O_V1_EXTENSION); + return Lists.transform(returnAny.getExtensions(), V2ToV1Converter.EX= TENSION); } } Modified: components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/= wsrp/endpoints/v1/ServiceDescriptionEndpoint.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/e= ndpoints/v1/ServiceDescriptionEndpoint.java 2010-06-10 07:58:14 UTC (rev 32= 92) +++ components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/e= ndpoints/v1/ServiceDescriptionEndpoint.java 2010-06-10 08:41:09 UTC (rev 32= 93) @@ -23,8 +23,10 @@ = package org.gatein.wsrp.endpoints.v1; = +import org.gatein.wsrp.WSRPUtils; import org.gatein.wsrp.endpoints.WSRPBaseEndpoint; -import org.gatein.wsrp.spec.v1.V2V1Converter; +import org.gatein.wsrp.spec.v1.V1ToV2Converter; +import org.gatein.wsrp.spec.v1.V2ToV1Converter; import org.oasis.wsrp.v1.V1CookieProtocol; import org.oasis.wsrp.v1.V1Extension; import org.oasis.wsrp.v1.V1InvalidRegistration; @@ -77,7 +79,7 @@ ) throws V1InvalidRegistration, V1OperationFailed { GetServiceDescription getServiceDescription =3D new GetServiceDescri= ption(); - getServiceDescription.setRegistrationContext(V2V1Converter.toV2Regis= trationContext(registrationContext)); + getServiceDescription.setRegistrationContext(V1ToV2Converter.toV2Reg= istrationContext(registrationContext)); getServiceDescription.getDesiredLocales().addAll(desiredLocales); = ServiceDescription description; @@ -87,23 +89,23 @@ } catch (InvalidRegistration invalidRegistration) { - throw V2V1Converter.toV1Exception(V1InvalidRegistration.class, in= validRegistration); + throw V2ToV1Converter.toV1Exception(V1InvalidRegistration.class, = invalidRegistration); } catch (OperationFailed operationFailed) { - throw V2V1Converter.toV1Exception(V1OperationFailed.class, operat= ionFailed); + throw V2ToV1Converter.toV1Exception(V1OperationFailed.class, oper= ationFailed); } = requiresRegistration.value =3D description.isRequiresRegistration(); - offeredPortlets.value =3D V2V1Converter.transform(description.getOff= eredPortlets(), V2V1Converter.V2_TO_V1_PORTLETDESCRIPTION); - userCategoryDescriptions.value =3D V2V1Converter.transform(descripti= on.getUserCategoryDescriptions(), V2V1Converter.V2_TO_V1_ITEMDESCRIPTION); + offeredPortlets.value =3D WSRPUtils.transform(description.getOffered= Portlets(), V2ToV1Converter.PORTLETDESCRIPTION); + userCategoryDescriptions.value =3D WSRPUtils.transform(description.g= etUserCategoryDescriptions(), V2ToV1Converter.ITEMDESCRIPTION); // customUserProfileItemDescriptions.value =3D description.getCustomU= serProfileItemDescriptions(); - customWindowStateDescriptions.value =3D V2V1Converter.transform(desc= ription.getCustomWindowStateDescriptions(), V2V1Converter.V2_TO_V1_ITEMDESC= RIPTION); - customModeDescriptions.value =3D V2V1Converter.transform(description= .getCustomModeDescriptions(), V2V1Converter.V2_TO_V1_ITEMDESCRIPTION); - requiresInitCookie.value =3D V2V1Converter.toV1CookieProtocol(descri= ption.getRequiresInitCookie()); - registrationPropertyDescription.value =3D V2V1Converter.toV1ModelDes= cription(description.getRegistrationPropertyDescription()); + customWindowStateDescriptions.value =3D WSRPUtils.transform(descript= ion.getCustomWindowStateDescriptions(), V2ToV1Converter.ITEMDESCRIPTION); + customModeDescriptions.value =3D WSRPUtils.transform(description.get= CustomModeDescriptions(), V2ToV1Converter.ITEMDESCRIPTION); + requiresInitCookie.value =3D V2ToV1Converter.toV1CookieProtocol(desc= ription.getRequiresInitCookie()); + registrationPropertyDescription.value =3D V2ToV1Converter.toV1ModelD= escription(description.getRegistrationPropertyDescription()); locales.value =3D description.getLocales(); - resourceList.value =3D V2V1Converter.toV1ResourceList(description.ge= tResourceList()); - extensions.value =3D V2V1Converter.transform(description.getExtensio= ns(), V2V1Converter.V2_TO_V1_EXTENSION); + resourceList.value =3D V2ToV1Converter.toV1ResourceList(description.= getResourceList()); + extensions.value =3D WSRPUtils.transform(description.getExtensions()= , V2ToV1Converter.EXTENSION); } } --===============6744000497341355643==--