text
stringlengths 30
1.67M
|
|---|
<s> package org . gatein . wsrp . config ; import org . gatein . common . net . URLTools ; import org . gatein . wsrp . producer . config . impl . xml . SimpleXMLProducerConfigurationService ; import java . net . URL ; import java . util . Enumeration ; public class FileSystemXmlProducerConfigWithReload extends SimpleXMLProducerConfigurationService { public void setConfigFile ( String configLocation ) throws Exception { Enumeration < URL > resources = getClass ( ) . getClassLoader ( ) . getResources ( configLocation ) ; URL configURL = null ; while ( resources . hasMoreElements ( ) ) { configURL = ( URL ) resources . nextElement ( ) ; } if ( configURL == null ) { throw new Exception ( "<STR_LIT>" + configLocation + "<STR_LIT>" ) ; } if ( ! URLTools . exists ( configURL ) ) { throw new Exception ( "<STR_LIT>" + configURL + "<STR_LIT>" ) ; } this . inputStream = configURL . openStream ( ) ; this . reloadConfiguration ( ) ; } } </s>
|
<s> package org . gatein . wsrp . producer ; import junit . framework . TestCase ; import org . gatein . pc . api . Portlet ; import org . gatein . pc . api . PortletContext ; import org . gatein . pc . portlet . container . managed . LifeCycleStatus ; import org . gatein . pc . portlet . container . managed . ManagedObjectLifeCycleEvent ; import org . gatein . pc . portlet . container . managed . ManagedPortletApplication ; import org . gatein . pc . portlet . container . managed . ManagedPortletContainer ; import org . gatein . registration . RegistrationException ; import org . gatein . wsrp . portlet . ApplicationScopeGetPortlet ; import org . gatein . wsrp . portlet . ApplicationScopeSetPortlet ; import org . gatein . wsrp . portlet . BasicPortlet ; import org . gatein . wsrp . portlet . DispatcherPortlet ; import org . gatein . wsrp . portlet . EncodeURLPortlet ; import org . gatein . wsrp . portlet . GetLocalesPortlet ; import org . gatein . wsrp . portlet . ImplicitCloningPortlet ; import org . gatein . wsrp . portlet . MarkupPortlet ; import org . gatein . wsrp . portlet . MultiValuedPortlet ; import org . gatein . wsrp . portlet . RenderParamPortlet ; import org . gatein . wsrp . portlet . ResourceNoEncodeURLPortlet ; import org . gatein . wsrp . portlet . ResourcePortlet ; import org . gatein . wsrp . portlet . SessionPortlet ; import org . gatein . wsrp . portlet . UserContextPortlet ; import org . gatein . wsrp . producer . config . ProducerRegistrationRequirements ; import org . gatein . wsrp . producer . handlers . processors . ProducerHelper ; import org . gatein . wsrp . protocol . v1 . MarkupTestCase ; import org . gatein . wsrp . protocol . v1 . NeedPortletHandleTest ; import org . gatein . wsrp . protocol . v1 . PortletManagementTestCase ; import org . gatein . wsrp . protocol . v1 . RegistrationTestCase ; import org . gatein . wsrp . protocol . v1 . ReleaseSessionTestCase ; import org . gatein . wsrp . protocol . v1 . ServiceDescriptionTestCase ; import org . gatein . wsrp . protocol . v1 . V1ProducerBaseTest ; import org . jboss . arquillian . container . test . api . Deployer ; import org . jboss . arquillian . container . test . api . Deployment ; import org . jboss . arquillian . container . test . api . OverProtocol ; import org . jboss . arquillian . test . api . ArquillianResource ; import org . jboss . shrinkwrap . api . ShrinkWrap ; import org . jboss . shrinkwrap . api . importer . ExplodedImporter ; import org . jboss . shrinkwrap . api . spec . WebArchive ; import org . mockito . Mockito ; import java . io . BufferedReader ; import java . io . File ; import java . io . InputStreamReader ; import java . net . URL ; import java . net . URLConnection ; import java . util . ArrayList ; import java . util . Collection ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Set ; public abstract class WSRPProducerBaseTest extends TestCase { protected Map < String , List < String > > war2Handles = new HashMap < String , List < String > > ( <NUM_LIT:7> ) ; protected String currentlyDeployedArchiveName ; protected WSRPProducerBaseTest ( String name ) throws Exception { super ( name ) ; } protected abstract WSRPProducer getProducer ( ) ; protected abstract ProducerHelper getProducerHelper ( ) ; @ ArquillianResource private Deployer deployer ; protected void deployArchive ( String deploymentName ) { deployer . deploy ( deploymentName ) ; } protected void undeployArchive ( String deploymentName ) { deployer . undeploy ( deploymentName ) ; } public void deploy ( String warFileName ) throws Exception { deployArchive ( warFileName ) ; WSRPProducer producer = getProducer ( ) ; Set < Portlet > portlets = producer . getPortletInvoker ( ) . getPortlets ( ) ; for ( Portlet portlet : portlets ) { org . gatein . pc . api . PortletContext context = portlet . getContext ( ) ; if ( ! war2Handles . containsKey ( getWarName ( context . getId ( ) ) ) ) { ManagedPortletApplication portletApplication = Mockito . mock ( ManagedPortletApplication . class ) ; PortletContext . PortletContextComponents components = context . getComponents ( ) ; Mockito . stub ( portletApplication . getId ( ) ) . toReturn ( components . getApplicationName ( ) ) ; ManagedPortletContainer portletContainer = Mockito . mock ( ManagedPortletContainer . class ) ; Mockito . stub ( portletContainer . getManagedPortletApplication ( ) ) . toReturn ( portletApplication ) ; Mockito . stub ( portletContainer . getId ( ) ) . toReturn ( components . getPortletName ( ) ) ; Mockito . stub ( portletContainer . getInfo ( ) ) . toReturn ( portlet . getInfo ( ) ) ; ManagedObjectLifeCycleEvent lifeCycleEvent = new ManagedObjectLifeCycleEvent ( portletContainer , LifeCycleStatus . STARTED ) ; producer . onEvent ( lifeCycleEvent ) ; } } currentlyDeployedArchiveName = warFileName ; if ( ! war2Handles . containsKey ( warFileName ) ) { Collection < String > portletHandles = getPortletHandles ( ) ; if ( portletHandles != null ) { for ( String handle : portletHandles ) { String warName = getWarName ( handle ) ; if ( warName . equals ( warFileName ) ) { List < String > handles = war2Handles . get ( warName ) ; if ( handles == null ) { handles = new ArrayList < String > ( <NUM_LIT:3> ) ; war2Handles . put ( warName , handles ) ; } handles . add ( handle ) ; } } } else { throw new IllegalArgumentException ( warFileName + "<STR_LIT>" ) ; } } } public void undeploy ( String warFileName ) throws Exception { currentlyDeployedArchiveName = null ; List < String > handles = war2Handles . get ( warFileName ) ; WSRPProducer producer = getProducer ( ) ; if ( handles != null ) { for ( String handle : handles ) { PortletContext context = PortletContext . createPortletContext ( handle ) ; try { Portlet portlet = producer . getPortletInvoker ( ) . getPortlet ( context ) ; ManagedPortletApplication portletApplication = Mockito . mock ( ManagedPortletApplication . class ) ; PortletContext . PortletContextComponents components = context . getComponents ( ) ; Mockito . stub ( portletApplication . getId ( ) ) . toReturn ( components . getApplicationName ( ) ) ; ManagedPortletContainer portletContainer = Mockito . mock ( ManagedPortletContainer . class ) ; Mockito . stub ( portletContainer . getManagedPortletApplication ( ) ) . toReturn ( portletApplication ) ; Mockito . stub ( portletContainer . getId ( ) ) . toReturn ( components . getPortletName ( ) ) ; Mockito . stub ( portletContainer . getInfo ( ) ) . toReturn ( portlet . getInfo ( ) ) ; ManagedObjectLifeCycleEvent lifeCycleEvent = new ManagedObjectLifeCycleEvent ( portletContainer , LifeCycleStatus . STOPPED ) ; producer . onEvent ( lifeCycleEvent ) ; } catch ( Exception e ) { } } } if ( removeCurrent ( warFileName ) ) { war2Handles . remove ( warFileName ) ; } undeployArchive ( warFileName ) ; } protected abstract boolean removeCurrent ( String archiveName ) ; protected void resetRegistrationInfo ( ) throws RegistrationException { WSRPProducer producer = getProducer ( ) ; ProducerRegistrationRequirements registrationRequirements = producer . getConfigurationService ( ) . getConfiguration ( ) . getRegistrationRequirements ( ) ; registrationRequirements . setRegistrationRequired ( false ) ; registrationRequirements . clearRegistrationProperties ( ) ; registrationRequirements . clearRegistrationPropertyChangeListeners ( ) ; producer . getRegistrationManager ( ) . clear ( ) ; registrationRequirements . removeRegistrationPropertyChangeListener ( producer . getRegistrationManager ( ) ) ; } private File getDirectory ( String property ) throws Exception { String deployableProperty = System . getProperty ( property ) ; if ( deployableProperty != null ) { File deployableDir = new File ( deployableProperty ) ; if ( deployableDir . exists ( ) && deployableDir . isDirectory ( ) ) { return deployableDir ; } else { throw new Error ( "<STR_LIT>" + property + "<STR_LIT>" + deployableProperty + "<STR_LIT>" ) ; } } else { throw new Error ( "<STR_LIT>" + property + "<STR_LIT>" ) ; } } public void setUp ( ) throws Exception { super . setUp ( ) ; resetRegistrationInfo ( ) ; getProducerHelper ( ) . reset ( ) ; } public void tearDown ( ) throws Exception { resetRegistrationInfo ( ) ; super . tearDown ( ) ; } protected String getWarName ( String handle ) { org . gatein . pc . api . PortletContext context = org . gatein . pc . api . PortletContext . createPortletContext ( handle ) ; return context . getComponents ( ) . getApplicationName ( ) + "<STR_LIT>" ; } protected abstract Collection < String > getPortletHandles ( ) throws Exception ; @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestBasicPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( BasicPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestMarkupPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( MarkupPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestResourceNoEncodeURLPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( ResourceNoEncodeURLPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestApplicationScopePortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( ApplicationScopeSetPortlet . class ) ; webArchive . addClass ( ApplicationScopeGetPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestSessionPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( SessionPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestDispatcherPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( DispatcherPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestGetLocalesPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( GetLocalesPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestEncodeURLPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( EncodeURLPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestUserContextPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( UserContextPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestMultiValuedPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( MultiValuedPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestImplicitCloningPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( ImplicitCloningPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestResourcePortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( ResourcePortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestRenderParamPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( RenderParamPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestEventsPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( RenderParamPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestPRPPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( RenderParamPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestPortletModesPortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( RenderParamPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createTestPortletStatePortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . merge ( ShrinkWrap . create ( WebArchive . class ) . as ( ExplodedImporter . class ) . importDirectory ( "<STR_LIT>" ) . as ( WebArchive . class ) ) ; webArchive . addClass ( RenderParamPortlet . class ) ; return webArchive ; } @ Deployment ( name = "<STR_LIT>" , managed = false ) @ OverProtocol ( "<STR_LIT>" ) public static WebArchive createGooglePortletArchive ( ) { WebArchive webArchive = ShrinkWrap . create ( WebArchive . class , "<STR_LIT>" ) ; webArchive . setManifest ( new File ( "<STR_LIT>" ) ) ; WebArchive googlePortletArchive = ShrinkWrap . createFromZipFile ( WebArchive . class , new File ( "<STR_LIT>" ) ) ; webArchive . merge ( googlePortletArchive ) ; return webArchive ; } } </s>
|
<s> package org . gatein . wsrp . endpoints . v2 ; import org . apache . cxf . feature . Features ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . ClonePortlet ; import org . oasis . wsrp . v2 . CopiedPortlet ; import org . oasis . wsrp . v2 . DestroyPortlets ; import org . oasis . wsrp . v2 . DestroyPortletsResponse ; import org . oasis . wsrp . v2 . ExportByValueNotSupported ; import org . oasis . wsrp . v2 . ExportNoLongerValid ; import org . oasis . wsrp . v2 . ExportPortlets ; import org . oasis . wsrp . v2 . ExportPortletsResponse ; import org . oasis . wsrp . v2 . ExportedPortlet ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . FailedPortlets ; import org . oasis . wsrp . v2 . GetPortletDescription ; import org . oasis . wsrp . v2 . GetPortletProperties ; import org . oasis . wsrp . v2 . GetPortletPropertyDescription ; import org . oasis . wsrp . v2 . ImportPortlet ; import org . oasis . wsrp . v2 . ImportPortlets ; import org . oasis . wsrp . v2 . ImportPortletsFailed ; import org . oasis . wsrp . v2 . ImportPortletsResponse ; import org . oasis . wsrp . v2 . ImportedPortlet ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . PortletDescriptionResponse ; import org . oasis . wsrp . v2 . PortletLifetime ; import org . oasis . wsrp . v2 . PortletPropertyDescriptionResponse ; import org . oasis . wsrp . v2 . Property ; import org . oasis . wsrp . v2 . PropertyList ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ReleaseExport ; import org . oasis . wsrp . v2 . ResetProperty ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetExportLifetime ; import org . oasis . wsrp . v2 . SetPortletProperties ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2PortletManagementPortType ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . ArrayList ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class PortletManagementEndpoint extends WSRPBaseEndpoint implements WSRPV2PortletManagementPortType { public void getPortletPropertyDescription ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > desiredLocales , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ModelDescription > modelDescription , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { GetPortletPropertyDescription getPortletPropertyDescription = WSRPTypeFactory . createGetPortletPropertyDescription ( registrationContext , portletContext , userContext , desiredLocales ) ; PortletPropertyDescriptionResponse descriptionResponse = producer . getPortletPropertyDescription ( getPortletPropertyDescription ) ; modelDescription . value = descriptionResponse . getModelDescription ( ) ; resourceList . value = descriptionResponse . getResourceList ( ) ; extensions . value = descriptionResponse . getExtensions ( ) ; } public void getPortletDescription ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > desiredLocales , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < PortletDescription > portletDescription , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { GetPortletDescription getPortletDescription = WSRPTypeFactory . createGetPortletDescription ( registrationContext , portletContext , userContext ) ; getPortletDescription . getDesiredLocales ( ) . addAll ( desiredLocales ) ; PortletDescriptionResponse description = producer . getPortletDescription ( getPortletDescription ) ; portletDescription . value = description . getPortletDescription ( ) ; resourceList . value = description . getResourceList ( ) ; extensions . value = description . getExtensions ( ) ; } public void clonePortlet ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Lifetime lifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < String > portletHandle , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < byte [ ] > portletState , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < Lifetime > scheduledDestruction , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { ClonePortlet clonePortlet = WSRPTypeFactory . createClonePortlet ( registrationContext , portletContext , userContext ) ; PortletContext response = producer . clonePortlet ( clonePortlet ) ; portletHandle . value = response . getPortletHandle ( ) ; portletState . value = response . getPortletState ( ) ; extensions . value = response . getExtensions ( ) ; } public void destroyPortlets ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > portletHandles , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < FailedPortlets > > failedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws InconsistentParameters , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { DestroyPortlets destroyPortlets = WSRPTypeFactory . createDestroyPortlets ( registrationContext , portletHandles ) ; DestroyPortletsResponse destroyPortletsResponse = producer . destroyPortlets ( destroyPortlets ) ; failedPortlets . value = destroyPortletsResponse . getFailedPortlets ( ) ; extensions . value = destroyPortletsResponse . getExtensions ( ) ; } public void getPortletsLifetime ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < PortletContext > portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < PortletLifetime > > portletLifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < FailedPortlets > > failedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { } public void setPortletsLifetime ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < PortletContext > portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Lifetime lifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < PortletLifetime > > updatedPortlet , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < FailedPortlets > > failedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { } public void copyPortlets ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext toRegistrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext toUserContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext fromRegistrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext fromUserContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < PortletContext > fromPortletContexts , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Lifetime lifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < CopiedPortlet > > copiedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < FailedPortlets > > failedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { } public void exportPortlets ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < PortletContext > portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . INOUT ) Holder < Lifetime > lifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Boolean exportByValueRequired , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < byte [ ] > exportContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ExportedPortlet > > exportedPortlet , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < FailedPortlets > > failedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , ExportByValueNotSupported , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { ExportPortlets exportPortlets = WSRPTypeFactory . createExportPortlets ( registrationContext , portletContext , userContext , lifetime . value , exportByValueRequired ) ; ExportPortletsResponse exportPortletsResponse = producer . exportPortlets ( exportPortlets ) ; lifetime . value = exportPortletsResponse . getLifetime ( ) ; exportContext . value = exportPortletsResponse . getExportContext ( ) ; exportedPortlet . value = exportPortletsResponse . getExportedPortlet ( ) ; failedPortlets . value = exportPortletsResponse . getFailedPortlets ( ) ; resourceList . value = exportPortletsResponse . getResourceList ( ) ; extensions . value = exportPortletsResponse . getExtensions ( ) ; } public void importPortlets ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) byte [ ] importContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < ImportPortlet > importPortlet , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Lifetime lifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ImportedPortlet > > importedPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ImportPortletsFailed > > importFailed , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , ExportNoLongerValid , InconsistentParameters , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { ImportPortlets importPortlets = WSRPTypeFactory . createImportPortlets ( registrationContext , importContext , importPortlet , userContext , lifetime ) ; ImportPortletsResponse importPortletsResponse = producer . importPortlets ( importPortlets ) ; importedPortlets . value = importPortletsResponse . getImportedPortlets ( ) ; importFailed . value = importPortletsResponse . getImportFailed ( ) ; resourceList . value = importPortletsResponse . getResourceList ( ) ; extensions . value = importPortletsResponse . getExtensions ( ) ; } public List < Extension > releaseExport ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) byte [ ] exportContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext ) { ReleaseExport releaseExport = WSRPTypeFactory . createReleaseExport ( registrationContext , exportContext , userContext ) ; producer . releaseExport ( releaseExport ) ; return new ArrayList < Extension > ( ) ; } public Lifetime setExportLifetime ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , partName = "<STR_LIT>" ) SetExportLifetime setExportLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return producer . setExportLifetime ( setExportLifetime ) ; } public void setPortletProperties ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PropertyList propertyList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < String > portletHandle , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < byte [ ] > portletState , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < Lifetime > scheduledDestruction , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { SetPortletProperties setPortletProperties = WSRPTypeFactory . createSetPortletProperties ( registrationContext , portletContext , propertyList ) ; setPortletProperties . setUserContext ( userContext ) ; PortletContext response = producer . setPortletProperties ( setPortletProperties ) ; portletHandle . value = response . getPortletHandle ( ) ; portletState . value = response . getPortletState ( ) ; extensions . value = response . getExtensions ( ) ; } public void getPortletProperties ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > names , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Property > > properties , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ResetProperty > > resetProperties , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { GetPortletProperties getPortletProperties = WSRPTypeFactory . createGetPortletProperties ( registrationContext , portletContext , userContext , names ) ; PropertyList result = producer . getPortletProperties ( getPortletProperties ) ; properties . value = result . getProperties ( ) ; resetProperties . value = result . getResetProperties ( ) ; extensions . value = result . getExtensions ( ) ; } } </s>
|
<s> package org . gatein . wsrp . endpoints . v2 ; import org . apache . cxf . feature . Features ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetRegistrationLifetime ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistration ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . RegistrationState ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetRegistrationLifetime ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2RegistrationPortType ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class RegistrationEndpoint extends WSRPBaseEndpoint implements WSRPV2RegistrationPortType { public void register ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationData registrationData , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Lifetime lifetime , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < byte [ ] > registrationState , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < Lifetime > scheduledDestruction , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < String > registrationHandle ) throws MissingParameters , OperationFailed , OperationNotSupported { RegistrationContext registrationContext = producer . register ( registrationData ) ; registrationHandle . value = registrationContext . getRegistrationHandle ( ) ; registrationState . value = registrationContext . getRegistrationState ( ) ; extensions . value = registrationContext . getExtensions ( ) ; } public List < Extension > deregister ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext ) throws InvalidRegistration , OperationFailed , OperationNotSupported , ResourceSuspended { producer . deregister ( registrationContext ) ; return null ; } public void modifyRegistration ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationData registrationData , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < byte [ ] > registrationState , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < Lifetime > scheduledDestruction , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws InvalidRegistration , MissingParameters , OperationFailed , OperationNotSupported , ResourceSuspended { ModifyRegistration modifyRegistration = WSRPTypeFactory . createModifyRegistration ( registrationContext , registrationData ) ; RegistrationState result = producer . modifyRegistration ( modifyRegistration ) ; if ( result != null ) { registrationState . value = result . getRegistrationState ( ) ; extensions . value = result . getExtensions ( ) ; } } public Lifetime getRegistrationLifetime ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , partName = "<STR_LIT>" ) GetRegistrationLifetime getRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return null ; } public Lifetime setRegistrationLifetime ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , partName = "<STR_LIT>" ) SetRegistrationLifetime setRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return null ; } } </s>
|
<s> package org . gatein . wsrp . endpoints . v2 ; import org . apache . cxf . feature . Features ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . BlockingInteractionResponse ; import org . oasis . wsrp . v2 . EventParams ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetMarkup ; import org . oasis . wsrp . v2 . GetResource ; import org . oasis . wsrp . v2 . HandleEvents ; import org . oasis . wsrp . v2 . HandleEventsFailed ; import org . oasis . wsrp . v2 . HandleEventsResponse ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InitCookie ; import org . oasis . wsrp . v2 . InteractionParams ; import org . oasis . wsrp . v2 . InvalidCookie ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidSession ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . MarkupContext ; import org . oasis . wsrp . v2 . MarkupParams ; import org . oasis . wsrp . v2 . MarkupResponse ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PerformBlockingInteraction ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletStateChangeRequired ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ReleaseSessions ; import org . oasis . wsrp . v2 . ResourceContext ; import org . oasis . wsrp . v2 . ResourceParams ; import org . oasis . wsrp . v2 . ResourceResponse ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import org . oasis . wsrp . v2 . UnsupportedLocale ; import org . oasis . wsrp . v2 . UnsupportedMimeType ; import org . oasis . wsrp . v2 . UnsupportedMode ; import org . oasis . wsrp . v2 . UnsupportedWindowState ; import org . oasis . wsrp . v2 . UpdateResponse ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2MarkupPortType ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class MarkupEndpoint extends WSRPBaseEndpoint implements WSRPV2MarkupPortType { public void handleEvents ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RuntimeContext runtimeContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) MarkupParams markupParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) EventParams eventParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < UpdateResponse > updateResponse , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < HandleEventsFailed > > failedEvents , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { forceSessionAccess ( ) ; HandleEvents handleEvents = WSRPTypeFactory . createHandleEvents ( registrationContext , portletContext , runtimeContext , userContext , markupParams , eventParams ) ; HandleEventsResponse response = producer . handleEvents ( handleEvents ) ; updateResponse . value = response . getUpdateResponse ( ) ; failedEvents . value = response . getFailedEvents ( ) ; extensions . value = response . getExtensions ( ) ; } public List < Extension > releaseSessions ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > sessionIDs , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext ) throws AccessDenied , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { forceSessionAccess ( ) ; ReleaseSessions releaseSessions = WSRPTypeFactory . createReleaseSessions ( registrationContext , sessionIDs ) ; return producer . releaseSessions ( releaseSessions ) ; } public List < Extension > initCookie ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext ) throws AccessDenied , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { forceSessionAccess ( ) ; InitCookie initCookie = WSRPTypeFactory . createInitCookie ( registrationContext ) ; return producer . initCookie ( initCookie ) ; } public void getMarkup ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RuntimeContext runtimeContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) MarkupParams markupParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < MarkupContext > markupContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < SessionContext > sessionContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { forceSessionAccess ( ) ; GetMarkup getMarkup = WSRPTypeFactory . createGetMarkup ( registrationContext , portletContext , runtimeContext , userContext , markupParams ) ; MarkupResponse response = producer . getMarkup ( getMarkup ) ; markupContext . value = response . getMarkupContext ( ) ; sessionContext . value = response . getSessionContext ( ) ; extensions . value = response . getExtensions ( ) ; } public void getResource ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . INOUT ) Holder < PortletContext > portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RuntimeContext runtimeContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) ResourceParams resourceParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceContext > resourceContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < SessionContext > sessionContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { forceSessionAccess ( ) ; GetResource getResource = WSRPTypeFactory . createGetResource ( registrationContext , portletContext . value , runtimeContext , userContext , resourceParams ) ; ResourceResponse response = producer . getResource ( getResource ) ; resourceContext . value = response . getResourceContext ( ) ; sessionContext . value = response . getSessionContext ( ) ; portletContext . value = response . getPortletContext ( ) ; extensions . value = response . getExtensions ( ) ; } public void performBlockingInteraction ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RuntimeContext runtimeContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) MarkupParams markupParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) InteractionParams interactionParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < UpdateResponse > updateResponse , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < String > redirectURL , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { forceSessionAccess ( ) ; PerformBlockingInteraction performBlockingInteraction = WSRPTypeFactory . createPerformBlockingInteraction ( registrationContext , portletContext , runtimeContext , userContext , markupParams , interactionParams ) ; BlockingInteractionResponse interactionResponse = producer . performBlockingInteraction ( performBlockingInteraction ) ; updateResponse . value = interactionResponse . getUpdateResponse ( ) ; redirectURL . value = interactionResponse . getRedirectURL ( ) ; extensions . value = interactionResponse . getExtensions ( ) ; } } </s>
|
<s> package org . gatein . wsrp . endpoints . v2 ; import org . apache . cxf . feature . Features ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . oasis . wsrp . v2 . CookieProtocol ; import org . oasis . wsrp . v2 . EventDescription ; import org . oasis . wsrp . v2 . ExportDescription ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . ExtensionDescription ; import org . oasis . wsrp . v2 . GetServiceDescription ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . ItemDescription ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModelTypes ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . ServiceDescription ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2ServiceDescriptionPortType ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class ServiceDescriptionEndpoint extends WSRPBaseEndpoint implements WSRPV2ServiceDescriptionPortType { public void getServiceDescription ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > desiredLocales , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > portletHandles , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < Boolean > requiresRegistration , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < PortletDescription > > offeredPortlets , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ItemDescription > > userCategoryDescriptions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ExtensionDescription > > extensionDescriptions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ItemDescription > > customWindowStateDescriptions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < ItemDescription > > customModeDescriptions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < CookieProtocol > requiresInitCookie , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ModelDescription > registrationPropertyDescription , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < String > > locales , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ResourceList > resourceList , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < EventDescription > > eventDescriptions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ModelTypes > schemaType , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < String > > supportedOptions , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < ExportDescription > exportDescription , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < Boolean > mayReturnRegistrationState , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . OUT ) Holder < List < Extension > > extensions ) throws InvalidRegistration , ModifyRegistrationRequired , OperationFailed , ResourceSuspended { GetServiceDescription getServiceDescription = WSRPTypeFactory . createGetServiceDescription ( registrationContext , userContext ) ; getServiceDescription . getDesiredLocales ( ) . addAll ( desiredLocales ) ; getServiceDescription . getPortletHandles ( ) . addAll ( portletHandles ) ; ServiceDescription description = producer . getServiceDescription ( getServiceDescription ) ; requiresRegistration . value = description . isRequiresRegistration ( ) ; offeredPortlets . value = description . getOfferedPortlets ( ) ; userCategoryDescriptions . value = description . getUserCategoryDescriptions ( ) ; extensionDescriptions . value = description . getExtensionDescriptions ( ) ; customWindowStateDescriptions . value = description . getCustomWindowStateDescriptions ( ) ; customModeDescriptions . value = description . getCustomModeDescriptions ( ) ; requiresInitCookie . value = description . getRequiresInitCookie ( ) ; registrationPropertyDescription . value = description . getRegistrationPropertyDescription ( ) ; locales . value = description . getLocales ( ) ; resourceList . value = description . getResourceList ( ) ; eventDescriptions . value = description . getEventDescriptions ( ) ; schemaType . value = description . getSchemaType ( ) ; supportedOptions . value = description . getSupportedOptions ( ) ; exportDescription . value = description . getExportDescription ( ) ; mayReturnRegistrationState . value = description . isMayReturnRegistrationState ( ) ; extensions . value = description . getExtensions ( ) ; } } </s>
|
<s> package org . gatein . wsrp . endpoints . v1 ; import org . apache . cxf . feature . Features ; import org . gatein . common . util . ParameterValidation ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . gatein . wsrp . spec . v1 . V1ToV2Converter ; import org . gatein . wsrp . spec . v1 . V2ToV1Converter ; import org . gatein . wsrp . spec . v1 . WSRP1ExceptionFactory ; import org . oasis . wsrp . v1 . V1AccessDenied ; import org . oasis . wsrp . v1 . V1DestroyFailed ; import org . oasis . wsrp . v1 . V1Extension ; import org . oasis . wsrp . v1 . V1InconsistentParameters ; import org . oasis . wsrp . v1 . V1InvalidHandle ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1InvalidUserCategory ; import org . oasis . wsrp . v1 . V1MissingParameters ; import org . oasis . wsrp . v1 . V1ModelDescription ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1PortletContext ; import org . oasis . wsrp . v1 . V1PortletDescription ; import org . oasis . wsrp . v1 . V1Property ; import org . oasis . wsrp . v1 . V1PropertyList ; import org . oasis . wsrp . v1 . V1RegistrationContext ; import org . oasis . wsrp . v1 . V1ResetProperty ; import org . oasis . wsrp . v1 . V1ResourceList ; import org . oasis . wsrp . v1 . V1UserContext ; import org . oasis . wsrp . v1 . WSRPV1PortletManagementPortType ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . ClonePortlet ; import org . oasis . wsrp . v2 . DestroyPortlets ; import org . oasis . wsrp . v2 . DestroyPortletsResponse ; import org . oasis . wsrp . v2 . GetPortletDescription ; import org . oasis . wsrp . v2 . GetPortletProperties ; import org . oasis . wsrp . v2 . GetPortletPropertyDescription ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletDescriptionResponse ; import org . oasis . wsrp . v2 . PortletPropertyDescriptionResponse ; import org . oasis . wsrp . v2 . PropertyList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetPortletProperties ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class PortletManagementEndpoint extends WSRPBaseEndpoint implements WSRPV1PortletManagementPortType { public void getPortletPropertyDescription ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > desiredLocales , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1ModelDescription > modelDescription , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1ResourceList > resourceList , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InconsistentParameters , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { try { GetPortletPropertyDescription getPortletPropertyDescription = WSRPTypeFactory . createGetPortletPropertyDescription ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2UserContext ( userContext ) , desiredLocales ) ; PortletPropertyDescriptionResponse descriptionResponse = producer . getPortletPropertyDescription ( getPortletPropertyDescription ) ; modelDescription . value = V2ToV1Converter . toV1ModelDescription ( descriptionResponse . getModelDescription ( ) ) ; resourceList . value = V2ToV1Converter . toV1ResourceList ( descriptionResponse . getResourceList ( ) ) ; extensions . value = WSRPUtils . transform ( descriptionResponse . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void setPortletProperties ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PropertyList propertyList , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < String > portletHandle , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < byte [ ] > portletState , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InconsistentParameters , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { try { SetPortletProperties setPortletProperties = WSRPTypeFactory . createSetPortletProperties ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2PropertyList ( propertyList ) ) ; setPortletProperties . setUserContext ( V1ToV2Converter . toV2UserContext ( userContext ) ) ; PortletContext response = producer . setPortletProperties ( setPortletProperties ) ; portletHandle . value = response . getPortletHandle ( ) ; portletState . value = response . getPortletState ( ) ; extensions . value = WSRPUtils . transform ( response . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void clonePortlet ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < String > portletHandle , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < byte [ ] > portletState , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InconsistentParameters , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { try { ClonePortlet clonePortlet = WSRPTypeFactory . createClonePortlet ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2UserContext ( userContext ) ) ; PortletContext response = producer . clonePortlet ( clonePortlet ) ; portletHandle . value = response . getPortletHandle ( ) ; portletState . value = response . getPortletState ( ) ; extensions . value = WSRPUtils . transform ( response . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void getPortletDescription ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > desiredLocales , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1PortletDescription > portletDescription , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1ResourceList > resourceList , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InconsistentParameters , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { try { GetPortletDescription getPortletDescription = WSRPTypeFactory . createGetPortletDescription ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2UserContext ( userContext ) ) ; if ( ParameterValidation . existsAndIsNotEmpty ( desiredLocales ) ) { getPortletDescription . getDesiredLocales ( ) . addAll ( desiredLocales ) ; } PortletDescriptionResponse description = producer . getPortletDescription ( getPortletDescription ) ; portletDescription . value = V2ToV1Converter . toV1PortletDescription ( description . getPortletDescription ( ) ) ; resourceList . value = V2ToV1Converter . toV1ResourceList ( description . getResourceList ( ) ) ; extensions . value = WSRPUtils . transform ( description . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void getPortletProperties ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > names , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Property > > properties , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1ResetProperty > > resetProperties , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InconsistentParameters , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { try { GetPortletProperties getPortletProperties = WSRPTypeFactory . createGetPortletProperties ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2UserContext ( userContext ) , names ) ; PropertyList result = producer . getPortletProperties ( getPortletProperties ) ; properties . value = WSRPUtils . transform ( result . getProperties ( ) , V2ToV1Converter . PROPERTY ) ; resetProperties . value = WSRPUtils . transform ( result . getResetProperties ( ) , V2ToV1Converter . RESETPROPERTY ) ; extensions . value = WSRPUtils . transform ( result . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void destroyPortlets ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > portletHandles , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1DestroyFailed > > destroyFailed , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InconsistentParameters , V1InvalidRegistration , V1OperationFailed { try { DestroyPortlets destroyPortlets = WSRPTypeFactory . createDestroyPortlets ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , portletHandles ) ; DestroyPortletsResponse destroyPortletsResponse = producer . destroyPortlets ( destroyPortlets ) ; destroyFailed . value = V2ToV1Converter . toV1DestroyFailed ( destroyPortletsResponse . getFailedPortlets ( ) ) ; extensions . value = WSRPUtils . transform ( destroyPortletsResponse . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } } </s>
|
<s> package org . gatein . wsrp . endpoints . v1 ; import org . apache . cxf . feature . Features ; import org . gatein . common . util . ParameterValidation ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . gatein . wsrp . spec . v1 . V1ToV2Converter ; import org . gatein . wsrp . spec . v1 . V2ToV1Converter ; import org . gatein . wsrp . spec . v1 . WSRP1ExceptionFactory ; import org . oasis . wsrp . v1 . V1Extension ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1MissingParameters ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1Property ; import org . oasis . wsrp . v1 . V1RegistrationContext ; import org . oasis . wsrp . v1 . V1RegistrationData ; import org . oasis . wsrp . v1 . WSRPV1RegistrationPortType ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistration ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . RegistrationState ; import org . oasis . wsrp . v2 . ResourceSuspended ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class RegistrationEndpoint extends WSRPBaseEndpoint implements WSRPV1RegistrationPortType { public void register ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) String consumerName , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) String consumerAgent , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) boolean methodGetSupported , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > consumerModes , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > consumerWindowStates , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > consumerUserScopes , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > customUserProfileData , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < V1Property > registrationProperties , @ WebParam ( mode = WebParam . Mode . INOUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < String > registrationHandle , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < byte [ ] > registrationState ) throws V1MissingParameters , V1OperationFailed { try { RegistrationData registrationData = WSRPTypeFactory . createRegistrationData ( consumerName , consumerAgent , methodGetSupported ) ; if ( ParameterValidation . existsAndIsNotEmpty ( consumerModes ) ) { registrationData . getConsumerModes ( ) . addAll ( consumerModes ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( consumerWindowStates ) ) { registrationData . getConsumerWindowStates ( ) . addAll ( consumerWindowStates ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( consumerUserScopes ) ) { registrationData . getConsumerUserScopes ( ) . addAll ( consumerUserScopes ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( registrationProperties ) ) { registrationData . getRegistrationProperties ( ) . addAll ( WSRPUtils . transform ( registrationProperties , V1ToV2Converter . PROPERTY ) ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( extensions . value ) ) { registrationData . getExtensions ( ) . addAll ( WSRPUtils . transform ( extensions . value , V1ToV2Converter . EXTENSION ) ) ; } RegistrationContext registrationContext = producer . register ( registrationData ) ; registrationHandle . value = registrationContext . getRegistrationHandle ( ) ; registrationState . value = registrationContext . getRegistrationState ( ) ; extensions . value = WSRPUtils . transform ( registrationContext . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void deregister ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) String registrationHandle , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) byte [ ] registrationState , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , mode = WebParam . Mode . INOUT ) Holder < List < V1Extension > > extensions ) throws V1InvalidRegistration , V1OperationFailed { try { RegistrationContext rc = WSRPTypeFactory . createRegistrationContext ( registrationHandle ) ; rc . setRegistrationState ( registrationState ) ; producer . deregister ( rc ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } public void modifyRegistration ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationData registrationData , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < byte [ ] > registrationState , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1MissingParameters , V1InvalidRegistration , V1OperationFailed { try { ModifyRegistration modifyRegistration = WSRPTypeFactory . createModifyRegistration ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2RegistrationData ( registrationData ) ) ; RegistrationState result = producer . modifyRegistration ( modifyRegistration ) ; if ( result != null ) { registrationState . value = result . getRegistrationState ( ) ; extensions . value = WSRPUtils . transform ( result . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } } } </s>
|
<s> package org . gatein . wsrp . endpoints . v1 ; import com . google . common . collect . Lists ; import org . apache . cxf . feature . Features ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . gatein . wsrp . spec . v1 . V1ToV2Converter ; import org . gatein . wsrp . spec . v1 . V2ToV1Converter ; import org . gatein . wsrp . spec . v1 . WSRP1ExceptionFactory ; import org . oasis . wsrp . v1 . V1AccessDenied ; import org . oasis . wsrp . v1 . V1Extension ; import org . oasis . wsrp . v1 . V1InconsistentParameters ; import org . oasis . wsrp . v1 . V1InteractionParams ; import org . oasis . wsrp . v1 . V1InvalidCookie ; import org . oasis . wsrp . v1 . V1InvalidHandle ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1InvalidSession ; import org . oasis . wsrp . v1 . V1InvalidUserCategory ; import org . oasis . wsrp . v1 . V1MarkupContext ; import org . oasis . wsrp . v1 . V1MarkupParams ; import org . oasis . wsrp . v1 . V1MissingParameters ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1PortletContext ; import org . oasis . wsrp . v1 . V1PortletStateChangeRequired ; import org . oasis . wsrp . v1 . V1RegistrationContext ; import org . oasis . wsrp . v1 . V1RuntimeContext ; import org . oasis . wsrp . v1 . V1SessionContext ; import org . oasis . wsrp . v1 . V1UnsupportedLocale ; import org . oasis . wsrp . v1 . V1UnsupportedMimeType ; import org . oasis . wsrp . v1 . V1UnsupportedMode ; import org . oasis . wsrp . v1 . V1UnsupportedWindowState ; import org . oasis . wsrp . v1 . V1UpdateResponse ; import org . oasis . wsrp . v1 . V1UserContext ; import org . oasis . wsrp . v1 . WSRPV1MarkupPortType ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . BlockingInteractionResponse ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetMarkup ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InitCookie ; import org . oasis . wsrp . v2 . InvalidCookie ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidSession ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . MarkupResponse ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PerformBlockingInteraction ; import org . oasis . wsrp . v2 . PortletStateChangeRequired ; import org . oasis . wsrp . v2 . ReleaseSessions ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . UnsupportedLocale ; import org . oasis . wsrp . v2 . UnsupportedMimeType ; import org . oasis . wsrp . v2 . UnsupportedMode ; import org . oasis . wsrp . v2 . UnsupportedWindowState ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class MarkupEndpoint extends WSRPBaseEndpoint implements WSRPV1MarkupPortType { public void performBlockingInteraction ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RuntimeContext runtimeContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1MarkupParams markupParams , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1InteractionParams interactionParams , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1UpdateResponse > updateResponse , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < String > redirectURL , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1UnsupportedMimeType , V1UnsupportedMode , V1UnsupportedWindowState , V1InvalidCookie , V1InvalidSession , V1MissingParameters , V1UnsupportedLocale , V1InconsistentParameters , V1PortletStateChangeRequired , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { forceSessionAccess ( ) ; PerformBlockingInteraction performBlockingInteraction = WSRPTypeFactory . createPerformBlockingInteraction ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2RuntimeContext ( runtimeContext , portletContext . getPortletHandle ( ) ) , V1ToV2Converter . toV2UserContext ( userContext ) , V1ToV2Converter . toV2MarkupParams ( markupParams ) , V1ToV2Converter . toV2InteractionParams ( interactionParams ) ) ; BlockingInteractionResponse interactionResponse ; try { interactionResponse = producer . performBlockingInteraction ( performBlockingInteraction ) ; } catch ( InvalidCookie invalidCookie ) { throw V2ToV1Converter . toV1Exception ( V1InvalidCookie . class , invalidCookie ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( InvalidSession invalidSession ) { throw V2ToV1Converter . toV1Exception ( V1InvalidSession . class , invalidSession ) ; } catch ( UnsupportedMode unsupportedMode ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedMode . class , unsupportedMode ) ; } catch ( UnsupportedMimeType unsupportedMimeType ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedMimeType . class , unsupportedMimeType ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( UnsupportedWindowState unsupportedWindowState ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedWindowState . class , unsupportedWindowState ) ; } catch ( UnsupportedLocale unsupportedLocale ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedLocale . class , unsupportedLocale ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( PortletStateChangeRequired portletStateChangeRequired ) { throw V2ToV1Converter . toV1Exception ( V1PortletStateChangeRequired . class , portletStateChangeRequired ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } updateResponse . value = V2ToV1Converter . toV1UpdateResponse ( interactionResponse . getUpdateResponse ( ) ) ; redirectURL . value = interactionResponse . getRedirectURL ( ) ; extensions . value = Lists . transform ( interactionResponse . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } public List < V1Extension > releaseSessions ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > sessionIDs ) throws V1MissingParameters , V1InvalidRegistration , V1AccessDenied , V1OperationFailed { forceSessionAccess ( ) ; ReleaseSessions releaseSessions = WSRPTypeFactory . createReleaseSessions ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , sessionIDs ) ; List < Extension > extensions ; try { extensions = producer . releaseSessions ( releaseSessions ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } return Lists . transform ( extensions , V2ToV1Converter . EXTENSION ) ; } public void getMarkup ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1PortletContext portletContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RuntimeContext runtimeContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1UserContext userContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1MarkupParams markupParams , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1MarkupContext > markupContext , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1SessionContext > sessionContext , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1UnsupportedMimeType , V1UnsupportedMode , V1UnsupportedWindowState , V1InvalidCookie , V1InvalidSession , V1MissingParameters , V1UnsupportedLocale , V1InconsistentParameters , V1InvalidHandle , V1InvalidRegistration , V1InvalidUserCategory , V1AccessDenied , V1OperationFailed { forceSessionAccess ( ) ; GetMarkup getMarkup = WSRPTypeFactory . createGetMarkup ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , V1ToV2Converter . toV2PortletContext ( portletContext ) , V1ToV2Converter . toV2RuntimeContext ( runtimeContext , portletContext . getPortletHandle ( ) ) , V1ToV2Converter . toV2UserContext ( userContext ) , V1ToV2Converter . toV2MarkupParams ( markupParams ) ) ; MarkupResponse response ; try { response = producer . getMarkup ( getMarkup ) ; } catch ( UnsupportedWindowState unsupportedWindowState ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedWindowState . class , unsupportedWindowState ) ; } catch ( InvalidCookie invalidCookie ) { throw V2ToV1Converter . toV1Exception ( V1InvalidCookie . class , invalidCookie ) ; } catch ( InvalidSession invalidSession ) { throw V2ToV1Converter . toV1Exception ( V1InvalidSession . class , invalidSession ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw V2ToV1Converter . toV1Exception ( V1InconsistentParameters . class , inconsistentParameters ) ; } catch ( InvalidHandle invalidHandle ) { throw V2ToV1Converter . toV1Exception ( V1InvalidHandle . class , invalidHandle ) ; } catch ( UnsupportedLocale unsupportedLocale ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedLocale . class , unsupportedLocale ) ; } catch ( UnsupportedMode unsupportedMode ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedMode . class , unsupportedMode ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( MissingParameters missingParameters ) { throw V2ToV1Converter . toV1Exception ( V1MissingParameters . class , missingParameters ) ; } catch ( InvalidUserCategory invalidUserCategory ) { throw V2ToV1Converter . toV1Exception ( V1InvalidUserCategory . class , invalidUserCategory ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( UnsupportedMimeType unsupportedMimeType ) { throw V2ToV1Converter . toV1Exception ( V1UnsupportedMimeType . class , unsupportedMimeType ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } markupContext . value = V2ToV1Converter . toV1MarkupContext ( response . getMarkupContext ( ) ) ; sessionContext . value = V2ToV1Converter . toV1SessionContext ( response . getSessionContext ( ) ) ; extensions . value = Lists . transform ( response . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } public List < V1Extension > initCookie ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext ) throws V1InvalidRegistration , V1AccessDenied , V1OperationFailed { forceSessionAccess ( ) ; InitCookie initCookie = WSRPTypeFactory . createInitCookie ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) ) ; List < Extension > extensions ; try { extensions = producer . initCookie ( initCookie ) ; } catch ( AccessDenied accessDenied ) { throw V2ToV1Converter . toV1Exception ( V1AccessDenied . class , accessDenied ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } catch ( OperationNotSupported operationNotSupported ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , operationNotSupported ) ; } return Lists . transform ( extensions , V2ToV1Converter . EXTENSION ) ; } } </s>
|
<s> package org . gatein . wsrp . endpoints . v1 ; import org . apache . cxf . feature . Features ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . endpoints . WSRPBaseEndpoint ; import org . gatein . wsrp . spec . v1 . V1ToV2Converter ; import org . gatein . wsrp . spec . v1 . V2ToV1Converter ; import org . gatein . wsrp . spec . v1 . WSRP1ExceptionFactory ; import org . oasis . wsrp . v1 . V1CookieProtocol ; import org . oasis . wsrp . v1 . V1Extension ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1ItemDescription ; import org . oasis . wsrp . v1 . V1ModelDescription ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1PortletDescription ; import org . oasis . wsrp . v1 . V1RegistrationContext ; import org . oasis . wsrp . v1 . V1ResourceList ; import org . oasis . wsrp . v1 . WSRPV1ServiceDescriptionPortType ; import org . oasis . wsrp . v2 . GetServiceDescription ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . ServiceDescription ; import javax . jws . HandlerChain ; import javax . jws . WebParam ; import javax . xml . ws . Holder ; import java . util . List ; @ javax . jws . WebService ( name = "<STR_LIT>" , serviceName = "<STR_LIT>" , portName = "<STR_LIT>" , targetNamespace = "<STR_LIT>" , wsdlLocation = "<STR_LIT>" , endpointInterface = "<STR_LIT>" ) @ HandlerChain ( file = "<STR_LIT>" ) @ Features ( features = "<STR_LIT>" ) public class ServiceDescriptionEndpoint extends WSRPBaseEndpoint implements WSRPV1ServiceDescriptionPortType { public void getServiceDescription ( @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) V1RegistrationContext registrationContext , @ WebParam ( name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) List < String > desiredLocales , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < Boolean > requiresRegistration , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1PortletDescription > > offeredPortlets , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1ItemDescription > > userCategoryDescriptions , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1ItemDescription > > customUserProfileItemDescriptions , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1ItemDescription > > customWindowStateDescriptions , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1ItemDescription > > customModeDescriptions , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1CookieProtocol > requiresInitCookie , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1ModelDescription > registrationPropertyDescription , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < String > > locales , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < V1ResourceList > resourceList , @ WebParam ( mode = WebParam . Mode . OUT , name = "<STR_LIT>" , targetNamespace = "<STR_LIT>" ) Holder < List < V1Extension > > extensions ) throws V1InvalidRegistration , V1OperationFailed { GetServiceDescription getServiceDescription = WSRPTypeFactory . createGetServiceDescription ( V1ToV2Converter . toV2RegistrationContext ( registrationContext ) , null ) ; getServiceDescription . getDesiredLocales ( ) . addAll ( desiredLocales ) ; ServiceDescription description ; try { description = producer . getServiceDescription ( getServiceDescription ) ; } catch ( InvalidRegistration invalidRegistration ) { throw V2ToV1Converter . toV1Exception ( V1InvalidRegistration . class , invalidRegistration ) ; } catch ( OperationFailed operationFailed ) { throw V2ToV1Converter . toV1Exception ( V1OperationFailed . class , operationFailed ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , modifyRegistrationRequired ) ; } catch ( ResourceSuspended resourceSuspended ) { throw WSRP1ExceptionFactory . createWSException ( V1OperationFailed . class , "<STR_LIT>" , resourceSuspended ) ; } requiresRegistration . value = description . isRequiresRegistration ( ) ; offeredPortlets . value = WSRPUtils . transform ( description . getOfferedPortlets ( ) , V2ToV1Converter . PORTLETDESCRIPTION ) ; userCategoryDescriptions . value = WSRPUtils . transform ( description . getUserCategoryDescriptions ( ) , V2ToV1Converter . ITEMDESCRIPTION ) ; customWindowStateDescriptions . value = WSRPUtils . transform ( description . getCustomWindowStateDescriptions ( ) , V2ToV1Converter . ITEMDESCRIPTION ) ; customModeDescriptions . value = WSRPUtils . transform ( description . getCustomModeDescriptions ( ) , V2ToV1Converter . ITEMDESCRIPTION ) ; requiresInitCookie . value = V2ToV1Converter . toV1CookieProtocol ( description . getRequiresInitCookie ( ) ) ; registrationPropertyDescription . value = V2ToV1Converter . toV1ModelDescription ( description . getRegistrationPropertyDescription ( ) ) ; locales . value = description . getLocales ( ) ; resourceList . value = V2ToV1Converter . toV1ResourceList ( description . getResourceList ( ) ) ; extensions . value = WSRPUtils . transform ( description . getExtensions ( ) , V2ToV1Converter . EXTENSION ) ; } } </s>
|
<s> package org . gatein . wsrp . endpoints ; import org . gatein . wsrp . api . servlet . ServletAccess ; import org . gatein . wsrp . producer . ProducerHolder ; import org . gatein . wsrp . producer . v2 . WSRP2Producer ; import javax . servlet . http . HttpSession ; public class WSRPBaseEndpoint { public WSRPBaseEndpoint ( ) { producer = ProducerHolder . getProducer ( true ) ; } protected void forceSessionAccess ( ) { HttpSession portalSession = ServletAccess . getRequest ( ) . getSession ( false ) ; } protected WSRP2Producer producer ; } </s>
|
<s> package org . gatein . wsrp . api . session ; public interface SessionEventBroadcaster { void registerListener ( String listenerId , SessionEventListener listener ) ; void unregisterListener ( String listenerId ) ; void notifyListenersOf ( SessionEvent event ) ; final static class NullSessionEventBroadcaster implements SessionEventBroadcaster { public void registerListener ( String listenerId , SessionEventListener listener ) { } public void unregisterListener ( String listenerId ) { } public void notifyListenersOf ( SessionEvent event ) { } } static final SessionEventBroadcaster NO_OP_BROADCASTER = new NullSessionEventBroadcaster ( ) ; } </s>
|
<s> package org . gatein . wsrp . api . session ; import javax . servlet . http . HttpSession ; public interface SessionEvent { enum SessionEventType { SESSION_CREATED , SESSION_DESTROYED } SessionEventType getType ( ) ; HttpSession getSession ( ) ; } </s>
|
<s> package org . gatein . wsrp . api . session ; public interface SessionEventListener { void onSessionEvent ( SessionEvent event ) ; } </s>
|
<s> package org . gatein . wsrp . api . plugins ; public class PluginsAccess { private static Plugins plugins ; private PluginsAccess ( ) { } public synchronized static Plugins getPlugins ( ) { return plugins ; } public synchronized static void register ( Plugins plugins ) { if ( PluginsAccess . plugins == null ) { PluginsAccess . plugins = plugins ; } else { throw new IllegalStateException ( "<STR_LIT>" + plugins . getClass ( ) . getCanonicalName ( ) + "<STR_LIT>" ) ; } } } </s>
|
<s> package org . gatein . wsrp . api . plugins ; import java . util . List ; public interface Plugins { String WSRP_PLUGIN_EXTENSION_SUFFIX = "<STR_LIT>" ; List < String > getKnownPluginInterfaceNames ( ) ; List < String > getPluginImplementationNames ( Class pluginClass , String defaultImplementationClassName ) ; < T > T createPluginInstance ( String className , Class < T > pluginClass ) ; } </s>
|
<s> package org . gatein . wsrp . api . plugins ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; public abstract class AbstractPlugins implements Plugins { private static final List < String > KNOWN_PLUGIN_INTERFACES = new ArrayList < String > ( <NUM_LIT:3> ) ; static { KNOWN_PLUGIN_INTERFACES . add ( "<STR_LIT>" ) ; KNOWN_PLUGIN_INTERFACES . add ( "<STR_LIT>" ) ; KNOWN_PLUGIN_INTERFACES . add ( "<STR_LIT>" ) ; KNOWN_PLUGIN_INTERFACES . add ( "<STR_LIT>" ) ; } @ Override public List < String > getKnownPluginInterfaceNames ( ) { return Collections . unmodifiableList ( KNOWN_PLUGIN_INTERFACES ) ; } @ Override public List < String > getPluginImplementationNames ( Class pluginClass , String defaultImplementationClassName ) { try { final List < String > implementations = getImplementationNamesFor ( pluginClass . getCanonicalName ( ) , defaultImplementationClassName ) ; Collections . sort ( implementations ) ; return implementations ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } protected abstract List < String > getImplementationNamesFor ( String pluginClassName , String defaultImplementationClassName ) ; @ Override public < T > T createPluginInstance ( String className , Class < T > pluginClass ) { try { final Class < ? extends T > clazz = getImplementationNamed ( className , pluginClass ) ; if ( ! pluginClass . isAssignableFrom ( clazz ) ) { throw new IllegalArgumentException ( "<STR_LIT>" + pluginClass . getCanonicalName ( ) ) ; } else { return pluginClass . cast ( clazz . newInstance ( ) ) ; } } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException ( "<STR_LIT>" + className , e ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "<STR_LIT>" + className , e ) ; } } protected abstract < T > Class < ? extends T > getImplementationNamed ( String className , Class < T > pluginClass ) throws ClassNotFoundException ; } </s>
|
<s> package org . gatein . wsrp . api . context ; import java . util . List ; import java . util . Locale ; public interface ProducerContext { List < Locale > getSupportedLocales ( ) ; } </s>
|
<s> package org . gatein . wsrp . api . context ; import org . gatein . pc . api . PortletContext ; import java . util . List ; public interface ConsumerStructureProvider { List < String > getPageIdentifiers ( ) ; List < String > getWindowIdentifiersFor ( String pageId ) ; void assignPortletToWindow ( PortletContext portletContext , String windowId , String pageId , String exportedPortletHandle ) ; } </s>
|
<s> package org . gatein . wsrp . api . extensions ; import org . w3c . dom . Element ; public class UnmarshalledExtension { private final String name ; private final Object value ; private final String namespaceURI ; private final boolean isElement ; public UnmarshalledExtension ( String name , Object value , String namespaceURI ) { this . name = name ; this . value = value ; this . namespaceURI = namespaceURI ; isElement = value instanceof Element ; } public String getName ( ) { return name ; } public Object getValue ( ) { return value ; } public boolean isElement ( ) { return isElement ; } public String getNamespaceURI ( ) { return namespaceURI ; } } </s>
|
<s> package org . gatein . wsrp . api . extensions ; import org . oasis . wsrp . v2 . Extension ; import java . util . List ; public interface ConsumerExtensionAccessor { public List < Extension > getRequestExtensionsFor ( Class targetClass ) ; public void addRequestExtension ( Class targetClass , Object extension ) ; public List < UnmarshalledExtension > getResponseExtensionsFrom ( Class responseClass ) ; public void addResponseExtension ( Class responseClass , UnmarshalledExtension extension ) ; public void clear ( ) ; } </s>
|
<s> package org . gatein . wsrp . api . extensions ; public class ExtensionAccess { private static ConsumerExtensionAccessor consumer ; private static ProducerExtensionAccessor producer ; public static ConsumerExtensionAccessor getConsumerExtensionAccessor ( ) { return consumer ; } public static ProducerExtensionAccessor getProducerExtensionAccessor ( ) { return producer ; } protected synchronized static void registerConsumerAccessorInstance ( ConsumerExtensionAccessor accessor ) { if ( consumer != null ) { throw new IllegalStateException ( "<STR_LIT>" + consumer . getClass ( ) . getCanonicalName ( ) + "<STR_LIT>" ) ; } else { consumer = accessor ; } } protected synchronized static void registerProducerAccessorInstance ( ProducerExtensionAccessor accessor ) { if ( producer != null ) { throw new IllegalStateException ( "<STR_LIT>" + producer . getClass ( ) . getCanonicalName ( ) + "<STR_LIT>" ) ; } else { producer = accessor ; } } } </s>
|
<s> package org . gatein . wsrp . api . extensions ; import org . oasis . wsrp . v2 . Extension ; import java . util . List ; public interface ProducerExtensionAccessor { void addRequestExtension ( Class fromClass , UnmarshalledExtension extension ) ; List < UnmarshalledExtension > getRequestExtensionsFor ( Class targetClass ) ; List < Extension > getResponseExtensionsFor ( Class wsrpResponseClass ) ; void addResponseExtension ( Class wsrpResponseClass , Object extension ) ; public void clear ( ) ; } </s>
|
<s> package org . gatein . wsrp . api . extensions ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . wsrp . api . plugins . Plugins ; import org . gatein . wsrp . api . plugins . PluginsAccess ; public abstract class InvocationHandlerDelegate { private static InvocationHandlerDelegate consumerDelegate ; private static InvocationHandlerDelegate producerDelegate ; public static final String CONSUMER_DELEGATE_CLASSNAME = "<STR_LIT>" ; public static final String PRODUCER_DELEGATE_CLASSNAME = "<STR_LIT>" ; static { final Plugins plugins = PluginsAccess . getPlugins ( ) ; consumerDelegate = createInstance ( CONSUMER_DELEGATE_CLASSNAME , plugins ) ; producerDelegate = createInstance ( PRODUCER_DELEGATE_CLASSNAME , plugins ) ; } private static InvocationHandlerDelegate createInstance ( String propertyName , Plugins plugins ) { String delegateClassName = System . getProperty ( propertyName ) ; if ( delegateClassName != null && ! delegateClassName . isEmpty ( ) ) { return plugins . createPluginInstance ( delegateClassName , InvocationHandlerDelegate . class ) ; } else { return null ; } } public synchronized static void registerConsumerDelegate ( InvocationHandlerDelegate delegate ) { consumerDelegate = delegate ; } public synchronized static void registerProducerDelegate ( InvocationHandlerDelegate delegate ) { producerDelegate = delegate ; } public static InvocationHandlerDelegate consumerDelegate ( ) { return consumerDelegate ; } public static InvocationHandlerDelegate producerDelegate ( ) { return producerDelegate ; } public abstract void processInvocation ( PortletInvocation invocation ) ; public abstract void processInvocationResponse ( PortletInvocationResponse response , PortletInvocation invocation ) ; } </s>
|
<s> package org . gatein . wsrp . api . servlet ; import javax . servlet . http . HttpServletRequest ; import javax . servlet . http . HttpServletResponse ; import java . lang . reflect . InvocationHandler ; import java . lang . reflect . Method ; public class ServletAccess implements InvocationHandler { public static final ThreadLocal < Invocation > local = new ThreadLocal < Invocation > ( ) ; protected Object next ; public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable { String mname = method . getName ( ) ; if ( "<STR_LIT>" . equals ( mname ) ) { return null ; } else if ( "<STR_LIT>" . equals ( mname ) ) { next = args [ <NUM_LIT:0> ] ; return null ; } else if ( "<STR_LIT>" . equals ( mname ) ) { return next ; } else if ( "<STR_LIT>" . equals ( mname ) ) { try { Object req = args [ <NUM_LIT:0> ] ; Object resp = args [ <NUM_LIT:1> ] ; Invocation invocation = new Invocation ( ( HttpServletRequest ) req , ( HttpServletResponse ) resp ) ; local . set ( invocation ) ; return method . invoke ( next , args ) ; } finally { local . set ( null ) ; } } else { return "<STR_LIT>" ; } } public static void setRequestAndResponse ( HttpServletRequest request , HttpServletResponse response ) { local . set ( new Invocation ( request , response ) ) ; } public static HttpServletRequest getRequest ( ) { Invocation invocation = local . get ( ) ; return invocation != null ? invocation . req : null ; } public static HttpServletResponse getResponse ( ) { Invocation invocation = local . get ( ) ; return invocation != null ? invocation . resp : null ; } private static class Invocation { private final HttpServletRequest req ; private final HttpServletResponse resp ; public Invocation ( HttpServletRequest req , HttpServletResponse resp ) { this . req = req ; this . resp = resp ; } } } </s>
|
<s> package org . gatein . wsrp . wss . credentials ; import org . gatein . wci . security . Credentials ; public interface CredentialsAccessor { public Credentials getCredentials ( ) ; } </s>
|
<s> package org . gatein . wsrp . wss . credentials ; import org . gatein . wci . security . Credentials ; import org . gatein . wsrp . api . servlet . ServletAccess ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . servlet . http . HttpServletRequest ; public class HTTPSessionCredentialsAccessor implements CredentialsAccessor { private static Logger log = LoggerFactory . getLogger ( HTTPSessionCredentialsAccessor . class ) ; @ Override public Credentials getCredentials ( ) { HttpServletRequest request = ServletAccess . getRequest ( ) ; if ( request != null && request . getSession ( ) != null ) { return ( Credentials ) request . getSession ( ) . getAttribute ( Credentials . CREDENTIALS ) ; } else { log . debug ( "<STR_LIT>" ) ; return null ; } } } </s>
|
<s> package org . gatein . wsrp . wss ; import org . gatein . wsrp . wss . credentials . CredentialsAccessor ; import java . util . ArrayList ; import java . util . List ; public class WebServiceSecurityFactory { public static final WebServiceSecurityFactory instance = new WebServiceSecurityFactory ( ) ; public List < CustomizePortListener > customizePortListeners ; private CredentialsAccessor credentialsAccessor ; public static WebServiceSecurityFactory getInstance ( ) { return instance ; } public void setCredentialsAccessor ( CredentialsAccessor credentialsAccessor ) { this . credentialsAccessor = credentialsAccessor ; } public CredentialsAccessor getCredentialsAccessor ( ) { return credentialsAccessor ; } public void addCustomizePortListener ( CustomizePortListener listener ) { if ( this . customizePortListeners == null ) { customizePortListeners = new ArrayList < CustomizePortListener > ( ) ; } customizePortListeners . add ( listener ) ; } public void removeCustomizePortListener ( CustomizePortListener listener ) { if ( customizePortListeners != null ) { customizePortListeners . remove ( listener ) ; } } public List < CustomizePortListener > getCustomizePortListeners ( ) { return customizePortListeners ; } } </s>
|
<s> package org . gatein . wsrp . wss ; public interface CustomizePortListener { public void customizePort ( Object service ) ; } </s>
|
<s> package org . gatein . wsrp . wss . cxf ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import java . io . File ; import java . io . FileInputStream ; import java . util . HashMap ; import java . util . Map ; import java . util . Properties ; public class Utils { private static Logger log = LoggerFactory . getLogger ( Utils . class ) ; public static final String WS_SECURITY_CONF_DIR_NAME = "<STR_LIT>" ; public static final String CONSUMER_CONF_DIR_NAME = "<STR_LIT>" ; public static final String PRODUCER_CONF_DIR_NAME = "<STR_LIT>" ; public static final String WSS4J_ININTERCEPTOR_PROPERTY_FILE = "<STR_LIT>" ; public static final String WSS4J_OUTINTERCEPTOR_PROPERTY_FILE = "<STR_LIT>" ; public static Map < String , Object > getCXFConfigProperties ( String path ) { String interceptorPropertyFileName = getCXFWSSecurityConfigDir ( ) + File . separator + path ; try { Map < String , Object > outProperties = new HashMap < String , Object > ( ) ; File interceptorPropertyFile = new File ( interceptorPropertyFileName ) ; if ( interceptorPropertyFile . exists ( ) ) { Properties properties = new Properties ( ) ; properties . load ( new FileInputStream ( interceptorPropertyFile ) ) ; for ( String propName : properties . stringPropertyNames ( ) ) { outProperties . put ( propName , properties . get ( propName ) ) ; } } else { log . debug ( "<STR_LIT>" + interceptorPropertyFileName + "<STR_LIT>" ) ; return null ; } return outProperties ; } catch ( Exception e ) { log . error ( "<STR_LIT>" + interceptorPropertyFileName + "<STR_LIT>" , e ) ; } return null ; } protected static String getCXFWSSecurityConfigDir ( ) { return org . gatein . wsrp . cxf . Utils . getWSRPCXFConfigDirectory ( ) + File . separator + WS_SECURITY_CONF_DIR_NAME ; } } </s>
|
<s> package org . gatein . wsrp . wss . cxf . consumer ; import org . apache . cxf . endpoint . Client ; import org . apache . cxf . frontend . ClientProxy ; import org . apache . cxf . ws . security . wss4j . WSS4JInInterceptor ; import org . apache . cxf . ws . security . wss4j . WSS4JOutInterceptor ; import org . apache . ws . security . handler . WSHandlerConstants ; import org . gatein . wci . security . Credentials ; import org . gatein . wsrp . wss . CustomizePortListener ; import org . gatein . wsrp . wss . WebServiceSecurityFactory ; import org . gatein . wsrp . wss . credentials . CredentialsAccessor ; import org . gatein . wsrp . wss . cxf . Utils ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import java . io . File ; import java . util . Map ; public class CXFCustomizePortListener implements CustomizePortListener { private static Logger log = LoggerFactory . getLogger ( CXFCustomizePortListener . class ) ; protected static String GTN_CURRENT_USER = "<STR_LIT>" ; protected static String GTN_USERNAME_TOKEN_IF_AUTHENTICATED = "<STR_LIT>" ; protected static String GTN_NO_USER = "<STR_LIT>" ; @ Override public void customizePort ( Object service ) { log . debug ( "<STR_LIT>" ) ; Client client = ClientProxy . getClient ( service ) ; Map < String , Object > inPropertyMap = getWSS4JInInterceptorProperties ( ) ; Map < String , Object > outPropertyMap = getWSS4JOutInterceptorProperties ( ) ; if ( inPropertyMap != null && handleSpecialProperties ( inPropertyMap ) ) { WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor ( inPropertyMap ) ; client . getInInterceptors ( ) . add ( inInterceptor ) ; } if ( outPropertyMap != null && handleSpecialProperties ( outPropertyMap ) ) { WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor ( outPropertyMap ) ; client . getOutInterceptors ( ) . add ( outInterceptor ) ; } } protected Map < String , Object > getWSS4JInInterceptorProperties ( ) { String wss4jInInterceptorConfigPath = Utils . CONSUMER_CONF_DIR_NAME + File . separator + Utils . WSS4J_ININTERCEPTOR_PROPERTY_FILE ; Map < String , Object > inInterceptorProperties = Utils . getCXFConfigProperties ( wss4jInInterceptorConfigPath ) ; if ( inInterceptorProperties == null ) { log . debug ( "<STR_LIT>" ) ; } return inInterceptorProperties ; } protected Map < String , Object > getWSS4JOutInterceptorProperties ( ) { String wss4jOutInterceptorConfigPath = Utils . CONSUMER_CONF_DIR_NAME + File . separator + Utils . WSS4J_OUTINTERCEPTOR_PROPERTY_FILE ; Map < String , Object > outInterceptorProperties = Utils . getCXFConfigProperties ( wss4jOutInterceptorConfigPath ) ; if ( outInterceptorProperties == null ) { log . debug ( "<STR_LIT>" ) ; } return outInterceptorProperties ; } protected boolean handleSpecialProperties ( Map < String , Object > propertyMap ) { return handleUserAuthentication ( propertyMap ) ; } protected boolean handleUserAuthentication ( Map < String , Object > propertyMap ) { if ( propertyMap . containsKey ( WSHandlerConstants . USER ) && propertyMap . get ( WSHandlerConstants . USER ) . equals ( GTN_CURRENT_USER ) ) { CredentialsAccessor credentialsAccessor = WebServiceSecurityFactory . getInstance ( ) . getCredentialsAccessor ( ) ; if ( credentialsAccessor != null && credentialsAccessor . getCredentials ( ) != null ) { Credentials credentials = credentialsAccessor . getCredentials ( ) ; propertyMap . put ( WSHandlerConstants . USER , credentials . getUsername ( ) ) ; String actionProperty = ( String ) propertyMap . get ( WSHandlerConstants . ACTION ) ; if ( actionProperty != null && actionProperty . contains ( GTN_USERNAME_TOKEN_IF_AUTHENTICATED ) ) { if ( credentials . getPassword ( ) != null ) { actionProperty = actionProperty . replace ( GTN_USERNAME_TOKEN_IF_AUTHENTICATED , WSHandlerConstants . USERNAME_TOKEN ) ; } else { actionProperty = actionProperty . replace ( GTN_USERNAME_TOKEN_IF_AUTHENTICATED , WSHandlerConstants . USERNAME_TOKEN_NO_PASSWORD ) ; } propertyMap . put ( WSHandlerConstants . ACTION , actionProperty ) ; } } else { propertyMap . put ( WSHandlerConstants . USER , GTN_NO_USER ) ; String actionProperty = ( String ) propertyMap . get ( WSHandlerConstants . ACTION ) ; if ( actionProperty != null ) { if ( actionProperty . contains ( GTN_USERNAME_TOKEN_IF_AUTHENTICATED ) ) { actionProperty = actionProperty . replace ( GTN_USERNAME_TOKEN_IF_AUTHENTICATED , "<STR_LIT>" ) ; } propertyMap . put ( WSHandlerConstants . ACTION , actionProperty ) ; if ( actionProperty . trim ( ) . isEmpty ( ) ) { return false ; } } } } return true ; } } </s>
|
<s> package org . gatein . wsrp . wss . cxf . consumer ; import org . apache . ws . security . WSPasswordCallback ; import org . gatein . wci . security . Credentials ; import org . gatein . wsrp . wss . WebServiceSecurityFactory ; import org . gatein . wsrp . wss . credentials . CredentialsAccessor ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . security . auth . callback . Callback ; import javax . security . auth . callback . CallbackHandler ; import javax . security . auth . callback . UnsupportedCallbackException ; import java . io . IOException ; public class CurrentUserPasswordCallback implements CallbackHandler { private static Logger log = LoggerFactory . getLogger ( CurrentUserPasswordCallback . class ) ; @ Override public void handle ( Callback [ ] callbacks ) throws IOException , UnsupportedCallbackException { for ( Callback callback : callbacks ) { if ( callback instanceof WSPasswordCallback ) { WSPasswordCallback wspasswordCallBack = ( WSPasswordCallback ) callback ; if ( wspasswordCallBack . getUsage ( ) == ( WSPasswordCallback . USERNAME_TOKEN ) ) { CredentialsAccessor credentialsAccessor = WebServiceSecurityFactory . getInstance ( ) . getCredentialsAccessor ( ) ; if ( credentialsAccessor != null && credentialsAccessor . getCredentials ( ) != null ) { Credentials credentials = credentialsAccessor . getCredentials ( ) ; if ( credentials . getUsername ( ) . equals ( wspasswordCallBack . getIdentifier ( ) ) ) { wspasswordCallBack . setPassword ( credentials . getPassword ( ) ) ; } else { log . warn ( "<STR_LIT>" ) ; } } else { log . warn ( "<STR_LIT>" ) ; } } } } } } </s>
|
<s> package org . gatein . wsrp . wss . cxf . producer ; import org . apache . cxf . binding . soap . SoapMessage ; import org . apache . cxf . interceptor . Fault ; import org . apache . ws . security . WSConstants ; import org . apache . ws . security . WSSecurityEngineResult ; import org . apache . ws . security . WSUsernameTokenPrincipal ; import org . apache . ws . security . handler . WSHandlerConstants ; import org . jboss . wsf . stack . cxf . security . authentication . SubjectCreatingInterceptor ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . security . auth . Subject ; import javax . servlet . ServletException ; import javax . servlet . http . HttpServletRequest ; import java . security . Principal ; import java . util . HashMap ; import java . util . LinkedHashSet ; import java . util . List ; import java . util . Map ; import java . util . Set ; public class GTNSubjectCreatingInterceptor extends SubjectCreatingInterceptor { private static Logger log = LoggerFactory . getLogger ( GTNSubjectCreatingInterceptor . class ) ; private static final String USERNAME_TOKEN_IFAVAILABLE = "<STR_LIT>" ; protected boolean gtnUsernameTokenIfAvailable = false ; private WSUsernameTokenPrincipal wsUsernameTokenPrincipal = null ; public GTNSubjectCreatingInterceptor ( ) { this ( new HashMap < String , Object > ( ) ) ; } public GTNSubjectCreatingInterceptor ( Map < String , Object > properties ) { super ( properties ) ; } @ Override public void handleMessage ( SoapMessage msg ) throws Fault { String actionProperty = ( String ) this . getProperties ( ) . get ( WSHandlerConstants . ACTION ) ; if ( actionProperty . contains ( USERNAME_TOKEN_IFAVAILABLE ) ) { gtnUsernameTokenIfAvailable = true ; this . setProperty ( WSHandlerConstants . ACTION , actionProperty . replace ( USERNAME_TOKEN_IFAVAILABLE , WSHandlerConstants . USERNAME_TOKEN ) ) ; } try { super . handleMessage ( msg ) ; } finally { if ( gtnUsernameTokenIfAvailable ) { this . setProperty ( WSHandlerConstants . ACTION , actionProperty ) ; } } if ( wsUsernameTokenPrincipal != null ) { HttpServletRequest request = ( HttpServletRequest ) msg . get ( "<STR_LIT>" ) ; String username = wsUsernameTokenPrincipal . getName ( ) ; String password = wsUsernameTokenPrincipal . getPassword ( ) ; wsUsernameTokenPrincipal = null ; try { if ( request . getRemoteUser ( ) == null ) { request . login ( username , password ) ; } } catch ( ServletException e ) { e . printStackTrace ( ) ; } } } @ Override public Subject createSubject ( String name , String password , boolean isDigest , String nonce , String created ) { Subject originalSubject = super . createSubject ( name , password , isDigest , nonce , created ) ; Set < Principal > principals = originalSubject . getPrincipals ( ) ; if ( ! principals . iterator ( ) . next ( ) . getName ( ) . equals ( name ) ) { Principal namePrincipal = null ; for ( Principal principal : principals ) { if ( principal . getName ( ) . equals ( name ) ) { namePrincipal = principal ; break ; } } if ( namePrincipal != null ) { principals . remove ( namePrincipal ) ; Set < Principal > newPrincipals = new LinkedHashSet < Principal > ( ) ; newPrincipals . add ( namePrincipal ) ; newPrincipals . addAll ( principals ) ; originalSubject . getPrincipals ( ) . clear ( ) ; originalSubject . getPrincipals ( ) . addAll ( newPrincipals ) ; } } return originalSubject ; } @ Override protected boolean checkReceiverResultsAnyOrder ( List < WSSecurityEngineResult > wsResults , List < Integer > actions ) { wsUsernameTokenPrincipal = null ; if ( gtnUsernameTokenIfAvailable ) { boolean foundUsernameTokenResult = false ; for ( WSSecurityEngineResult wsResult : wsResults ) { Integer actInt = ( Integer ) wsResult . get ( WSSecurityEngineResult . TAG_ACTION ) ; if ( actInt == WSConstants . UT ) { foundUsernameTokenResult = true ; Object principal = wsResult . get ( WSSecurityEngineResult . TAG_PRINCIPAL ) ; if ( principal != null && principal instanceof WSUsernameTokenPrincipal ) { this . wsUsernameTokenPrincipal = ( WSUsernameTokenPrincipal ) principal ; } break ; } } if ( foundUsernameTokenResult && ! actions . contains ( WSConstants . UT ) ) { actions . add ( WSConstants . UT ) ; } else if ( ! foundUsernameTokenResult && actions . contains ( WSConstants . UT ) ) { actions . remove ( actions . indexOf ( WSConstants . UT ) ) ; } } return super . checkReceiverResults ( wsResults , actions ) ; } } </s>
|
<s> package org . gatein . wsrp . wss . cxf . producer ; import java . io . File ; import java . util . Map ; import org . apache . cxf . Bus ; import org . apache . cxf . endpoint . Server ; import org . apache . cxf . feature . AbstractFeature ; import org . apache . cxf . ws . security . wss4j . WSS4JInInterceptor ; import org . apache . cxf . ws . security . wss4j . WSS4JOutInterceptor ; import org . gatein . wsrp . wss . cxf . Utils ; import org . jboss . wsf . stack . cxf . security . authentication . SubjectCreatingInterceptor ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; public class WSRPWSSecurityFeature extends AbstractFeature { private static Logger log = LoggerFactory . getLogger ( WSRPWSSecurityFeature . class ) ; protected static String GTN_SCI_INTERCEPTOR_CONFIG_FILE = "<STR_LIT>" ; public WSRPWSSecurityFeature ( ) { log . debug ( "<STR_LIT>" ) ; } @ Override public void initialize ( Server server , Bus bus ) { System . out . println ( "<STR_LIT>" ) ; Map < String , Object > inPropertyMap = getWSS4JInInterceptorProperties ( ) ; Map < String , Object > outPropertyMap = getWSS4JOutInterceptorProperties ( ) ; Map < String , Object > sciPropertyMap = getGTNSubjectCreatingInterceptorProperties ( ) ; if ( sciPropertyMap != null ) { SubjectCreatingInterceptor sci = new GTNSubjectCreatingInterceptor ( sciPropertyMap ) ; server . getEndpoint ( ) . getInInterceptors ( ) . add ( sci ) ; } if ( inPropertyMap != null ) { WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor ( inPropertyMap ) ; server . getEndpoint ( ) . getInInterceptors ( ) . add ( inInterceptor ) ; } if ( outPropertyMap != null ) { WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor ( outPropertyMap ) ; server . getEndpoint ( ) . getOutInterceptors ( ) . add ( outInterceptor ) ; } } protected Map < String , Object > getWSS4JInInterceptorProperties ( ) { String wss4jInInterceptorConfigPath = Utils . PRODUCER_CONF_DIR_NAME + File . separator + Utils . WSS4J_ININTERCEPTOR_PROPERTY_FILE ; Map < String , Object > inInterceptorProperties = Utils . getCXFConfigProperties ( wss4jInInterceptorConfigPath ) ; if ( inInterceptorProperties == null ) { log . debug ( "<STR_LIT>" ) ; } return inInterceptorProperties ; } protected Map < String , Object > getWSS4JOutInterceptorProperties ( ) { String wss4jOutInterceptorConfigPath = Utils . PRODUCER_CONF_DIR_NAME + File . separator + Utils . WSS4J_OUTINTERCEPTOR_PROPERTY_FILE ; Map < String , Object > outInterceptorProperties = Utils . getCXFConfigProperties ( wss4jOutInterceptorConfigPath ) ; if ( outInterceptorProperties == null ) { log . debug ( "<STR_LIT>" ) ; } return outInterceptorProperties ; } protected Map < String , Object > getGTNSubjectCreatingInterceptorProperties ( ) { String gtnSCInterceptorConfigPath = Utils . PRODUCER_CONF_DIR_NAME + File . separator + GTN_SCI_INTERCEPTOR_CONFIG_FILE ; Map < String , Object > interceptorProperties = Utils . getCXFConfigProperties ( gtnSCInterceptorConfigPath ) ; if ( interceptorProperties == null ) { log . debug ( "<STR_LIT>" ) ; } return interceptorProperties ; } } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers . consumer ; import org . gatein . wsrp . wss . CustomizePortListener ; import org . jboss . ws . core . StubExt ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; public class JBWSCustomizePortListener implements CustomizePortListener { private static Logger log = LoggerFactory . getLogger ( JBWSCustomizePortListener . class ) ; @ Override public void customizePort ( Object service ) { if ( service instanceof StubExt ) { StubExt stub = ( StubExt ) service ; stub . setConfigName ( "<STR_LIT>" , "<STR_LIT>" ) ; } else { log . warn ( "<STR_LIT>" ) ; } } } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers . consumer ; import org . gatein . wci . security . Credentials ; import org . gatein . wsrp . wss . WebServiceSecurityFactory ; import org . gatein . wsrp . wss . credentials . CredentialsAccessor ; import org . jboss . ws . core . CommonMessageContext ; import org . wsrp . wss . jboss5 . handlers . AbstractWSSecurityCredentialHandler ; import javax . xml . ws . BindingProvider ; import javax . xml . ws . handler . soap . SOAPMessageContext ; public class WSSecurityCredentialHandler extends AbstractWSSecurityCredentialHandler { @ Override protected boolean handleRequest ( SOAPMessageContext soapMessageContext ) { try { log . debug ( "<STR_LIT>" ) ; CommonMessageContext ctx = ( CommonMessageContext ) soapMessageContext ; CredentialsAccessor credentialsAccessor = WebServiceSecurityFactory . getInstance ( ) . getCredentialsAccessor ( ) ; if ( credentialsAccessor != null && credentialsAccessor . getCredentials ( ) != null ) { Credentials credentials = credentialsAccessor . getCredentials ( ) ; ctx . put ( BindingProvider . USERNAME_PROPERTY , credentials . getUsername ( ) ) ; ctx . put ( BindingProvider . PASSWORD_PROPERTY , credentials . getPassword ( ) ) ; } else { log . debug ( "<STR_LIT>" ) ; } } catch ( Exception e ) { log . warn ( "<STR_LIT>" , e ) ; } return true ; } } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers . consumer ; import org . wsrp . wss . jboss5 . handlers . AbstractJBWSSecurityHandlerWrapper ; public class JBWSSecurityHandlerWrapper extends AbstractJBWSSecurityHandlerWrapper { protected String getInternalConfigFileName ( ) { return getDefaultConfigFileName ( ) ; } protected String getDefaultConfigFileName ( ) { return "<STR_LIT>" ; } protected String getConfigPropertyName ( ) { return "<STR_LIT>" ; } protected String getHandlerType ( ) { return "<STR_LIT>" ; } } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . xml . namespace . QName ; import javax . xml . ws . handler . MessageContext ; import javax . xml . ws . handler . soap . SOAPHandler ; import javax . xml . ws . handler . soap . SOAPMessageContext ; import java . util . Set ; public abstract class AbstractWSSecurityCredentialHandler implements SOAPHandler < SOAPMessageContext > { protected static final Logger log = LoggerFactory . getLogger ( AbstractWSSecurityCredentialHandler . class ) ; public void close ( MessageContext arg0 ) { } public boolean handleFault ( SOAPMessageContext soapMessageContext ) { return true ; } public boolean handleMessage ( SOAPMessageContext soapMessageContext ) { if ( Boolean . TRUE . equals ( soapMessageContext . get ( MessageContext . MESSAGE_OUTBOUND_PROPERTY ) ) ) { return handleRequest ( soapMessageContext ) ; } else { return handleResponse ( soapMessageContext ) ; } } protected boolean handleRequest ( SOAPMessageContext soapMessageContext ) { return true ; } protected boolean handleResponse ( SOAPMessageContext soapMessageContext ) { return true ; } public Set < QName > getHeaders ( ) { return null ; } } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers ; import org . jboss . ws . extensions . security . jaxws . WSSecurityHandler ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . xml . ws . handler . MessageContext ; import java . io . File ; import java . net . MalformedURLException ; public abstract class AbstractJBWSSecurityHandlerWrapper extends WSSecurityHandler { protected static final Logger log = LoggerFactory . getLogger ( AbstractWSSecurityCredentialHandler . class ) ; public static final String GATEIN_CONF_DIR = "<STR_LIT>" ; @ Override protected boolean handleInbound ( MessageContext msgContext ) { return handleInboundSecurity ( msgContext ) ; } @ Override protected boolean handleOutbound ( MessageContext msgContext ) { return handleOutboundSecurity ( msgContext ) ; } @ Override protected String getConfigResourceName ( ) { String configFile = System . getProperty ( getConfigPropertyName ( ) ) ; if ( configFile == null ) { String gateInConfDirectory = System . getProperty ( GATEIN_CONF_DIR ) ; configFile = gateInConfDirectory + File . separator + getDefaultConfigFileName ( ) ; } File file = new File ( configFile ) ; if ( file . exists ( ) ) { try { return file . toURI ( ) . toURL ( ) . toString ( ) ; } catch ( MalformedURLException e ) { log . warn ( "<STR_LIT>" + getHandlerType ( ) + "<STR_LIT>" + configFile , e ) ; } } else { log . debug ( "<STR_LIT>" + getDefaultConfigFileName ( ) + "<STR_LIT>" + GATEIN_CONF_DIR + "<STR_LIT>" ) ; } return getInternalConfigFileName ( ) ; } protected abstract String getInternalConfigFileName ( ) ; protected abstract String getDefaultConfigFileName ( ) ; protected abstract String getConfigPropertyName ( ) ; protected abstract String getHandlerType ( ) ; } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers . producer ; import org . jboss . web . tomcat . security . login . WebAuthentication ; import org . jboss . wsf . spi . SPIProvider ; import org . jboss . wsf . spi . SPIProviderResolver ; import org . jboss . wsf . spi . invocation . SecurityAdaptor ; import org . jboss . wsf . spi . invocation . SecurityAdaptorFactory ; import org . wsrp . wss . jboss5 . handlers . AbstractWSSecurityCredentialHandler ; import javax . xml . ws . handler . soap . SOAPMessageContext ; public class WSSecurityCredentialHandler extends AbstractWSSecurityCredentialHandler { @ Override protected boolean handleResponse ( SOAPMessageContext soapMessageContext ) { try { log . debug ( "<STR_LIT>" ) ; SPIProvider spiProvider = SPIProviderResolver . getInstance ( ) . getProvider ( ) ; SecurityAdaptor securityAdaptor = spiProvider . getSPI ( SecurityAdaptorFactory . class ) . newSecurityAdapter ( ) ; if ( securityAdaptor != null && securityAdaptor . getPrincipal ( ) != null && securityAdaptor . getPrincipal ( ) . getName ( ) != null && securityAdaptor . getCredential ( ) != null ) { WebAuthentication wa = new WebAuthentication ( ) ; wa . login ( securityAdaptor . getPrincipal ( ) . getName ( ) , securityAdaptor . getCredential ( ) ) ; } else { log . debug ( "<STR_LIT>" ) ; } } catch ( Exception e ) { log . warn ( "<STR_LIT>" , e ) ; } return true ; } } </s>
|
<s> package org . wsrp . wss . jboss5 . handlers . producer ; import org . wsrp . wss . jboss5 . handlers . AbstractJBWSSecurityHandlerWrapper ; public class JBWSSecurityHandlerWrapper extends AbstractJBWSSecurityHandlerWrapper { protected String getInternalConfigFileName ( ) { return "<STR_LIT>" ; } protected String getDefaultConfigFileName ( ) { return "<STR_LIT>" ; } protected String getConfigPropertyName ( ) { return "<STR_LIT>" ; } protected String getHandlerType ( ) { return "<STR_LIT>" ; } } </s>
|
<s> package org . gatein . wsrp . consumer . registry ; import org . gatein . pc . federation . FederatingPortletInvoker ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . consumer . ConsumerException ; import org . gatein . wsrp . consumer . ProducerInfo ; import java . util . Collection ; import java . util . List ; public interface ConsumerRegistry { List < WSRPConsumer > getConfiguredConsumers ( ) ; WSRPConsumer getConsumer ( String id ) ; FederatingPortletInvoker getFederatingPortletInvoker ( ) ; WSRPConsumer createConsumer ( String id , Integer expirationCacheSeconds , String wsdlURL ) throws ConsumerException ; void persistConsumer ( WSRPConsumer consumer ) throws ConsumerException ; void activateConsumerWith ( String id ) throws ConsumerException ; String updateProducerInfo ( ProducerInfo producerInfo ) throws ConsumerException ; void deactivateConsumerWith ( String id ) throws ConsumerException ; void registerOrDeregisterConsumerWith ( String id , boolean register ) throws ConsumerException ; void destroyConsumer ( String id ) throws ConsumerException ; void reloadConsumers ( ) ; boolean containsConsumer ( String id ) ; Collection < String > getConfiguredConsumersIds ( ) ; int getConfiguredConsumerNumber ( ) ; } </s>
|
<s> package org . gatein . wsrp . consumer . registry . xml ; import org . gatein . common . util . ParameterValidation ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . consumer . EndpointConfigurationInfo ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . RegistrationInfo ; import org . gatein . wsrp . consumer . registry . ConsumerRegistry ; import org . gatein . wsrp . services . ServiceFactory ; import org . jboss . util . StringPropertyReplacer ; import org . jboss . xb . binding . GenericObjectModelFactory ; import org . jboss . xb . binding . UnmarshallingContext ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import org . xml . sax . Attributes ; import java . util . SortedMap ; import java . util . TreeMap ; public class XMLWSRPConsumerFactory implements GenericObjectModelFactory { private static final Logger log = LoggerFactory . getLogger ( XMLWSRPConsumerFactory . class ) ; private ConsumerRegistry consumerRegistry ; private static final boolean DEBUG = false ; private static final String WSRP_PRODUCER = "<STR_LIT>" ; public static class Property { String name ; String value ; String lang ; } public XMLWSRPConsumerFactory ( ConsumerRegistry consumerRegistry ) { this . consumerRegistry = consumerRegistry ; } public Object newRoot ( Object root , UnmarshallingContext nav , String nsURI , String localName , Attributes attrs ) { return new TreeMap < String , WSRPConsumer > ( ) ; } public Object completeRoot ( Object root , UnmarshallingContext nav , String nsURI , String localName ) { return root ; } public Object newChild ( Object parent , UnmarshallingContext unmarshallingContext , String nsURI , String localName , Attributes attributes ) { if ( parent instanceof SortedMap ) { return newChild ( ( SortedMap < String , WSRPConsumer > ) parent , unmarshallingContext , nsURI , localName , attributes ) ; } if ( parent instanceof RegistrationInfo ) { return newChild ( ( RegistrationInfo ) parent , unmarshallingContext , nsURI , localName , attributes ) ; } if ( parent instanceof WSRPConsumer ) { return newChild ( ( WSRPConsumer ) parent , unmarshallingContext , nsURI , localName , attributes ) ; } return null ; } public void addChild ( Object parent , Object child , UnmarshallingContext unmarshallingContext , String nsURI , String localName ) { if ( parent instanceof RegistrationInfo && child instanceof Property ) { addChild ( ( RegistrationInfo ) parent , ( Property ) child , unmarshallingContext , nsURI , localName ) ; } else if ( parent instanceof SortedMap && child instanceof WSRPConsumer ) { addChild ( ( SortedMap < String , WSRPConsumer > ) parent , ( WSRPConsumer ) child , unmarshallingContext , nsURI , localName ) ; } } public void setValue ( Object parent , UnmarshallingContext unmarshallingContext , String nsURI , String localName , String value ) { if ( parent instanceof EndpointConfigurationInfo ) { setValue ( ( EndpointConfigurationInfo ) parent , unmarshallingContext , nsURI , localName , value ) ; } else if ( parent instanceof Property ) { setValue ( ( Property ) parent , unmarshallingContext , nsURI , localName , value ) ; } else if ( parent instanceof RegistrationInfo ) { setValue ( ( RegistrationInfo ) parent , unmarshallingContext , nsURI , localName , value ) ; } } public Object newChild ( SortedMap < String , WSRPConsumer > consumers , UnmarshallingContext nav , String nsURI , String localName , Attributes attrs ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } if ( WSRP_PRODUCER . equals ( localName ) ) { String id = attrs . getValue ( "<STR_LIT:id>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , "<STR_LIT>" ) ; WSRPConsumer consumer = consumerRegistry . getConsumer ( id ) ; if ( consumer != null ) { String message = "<STR_LIT>" + id + "<STR_LIT>" ; if ( consumer . getProducerInfo ( ) . isActive ( ) ) { consumers . put ( id , consumer ) ; message += "<STR_LIT>" ; } else { message += "<STR_LIT>" ; } log . info ( message + "<STR_LIT>" ) ; return null ; } String expirationCache = attrs . getValue ( "<STR_LIT>" ) ; Integer expirationCacheSeconds = null ; if ( expirationCache != null ) { try { expirationCacheSeconds = new Integer ( expirationCache ) ; } catch ( NumberFormatException e ) { log . info ( "<STR_LIT>" + expirationCache + "<STR_LIT>" + id + "<STR_LIT:'>" ) ; } } String wsTimeout = attrs . getValue ( "<STR_LIT>" ) ; Integer wsTimeoutMS = ServiceFactory . DEFAULT_TIMEOUT_MS ; if ( wsTimeout != null ) { try { wsTimeoutMS = new Integer ( wsTimeout ) ; } catch ( NumberFormatException e ) { log . info ( "<STR_LIT>" + wsTimeout + "<STR_LIT>" + id + "<STR_LIT:'>" ) ; } } consumer = consumerRegistry . createConsumer ( id , expirationCacheSeconds , null ) ; consumer . getProducerInfo ( ) . getEndpointConfigurationInfo ( ) . setWSOperationTimeOut ( wsTimeoutMS ) ; return consumer ; } else { return null ; } } public Object newChild ( WSRPConsumer consumer , UnmarshallingContext nav , String nsURI , String localName , Attributes attrs ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } ProducerInfo prodInfo = consumer . getProducerInfo ( ) ; if ( "<STR_LIT>" . equals ( localName ) ) { return prodInfo . getEndpointConfigurationInfo ( ) ; } else if ( "<STR_LIT>" . equals ( localName ) ) { return new RegistrationInfo ( prodInfo ) ; } else { return null ; } } public Object newChild ( RegistrationInfo registrationInfo , UnmarshallingContext nav , String nsURI , String localName , Attributes attrs ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } if ( "<STR_LIT>" . equals ( localName ) ) { return new Property ( ) ; } return null ; } public void setValue ( EndpointConfigurationInfo endpointInfo , UnmarshallingContext nav , String nsURI , String localName , String value ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } if ( "<STR_LIT>" . equals ( localName ) ) { value = StringPropertyReplacer . replaceProperties ( value ) ; endpointInfo . setWsdlDefinitionURL ( value ) ; } } public void setValue ( RegistrationInfo registrationInfo , UnmarshallingContext nav , String nsURI , String localName , String value ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } if ( "<STR_LIT>" . equals ( localName ) ) { value = StringPropertyReplacer . replaceProperties ( value ) ; registrationInfo . setConsumerName ( value ) ; } } public void setValue ( Property property , UnmarshallingContext nav , String nsURI , String localName , String value ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } if ( "<STR_LIT:name>" . equals ( localName ) ) { value = StringPropertyReplacer . replaceProperties ( value ) ; property . name = value ; } else if ( "<STR_LIT>" . equals ( localName ) ) { value = StringPropertyReplacer . replaceProperties ( value ) ; property . lang = value ; } else if ( "<STR_LIT:value>" . equals ( localName ) ) { value = StringPropertyReplacer . replaceProperties ( value ) ; property . value = value ; } } public void addChild ( RegistrationInfo registrationInfo , Property property , UnmarshallingContext nav , String nsURI , String localName ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + localName ) ; } registrationInfo . setRegistrationPropertyValue ( property . name , property . value ) . setLang ( property . lang ) ; } public void addChild ( SortedMap < String , WSRPConsumer > consumers , WSRPConsumer consumer , UnmarshallingContext nav , String nsURI , String localName ) { ProducerInfo info = consumer . getProducerInfo ( ) ; if ( DEBUG ) { System . out . println ( "<STR_LIT>" + info . getId ( ) + "<STR_LIT>" + localName ) ; } String id = consumer . getProducerId ( ) ; consumers . put ( id , consumer ) ; log . info ( "<STR_LIT>" + id + "<STR_LIT>" ) ; try { consumerRegistry . updateProducerInfo ( info ) ; } catch ( Exception e ) { consumers . remove ( id ) ; log . info ( "<STR_LIT>" + info . getId ( ) + "<STR_LIT:'>" , e ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . registry . xml ; import org . gatein . common . xml . NullEntityResolver ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . consumer . registry . InMemoryConsumerRegistry ; import org . jboss . xb . binding . JBossXBException ; import org . jboss . xb . binding . ObjectModelFactory ; import org . jboss . xb . binding . Unmarshaller ; import org . jboss . xb . binding . UnmarshallerFactory ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import org . xml . sax . EntityResolver ; import java . io . IOException ; import java . io . InputStream ; import java . net . URL ; import java . util . SortedMap ; public class XMLConsumerRegistry extends InMemoryConsumerRegistry { private final static Logger log = LoggerFactory . getLogger ( XMLConsumerRegistry . class ) ; private static final String defaultWSRPLocation = "<STR_LIT>" ; private InputStream configurationIS ; private EntityResolver entityResolver ; public XMLConsumerRegistry ( InputStream configurationInputStream ) { configurationIS = configurationInputStream ; } public EntityResolver getEntityResolver ( ) { return entityResolver ; } public void setEntityResolver ( EntityResolver entityResolver ) { this . entityResolver = entityResolver ; } public void reloadConsumers ( ) { if ( configurationIS == null ) { URL defaultWSRPURL = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( defaultWSRPLocation ) ; try { configurationIS = defaultWSRPURL . openStream ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "<STR_LIT>" , e ) ; } } Unmarshaller unmarshaller = UnmarshallerFactory . newInstance ( ) . newUnmarshaller ( ) ; ObjectModelFactory factory = new XMLWSRPConsumerFactory ( this ) ; if ( entityResolver == null ) { log . debug ( "<STR_LIT>" ) ; entityResolver = new NullEntityResolver ( ) ; } try { unmarshaller . setEntityResolver ( entityResolver ) ; initConsumers ( ( SortedMap < String , WSRPConsumer > ) unmarshaller . unmarshal ( configurationIS , factory , null ) ) ; } catch ( JBossXBException e ) { throw new RuntimeException ( "<STR_LIT>" , e ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . registry ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . federation . FederatingPortletInvoker ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . api . session . SessionEventBroadcaster ; import org . gatein . wsrp . consumer . ConsumerException ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . gatein . wsrp . consumer . handlers . session . InMemorySessionRegistry ; import org . gatein . wsrp . consumer . handlers . session . SessionRegistry ; import org . gatein . wsrp . consumer . migration . InMemoryMigrationService ; import org . gatein . wsrp . consumer . migration . MigrationService ; import org . gatein . wsrp . consumer . spi . ConsumerRegistrySPI ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import java . util . ArrayList ; import java . util . Collection ; import java . util . HashSet ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import java . util . Set ; import java . util . concurrent . ConcurrentHashMap ; public abstract class AbstractConsumerRegistry implements ConsumerRegistrySPI { private FederatingPortletInvoker federatingPortletInvoker ; private SessionEventBroadcaster sessionEventBroadcaster = SessionEventBroadcaster . NO_OP_BROADCASTER ; private MigrationService migrationService = new InMemoryMigrationService ( ) ; private SessionRegistry sessionRegistry = new InMemorySessionRegistry ( ) ; private static final String CONSUMER_WITH_ID = "<STR_LIT>" ; private static final String RELEASE_SESSIONS_LISTENER = "<STR_LIT>" ; protected static final Logger log = LoggerFactory . getLogger ( AbstractConsumerRegistry . class ) ; protected ConsumerCache consumerCache ; protected AbstractConsumerRegistry ( ) { initConsumerCache ( ) ; } protected abstract void initConsumerCache ( ) ; public synchronized void setConsumerCache ( ConsumerCache consumers ) { if ( consumers == null ) { consumers = new InMemoryConsumerCache ( this ) ; } this . consumerCache = consumers ; } public synchronized void setSessionRegistry ( SessionRegistry sessionRegistry ) { if ( sessionRegistry == null ) { sessionRegistry = new InMemorySessionRegistry ( ) ; } this . sessionRegistry = sessionRegistry ; } public SessionRegistry getSessionRegistry ( ) { return sessionRegistry ; } public FederatingPortletInvoker getFederatingPortletInvoker ( ) { return federatingPortletInvoker ; } public synchronized void setSessionEventBroadcaster ( SessionEventBroadcaster sessionEventBroadcaster ) { if ( sessionEventBroadcaster == null ) { sessionEventBroadcaster = SessionEventBroadcaster . NO_OP_BROADCASTER ; } this . sessionEventBroadcaster = sessionEventBroadcaster ; } public MigrationService getMigrationService ( ) { return migrationService ; } public synchronized void setMigrationService ( MigrationService migrationService ) { if ( migrationService == null ) { migrationService = new InMemoryMigrationService ( ) ; } this . migrationService = migrationService ; } public WSRPConsumer createConsumer ( String id , Integer expirationCacheSeconds , String wsdlURL ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , "<STR_LIT>" ) ; if ( getConsumer ( id ) != null ) { throw new ConsumerException ( CONSUMER_WITH_ID + id + "<STR_LIT>" ) ; } ProducerInfo info = new ProducerInfo ( this ) ; info . setId ( id ) ; info . setExpirationCacheSeconds ( expirationCacheSeconds ) ; info . getEndpointConfigurationInfo ( ) . setWsdlDefinitionURL ( wsdlURL ) ; save ( info , "<STR_LIT>" + id + "<STR_LIT:'>" ) ; log . debug ( CONSUMER_WITH_ID + id + "<STR_LIT>" ) ; return createConsumerFrom ( info , true ) ; } public void destroyConsumer ( String id ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , "<STR_LIT>" ) ; WSRPConsumer consumer = getConsumer ( id ) ; if ( consumer != null ) { ProducerInfo info = consumer . getProducerInfo ( ) ; try { consumer . releaseSessions ( ) ; } catch ( PortletInvokerException e ) { log . debug ( "<STR_LIT>" + CONSUMER_WITH_ID + id + "<STR_LIT:'>" ) ; } if ( info . isRegistered ( ) ) { registerOrDeregisterConsumerWith ( id , false ) ; } deactivateConsumer ( consumer ) ; delete ( info ) ; consumerCache . removeConsumer ( id ) ; } else { throw new ConsumerException ( CONSUMER_WITH_ID + id + "<STR_LIT>" ) ; } log . debug ( CONSUMER_WITH_ID + id + "<STR_LIT>" ) ; } public void persistConsumer ( WSRPConsumer consumer ) { ParameterValidation . throwIllegalArgExceptionIfNull ( consumer , "<STR_LIT>" ) ; ProducerInfo info = consumer . getProducerInfo ( ) ; save ( info , CONSUMER_WITH_ID + info . getId ( ) + "<STR_LIT>" ) ; createConsumerFrom ( info , true ) ; } public synchronized void setFederatingPortletInvoker ( FederatingPortletInvoker federatingPortletInvoker ) { this . federatingPortletInvoker = federatingPortletInvoker ; } public WSRPConsumer createConsumerFrom ( ProducerInfo producerInfo , boolean putInCache ) { final WSRPConsumerImpl consumer = createAndActivateIfNeeded ( producerInfo ) ; if ( putInCache ) { consumerCache . putConsumer ( producerInfo . getId ( ) , consumer ) ; } return consumer ; } private WSRPConsumerImpl createAndActivateIfNeeded ( ProducerInfo producerInfo ) { final WSRPConsumerImpl consumer = new WSRPConsumerImpl ( producerInfo ) ; if ( producerInfo . isActive ( ) && ! consumer . isActive ( ) ) { activateConsumer ( consumer ) ; } return consumer ; } public void activateConsumerWith ( String id ) throws ConsumerException { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , "<STR_LIT>" ) ; activateConsumer ( getConsumer ( id ) ) ; } protected void activateConsumer ( WSRPConsumer consumer ) { startOrStopConsumer ( consumer , true , false ) ; } public void deactivateConsumerWith ( String id ) throws ConsumerException { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , "<STR_LIT>" ) ; deactivateConsumer ( getConsumer ( id ) ) ; } protected void deactivateConsumer ( WSRPConsumer consumer ) { startOrStopConsumer ( consumer , false , false ) ; } public void registerWithFederatingPortletInvoker ( WSRPConsumer consumer ) { startOrStopConsumer ( consumer , true , true ) ; } public void deregisterWithFederatingPortletInvoker ( WSRPConsumer consumer ) { startOrStopConsumer ( consumer , false , true ) ; } public long getPersistedLastModifiedForProducerInfoWith ( String id ) { ProducerInfo producerInfo = loadProducerInfo ( id ) ; if ( producerInfo == null ) { return Long . MIN_VALUE ; } else { return producerInfo . getLastModified ( ) ; } } public synchronized String updateProducerInfo ( ProducerInfo producerInfo ) { ParameterValidation . throwIllegalArgExceptionIfNull ( producerInfo , "<STR_LIT>" ) ; if ( producerInfo . getLastModified ( ) > getPersistedLastModifiedForProducerInfoWith ( producerInfo . getId ( ) ) ) { String oldId = update ( producerInfo ) ; if ( oldId != null ) { WSRPConsumer consumer = createConsumerFrom ( producerInfo , true ) ; if ( federatingPortletInvoker . isResolved ( oldId ) ) { federatingPortletInvoker . unregisterInvoker ( oldId ) ; } consumerCache . removeConsumer ( oldId ) ; consumerCache . putConsumer ( producerInfo . getId ( ) , consumer ) ; } return oldId ; } else { return null ; } } public void start ( ) throws Exception { reloadConsumers ( ) ; } public void reloadConsumers ( ) { consumerCache . initFromStorage ( ) ; } public void stop ( ) throws Exception { for ( WSRPConsumer consumer : getConsumers ( false ) ) { String producerId = consumer . getProducerId ( ) ; if ( consumer . getProducerInfo ( ) . isActive ( ) && federatingPortletInvoker . isResolved ( producerId ) ) { federatingPortletInvoker . unregisterInvoker ( producerId ) ; } try { consumer . stop ( ) ; } catch ( Exception e ) { } } } public List < WSRPConsumer > getConfiguredConsumers ( ) { return getConsumers ( true ) ; } public WSRPConsumer getConsumer ( String id ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , null ) ; return consumerCache . getConsumer ( id ) ; } public boolean containsConsumer ( String id ) { return getConsumer ( id ) != null ; } public int getConfiguredConsumerNumber ( ) { return getConfiguredConsumersIds ( ) . size ( ) ; } public void registerOrDeregisterConsumerWith ( String id , boolean register ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( id , "<STR_LIT>" , "<STR_LIT>" ) ; WSRPConsumer consumer = getConsumer ( id ) ; if ( consumer == null ) { throw new ConsumerException ( CONSUMER_WITH_ID + id + "<STR_LIT>" ) ; } try { if ( register ) { consumer . getProducerInfo ( ) . register ( ) ; } else { consumer . getProducerInfo ( ) . deregister ( ) ; } } catch ( Exception e ) { deactivateConsumer ( consumer ) ; Throwable cause = e . getCause ( ) ; throw new ConsumerException ( "<STR_LIT>" + ( register ? "<STR_LIT>" : "<STR_LIT>" ) + CONSUMER_WITH_ID + id + "<STR_LIT:'>" , cause != null ? cause : e ) ; } } private void startOrStopConsumer ( WSRPConsumer consumer , boolean start , boolean registerOrDeregisterOnly ) { ParameterValidation . throwIllegalArgExceptionIfNull ( consumer , "<STR_LIT>" ) ; try { String id = consumer . getProducerId ( ) ; if ( start ) { if ( ! registerOrDeregisterOnly ) { consumer . refresh ( false ) ; } if ( ! federatingPortletInvoker . isResolved ( id ) ) { federatingPortletInvoker . registerInvoker ( id , consumer ) ; } sessionEventBroadcaster . registerListener ( getListenerIdFrom ( id ) , consumer ) ; } else { if ( ! registerOrDeregisterOnly ) { consumer . deactivate ( ) ; } if ( federatingPortletInvoker . isResolved ( id ) ) { federatingPortletInvoker . unregisterInvoker ( id ) ; } sessionEventBroadcaster . unregisterListener ( getListenerIdFrom ( id ) ) ; } } catch ( Exception e ) { throw new ConsumerException ( "<STR_LIT>" + ( start ? "<STR_LIT:start>" : "<STR_LIT>" ) + "<STR_LIT>" + consumer . getProducerId ( ) + "<STR_LIT:'>" , e ) ; } updateProducerInfo ( consumer . getProducerInfo ( ) ) ; } private String getListenerIdFrom ( String id ) { return RELEASE_SESSIONS_LISTENER + id ; } protected List < WSRPConsumer > getConsumers ( boolean startConsumers ) { final Collection < WSRPConsumer > consumerz = consumerCache . getConsumers ( ) ; if ( startConsumers ) { for ( WSRPConsumer consumer : consumerz ) { final ProducerInfo info = consumer . getProducerInfo ( ) ; if ( info . isActive ( ) && ! consumer . isActive ( ) ) { try { consumer . refresh ( false ) ; } catch ( Exception e ) { log . info ( "<STR_LIT>" + consumer . getProducerId ( ) ) ; info . setActiveAndSave ( false ) ; } } } } return new ArrayList < WSRPConsumer > ( consumerz ) ; } protected class ProducerInfoIterator implements Iterator < ProducerInfo > { private Iterator < WSRPConsumer > consumers ; public ProducerInfoIterator ( Iterator < WSRPConsumer > consumers ) { this . consumers = consumers ; } public boolean hasNext ( ) { return consumers . hasNext ( ) ; } public ProducerInfo next ( ) { return consumers . next ( ) . getProducerInfo ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } } protected static class InMemoryConsumerCache implements ConsumerCache { private Map < String , WSRPConsumer > consumers = new ConcurrentHashMap < String , WSRPConsumer > ( <NUM_LIT:11> ) ; private boolean invalidated ; private ConsumerRegistrySPI registry ; public InMemoryConsumerCache ( ConsumerRegistrySPI registry ) { this . registry = registry ; } public void initFromStorage ( ) { clear ( ) ; Iterator < ProducerInfo > infosFromStorage = registry . getProducerInfosFromStorage ( ) ; while ( infosFromStorage . hasNext ( ) ) { ProducerInfo info = infosFromStorage . next ( ) ; consumers . put ( info . getId ( ) , createConsumer ( info ) ) ; } setInvalidated ( false ) ; } private WSRPConsumer createConsumer ( ProducerInfo info ) { return registry . createConsumerFrom ( info , false ) ; } public Collection < WSRPConsumer > getConsumers ( ) { refreshIfNeeded ( ) ; return consumers . values ( ) ; } public WSRPConsumer getConsumer ( String id ) { WSRPConsumer consumer = consumers . get ( id ) ; return getUpdatedConsumer ( id , consumer ) ; } private WSRPConsumer getUpdatedConsumer ( String id , WSRPConsumer consumer ) { if ( consumer == null || consumer . getProducerInfo ( ) . getLastModified ( ) < registry . getPersistedLastModifiedForProducerInfoWith ( id ) ) { ProducerInfo info = registry . loadProducerInfo ( id ) ; if ( info != null ) { consumer = createConsumer ( info ) ; consumers . put ( id , consumer ) ; return consumer ; } else { return null ; } } else { return consumer ; } } public WSRPConsumer removeConsumer ( String id ) { return consumers . remove ( id ) ; } public void putConsumer ( String id , WSRPConsumer consumer ) { consumers . put ( id , consumer ) ; } public void clear ( ) { consumers . clear ( ) ; invalidated = true ; } public boolean isInvalidated ( ) { return invalidated ; } public void setInvalidated ( boolean invalidated ) { this . invalidated = invalidated ; } protected void refreshIfNeeded ( ) { if ( isInvalidated ( ) ) { consumers . clear ( ) ; } Collection < String > consumersIds = registry . getConfiguredConsumersIds ( ) ; Set < String > obsoleteConsumers = new HashSet < String > ( consumers . keySet ( ) ) ; obsoleteConsumers . removeAll ( consumersIds ) ; for ( String obsolete : obsoleteConsumers ) { consumers . remove ( obsolete ) ; } for ( String id : consumersIds ) { WSRPConsumer consumerInfo = consumers . get ( id ) ; if ( consumerInfo != null ) { getUpdatedConsumer ( id , consumerInfo ) ; } else { ProducerInfo producerInfo = registry . loadProducerInfo ( id ) ; consumers . put ( id , createConsumer ( producerInfo ) ) ; } } setInvalidated ( false ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . registry ; import org . gatein . pc . api . NoSuchPortletException ; import org . gatein . pc . federation . FederatedPortletInvoker ; import org . gatein . pc . federation . FederatingPortletInvoker ; import org . gatein . pc . federation . PortletInvokerResolver ; import org . gatein . pc . federation . impl . FederatedPortletInvokerService ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . consumer . ConsumerException ; import org . gatein . wsrp . consumer . spi . ConsumerRegistrySPI ; import java . util . Collection ; public class RegisteringPortletInvokerResolver implements PortletInvokerResolver { private transient ConsumerRegistrySPI consumerRegistry ; public FederatedPortletInvoker resolvePortletInvokerFor ( String invokerId , FederatingPortletInvoker callingInvoker , String compoundPortletId ) throws NoSuchPortletException { FederatingPortletInvoker registryInvoker = consumerRegistry . getFederatingPortletInvoker ( ) ; if ( registryInvoker != callingInvoker ) { throw new IllegalArgumentException ( "<STR_LIT>" + registryInvoker + "<STR_LIT>" + callingInvoker + "<STR_LIT:)>" ) ; } WSRPConsumer consumer = consumerRegistry . getConsumer ( invokerId ) ; if ( consumer == null ) { if ( compoundPortletId != null ) { throw new NoSuchPortletException ( compoundPortletId ) ; } else { return null ; } } else { synchronized ( this ) { try { consumerRegistry . registerWithFederatingPortletInvoker ( consumer ) ; return new FederatedPortletInvokerService ( callingInvoker , invokerId , consumer ) ; } catch ( ConsumerException e ) { return null ; } } } } public boolean knows ( String invoker ) { return consumerRegistry . containsConsumer ( invoker ) ; } public Collection < String > getKnownInvokerIds ( ) { return consumerRegistry . getConfiguredConsumersIds ( ) ; } public void setConsumerRegistry ( ConsumerRegistrySPI consumerRegistry ) { this . consumerRegistry = consumerRegistry ; } } </s>
|
<s> package org . gatein . wsrp . consumer . registry ; import org . gatein . wsrp . WSRPConsumer ; import java . util . Collection ; public interface ConsumerCache { Collection < WSRPConsumer > getConsumers ( ) ; WSRPConsumer getConsumer ( String id ) ; WSRPConsumer removeConsumer ( String id ) ; void putConsumer ( String id , WSRPConsumer consumer ) ; void clear ( ) ; boolean isInvalidated ( ) ; void setInvalidated ( boolean invalidated ) ; void initFromStorage ( ) ; } </s>
|
<s> package org . gatein . wsrp . consumer . registry ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . federation . impl . FederatingPortletInvokerService ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . migration . InMemoryMigrationService ; import java . util . Collection ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import java . util . SortedMap ; import java . util . TreeMap ; import java . util . UUID ; public class InMemoryConsumerRegistry extends AbstractConsumerRegistry { private SortedMap < String , WSRPConsumer > consumers ; private Map < String , String > keysToIds ; public InMemoryConsumerRegistry ( ) { initConsumers ( null ) ; setFederatingPortletInvoker ( new FederatingPortletInvokerService ( ) ) ; setMigrationService ( new InMemoryMigrationService ( ) ) ; } @ Override protected void initConsumerCache ( ) { setConsumerCache ( new InMemoryConsumerCache ( this ) ) ; } @ Override public WSRPConsumer createConsumerFrom ( ProducerInfo producerInfo , boolean putInCache ) { WSRPConsumer consumer = super . createConsumerFrom ( producerInfo , putInCache ) ; String id = consumer . getProducerId ( ) ; consumers . put ( id , consumer ) ; ProducerInfo info = consumer . getProducerInfo ( ) ; keysToIds . put ( info . getKey ( ) , id ) ; return consumer ; } @ Override public String updateProducerInfo ( ProducerInfo producerInfo ) { String oldId = super . updateProducerInfo ( producerInfo ) ; if ( oldId != null ) { keysToIds . put ( producerInfo . getKey ( ) , producerInfo . getId ( ) ) ; consumers . remove ( oldId ) ; } return oldId ; } public void save ( ProducerInfo info , String messageOnError ) { info . setKey ( UUID . randomUUID ( ) . toString ( ) ) ; keysToIds . put ( info . getKey ( ) , info . getId ( ) ) ; } public void delete ( ProducerInfo info ) { String key = info . getKey ( ) ; String removed = keysToIds . remove ( key ) ; if ( removed != null ) { consumers . remove ( removed ) ; } } public String update ( ProducerInfo producerInfo ) { String key = producerInfo . getKey ( ) ; String oldId = keysToIds . get ( key ) ; String newId = producerInfo . getId ( ) ; if ( oldId . equals ( newId ) ) { return null ; } else { keysToIds . put ( key , newId ) ; WSRPConsumer consumer = consumers . get ( oldId ) ; consumers . put ( newId , consumer ) ; return oldId ; } } @ Override public void reloadConsumers ( ) { } public Iterator < ProducerInfo > getProducerInfosFromStorage ( ) { return new ProducerInfoIterator ( consumers . values ( ) . iterator ( ) ) ; } public ProducerInfo loadProducerInfo ( String id ) { if ( keysToIds . containsValue ( id ) ) { final WSRPConsumer consumer = consumers . get ( id ) ; return consumer != null ? consumer . getProducerInfo ( ) : null ; } else { return null ; } } @ Override public void stop ( ) throws Exception { super . stop ( ) ; consumers . clear ( ) ; keysToIds . clear ( ) ; consumers = null ; keysToIds = null ; } public Collection < String > getConfiguredConsumersIds ( ) { return consumers . keySet ( ) ; } protected void initConsumers ( SortedMap < String , WSRPConsumer > consumers ) { if ( ! ParameterValidation . existsAndIsNotEmpty ( consumers ) ) { consumers = new TreeMap < String , WSRPConsumer > ( ) ; } this . consumers = consumers ; int size = consumers . size ( ) ; keysToIds = size == <NUM_LIT:0> ? new HashMap < String , String > ( ) : new HashMap < String , String > ( size ) ; for ( WSRPConsumer consumer : consumers . values ( ) ) { keysToIds . put ( consumer . getProducerInfo ( ) . getKey ( ) , consumer . getProducerId ( ) ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer ; import org . gatein . common . NotYetImplemented ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . InvokerUnavailableException ; import org . gatein . pc . api . NoSuchPortletException ; import org . gatein . pc . api . Portlet ; import org . gatein . pc . api . PortletContext ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . info . EventInfo ; import org . gatein . pc . api . info . TypeInfo ; import org . gatein . wsrp . WSRPConstants ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . consumer . portlet . WSRPPortlet ; import org . gatein . wsrp . consumer . portlet . info . WSRPEventInfo ; import org . gatein . wsrp . consumer . portlet . info . WSRPPortletInfo ; import org . gatein . wsrp . consumer . spi . ConsumerRegistrySPI ; import org . gatein . wsrp . servlet . UserAccess ; import org . gatein . wsrp . spec . v2 . WSRP2Constants ; import org . oasis . wsrp . v2 . CookieProtocol ; import org . oasis . wsrp . v2 . EventDescription ; import org . oasis . wsrp . v2 . ExportDescription ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . ExtensionDescription ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . ItemDescription ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModelTypes ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . PortletPropertyDescriptionResponse ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ServiceDescription ; import org . oasis . wsrp . v2 . WSRPV2PortletManagementPortType ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . xml . bind . annotation . XmlRootElement ; import javax . xml . namespace . QName ; import javax . xml . ws . Holder ; import java . util . Collection ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . LinkedHashMap ; import java . util . List ; import java . util . Map ; import java . util . Set ; public class ProducerInfo { private final static Logger log = LoggerFactory . getLogger ( ProducerInfo . class ) ; private final static boolean debug = log . isDebugEnabled ( ) ; public static final Integer DEFAULT_CACHE_VALUE = <NUM_LIT> ; private String key ; private EndpointConfigurationInfo persistentEndpointInfo ; private RegistrationInfo persistentRegistrationInfo ; private String persistentId ; private Integer persistentExpirationCacheSeconds = DEFAULT_CACHE_VALUE ; private boolean persistentActive ; private boolean isModifyRegistrationRequired ; private long lastModified ; private transient CookieProtocol requiresInitCookie ; private transient Map < String , Portlet > popsMap ; private transient Map < String , Portlet > ccpsMap ; private transient Map < String , Set < Portlet > > portletGroups ; private transient long expirationTimeMillis ; private transient final ConsumerRegistrySPI registry ; private static final String ERASED_LOCAL_REGISTRATION_INFORMATION = "<STR_LIT>" ; private transient RegistrationInfo expectedRegistrationInfo ; private transient Map < String , ItemDescription > customModes ; private transient Map < String , ItemDescription > customWindowStates ; private transient Map < QName , EventInfo > eventDescriptions ; private transient Set < String > supportedOptions = Collections . emptySet ( ) ; public ProducerInfo ( ConsumerRegistrySPI consumerRegistry ) { persistentEndpointInfo = new EndpointConfigurationInfo ( ) ; persistentRegistrationInfo = RegistrationInfo . createUndeterminedRegistration ( this ) ; this . registry = consumerRegistry ; } @ Override public boolean equals ( Object o ) { if ( this == o ) { return true ; } if ( o == null || getClass ( ) != o . getClass ( ) ) { return false ; } ProducerInfo that = ( ProducerInfo ) o ; if ( key != null ? ! key . equals ( that . key ) : that . key != null ) { return false ; } if ( ! getId ( ) . equals ( that . getId ( ) ) ) { return false ; } return true ; } @ Override public int hashCode ( ) { int result = key != null ? key . hashCode ( ) : <NUM_LIT:0> ; result = <NUM_LIT:31> * result + getId ( ) . hashCode ( ) ; return result ; } @ Override public String toString ( ) { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<STR_LIT>" ) ; sb . append ( "<STR_LIT>" ) . append ( key ) . append ( '<STR_LIT>' ) ; sb . append ( "<STR_LIT>" ) . append ( getId ( ) ) . append ( '<STR_LIT>' ) ; sb . append ( '<CHAR_LIT:}>' ) ; return sb . toString ( ) ; } public ConsumerRegistrySPI getRegistry ( ) { return registry ; } public String getKey ( ) { return key ; } public void setKey ( String key ) { this . key = key ; } public Set < String > getSupportedCustomModes ( ) { if ( customModes == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( customModes . keySet ( ) ) ; } public Set < String > getSupportedCustomWindowStates ( ) { if ( customWindowStates == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( customWindowStates . keySet ( ) ) ; } public EndpointConfigurationInfo getEndpointConfigurationInfo ( ) { return persistentEndpointInfo ; } public void setEndpointConfigurationInfo ( EndpointConfigurationInfo endpointConfigurationInfo ) { ParameterValidation . throwIllegalArgExceptionIfNull ( endpointConfigurationInfo , "<STR_LIT>" ) ; this . persistentEndpointInfo = endpointConfigurationInfo ; } public RegistrationInfo getRegistrationInfo ( ) { persistentRegistrationInfo . setParent ( this ) ; return persistentRegistrationInfo ; } public void setRegistrationInfo ( RegistrationInfo registrationInfo ) { ParameterValidation . throwIllegalArgExceptionIfNull ( registrationInfo , "<STR_LIT>" ) ; this . persistentRegistrationInfo = registrationInfo ; } public boolean isRegistered ( ) { return persistentRegistrationInfo . isRegistered ( ) ; } public boolean isRegistrationRequired ( ) { return persistentRegistrationInfo . isRegistrationDeterminedRequired ( ) ; } public boolean isRegistrationChecked ( ) { return persistentRegistrationInfo . isRegistrationRequired ( ) != null ; } public boolean hasLocalRegistrationInfo ( ) { return persistentRegistrationInfo . hasLocalInfo ( ) ; } public boolean isActive ( ) { return persistentActive ; } public void setActive ( boolean active ) { setInternalActive ( active ) ; } private boolean setInternalActive ( boolean active ) { final boolean modified = modifyNowIfNeeded ( persistentActive , active ) ; this . persistentActive = active ; return modified ; } public String getId ( ) { return persistentId ; } public void setId ( String id ) { modifyNowIfNeeded ( persistentId , id ) ; this . persistentId = id ; } private boolean modifyNowIfNeeded ( Object oldValue , Object newValue ) { if ( ParameterValidation . isOldAndNewDifferent ( oldValue , newValue ) ) { modifyNow ( ) ; return true ; } else { return false ; } } public void setActiveAndSave ( boolean active ) { if ( setInternalActive ( active ) ) { registry . updateProducerInfo ( this ) ; } } public boolean isModifyRegistrationRequired ( ) { return isModifyRegistrationRequired || persistentRegistrationInfo . isModifyRegistrationNeeded ( ) ; } public void setModifyRegistrationRequired ( boolean modifyRegistrationRequired ) { modifyNowIfNeeded ( isModifyRegistrationRequired , modifyRegistrationRequired ) ; this . isModifyRegistrationRequired = modifyRegistrationRequired ; } public CookieProtocol getRequiresInitCookie ( ) { return requiresInitCookie ; } public RegistrationInfo getExpectedRegistrationInfo ( ) { return expectedRegistrationInfo ; } public boolean refresh ( boolean forceRefresh ) throws PortletInvokerException { return detailedRefresh ( forceRefresh ) . didRefreshHappen ( ) ; } public RefreshResult detailedRefresh ( boolean forceRefresh ) throws PortletInvokerException { RefreshResult result = internalRefresh ( forceRefresh ) ; if ( RefreshResult . Status . FAILURE . equals ( result . getStatus ( ) ) ) { setActiveAndSave ( false ) ; return result ; } if ( result . didRefreshHappen ( ) ) { if ( result . hasIssues ( ) ) { setActive ( false ) ; expectedRegistrationInfo = new RegistrationInfo ( this . persistentRegistrationInfo ) ; expectedRegistrationInfo . refresh ( result . getServiceDescription ( ) , getId ( ) , true , true , true ) ; } else { if ( ! isActive ( ) ) { setActive ( true ) ; } expectedRegistrationInfo = persistentRegistrationInfo ; } registry . updateProducerInfo ( this ) ; } return result ; } private RefreshResult internalRefresh ( boolean forceRefresh ) throws PortletInvokerException { ServiceDescription serviceDescription ; if ( isModifyRegistrationRequired ( ) ) { return new RefreshResult ( RefreshResult . Status . MODIFY_REGISTRATION_REQUIRED ) ; } if ( forceRefresh || isRefreshNeeded ( true ) ) { log . debug ( "<STR_LIT>" + getId ( ) + "<STR_LIT:'>" ) ; RefreshResult result = new RefreshResult ( ) ; try { persistentEndpointInfo . refresh ( ) ; } catch ( InvokerUnavailableException e ) { log . debug ( "<STR_LIT>" + e , e ) ; try { persistentEndpointInfo . forceRefresh ( ) ; } catch ( InvokerUnavailableException e1 ) { result . setStatus ( RefreshResult . Status . FAILURE ) ; return result ; } } try { serviceDescription = getUnmanagedServiceDescription ( persistentRegistrationInfo . isUndetermined ( ) ) ; result . setServiceDescription ( serviceDescription ) ; } catch ( OperationFailed operationFailedFault ) { if ( hasLocalRegistrationInfo ( ) ) { log . debug ( "<STR_LIT>" , operationFailedFault ) ; return handleModifyRegistrationNeeded ( result ) ; } else { serviceDescription = rethrowAsInvokerUnvailable ( operationFailedFault ) ; } } catch ( InvalidRegistration invalidRegistrationFault ) { log . debug ( "<STR_LIT>" , invalidRegistrationFault ) ; serviceDescription = getServiceDescription ( true ) ; result . setServiceDescription ( serviceDescription ) ; RefreshResult registrationResult = internalRefreshRegistration ( serviceDescription , false , true , true ) ; if ( registrationResult . hasIssues ( ) ) { setActiveAndSave ( false ) ; rethrowAsInvokerUnvailable ( invalidRegistrationFault ) ; } return refreshInfo ( false , serviceDescription , result ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { return handleModifyRegistrationNeeded ( result ) ; } return refreshInfo ( forceRefresh , serviceDescription , result ) ; } return new RefreshResult ( RefreshResult . Status . BYPASSED ) ; } private RefreshResult handleModifyRegistrationNeeded ( RefreshResult result ) throws PortletInvokerException { ServiceDescription serviceDescription ; serviceDescription = getServiceDescription ( true ) ; result . setServiceDescription ( serviceDescription ) ; RefreshResult registrationResult = internalRefreshRegistration ( serviceDescription , false , true , true ) ; if ( registrationResult . hasIssues ( ) ) { setModifyRegistrationRequired ( true ) ; setActive ( false ) ; } else { log . debug ( "<STR_LIT>" ) ; modifyRegistration ( true ) ; } result . setRegistrationResult ( registrationResult ) ; return result ; } private RefreshResult refreshInfo ( boolean forceRefresh , ServiceDescription serviceDescription , RefreshResult result ) throws PortletInvokerException { requiresInitCookie = serviceDescription . getRequiresInitCookie ( ) ; log . debug ( "<STR_LIT>" + requiresInitCookie ) ; final List < String > supportedOptions = serviceDescription . getSupportedOptions ( ) ; if ( ParameterValidation . existsAndIsNotEmpty ( supportedOptions ) ) { this . supportedOptions = new HashSet < String > ( supportedOptions ) ; } customModes = toMap ( serviceDescription . getCustomModeDescriptions ( ) ) ; customWindowStates = toMap ( serviceDescription . getCustomWindowStateDescriptions ( ) ) ; List < EventDescription > eventDescriptions = serviceDescription . getEventDescriptions ( ) ; if ( ! eventDescriptions . isEmpty ( ) ) { this . eventDescriptions = new HashMap < QName , EventInfo > ( eventDescriptions . size ( ) ) ; for ( final EventDescription event : eventDescriptions ) { QName name = event . getName ( ) ; EventInfo eventInfo = new WSRPEventInfo ( name , WSRPUtils . convertToCommonLocalizedStringOrNull ( event . getLabel ( ) ) , WSRPUtils . convertToCommonLocalizedStringOrNull ( event . getDescription ( ) ) , new TypeInfo ( ) { public String getName ( ) { return event . getType ( ) . toString ( ) ; } public XmlRootElement getXMLBinding ( ) { throw new NotYetImplemented ( ) ; } } , event . getAliases ( ) ) ; this . eventDescriptions . put ( name , eventInfo ) ; } } if ( serviceDescription . isRequiresRegistration ( ) ) { RefreshResult registrationResult = internalRefreshRegistration ( serviceDescription , true , forceRefresh , false ) ; if ( ! registrationResult . hasIssues ( ) ) { registrationResult = register ( serviceDescription , false ) ; if ( ! registrationResult . hasIssues ( ) ) { serviceDescription = getServiceDescription ( false ) ; } extractOfferedPortlets ( serviceDescription ) ; } result . setRegistrationResult ( registrationResult ) ; } else { log . debug ( "<STR_LIT>" ) ; persistentRegistrationInfo = new RegistrationInfo ( this , false ) ; extractOfferedPortlets ( serviceDescription ) ; } modifyNow ( ) ; return result ; } private Map < String , ItemDescription > toMap ( List < ItemDescription > itemDescriptions ) { if ( itemDescriptions == null ) { return null ; } else { Map < String , ItemDescription > result = new HashMap < String , ItemDescription > ( itemDescriptions . size ( ) ) ; for ( ItemDescription itemDescription : itemDescriptions ) { result . put ( itemDescription . getItemName ( ) , itemDescription ) ; } return result ; } } private Map extractOfferedPortlets ( ServiceDescription sd ) { if ( sd == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } List < PortletDescription > portletDescriptions = sd . getOfferedPortlets ( ) ; if ( portletDescriptions != null ) { int length = portletDescriptions . size ( ) ; log . debug ( "<STR_LIT>" + length + "<STR_LIT>" ) ; popsMap = new LinkedHashMap < String , Portlet > ( length ) ; portletGroups = new HashMap < String , Set < Portlet > > ( ) ; for ( PortletDescription portletDescription : portletDescriptions ) { WSRPPortlet wsrpPortlet = createWSRPPortletFromPortletDescription ( portletDescription ) ; if ( wsrpPortlet != null ) { popsMap . put ( wsrpPortlet . getContext ( ) . getId ( ) , wsrpPortlet ) ; } } } else { popsMap = Collections . emptyMap ( ) ; portletGroups = Collections . emptyMap ( ) ; } resetCacheTimerIfNeeded ( ) ; return popsMap ; } WSRPPortlet createWSRPPortletFromPortletDescription ( PortletDescription portletDescription ) { ParameterValidation . throwIllegalArgExceptionIfNull ( portletDescription , "<STR_LIT>" ) ; String portletHandle = portletDescription . getPortletHandle ( ) ; log . debug ( "<STR_LIT>" + portletHandle + "<STR_LIT>" ) ; WSRPPortletInfo info = new WSRPPortletInfo ( portletDescription , this ) ; WSRPPortlet wsrpPortlet = null ; if ( info . isUsesMethodGet ( ) ) { log . warn ( "<STR_LIT>" + portletHandle + "<STR_LIT>" + "<STR_LIT>" + getId ( ) ) ; } else { if ( info . isHasUserSpecificState ( ) ) { log . debug ( "<STR_LIT>" + portletHandle + "<STR_LIT>" ) ; } wsrpPortlet = new WSRPPortlet ( PortletContext . createPortletContext ( portletHandle , false ) , info ) ; String portletGroupId = portletDescription . getGroupID ( ) ; if ( portletGroupId != null ) { Set < Portlet > groupedPortlets = portletGroups . get ( portletGroupId ) ; if ( groupedPortlets == null ) { groupedPortlets = new HashSet < Portlet > ( ) ; portletGroups . put ( portletGroupId , groupedPortlets ) ; } groupedPortlets . add ( wsrpPortlet ) ; } } return wsrpPortlet ; } public Portlet getPortlet ( PortletContext portletContext ) throws PortletInvokerException { String portletHandle = portletContext . getId ( ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( portletHandle , "<STR_LIT>" , "<STR_LIT>" ) ; log . debug ( "<STR_LIT>" + portletHandle + "<STR_LIT:'>" ) ; boolean justRefreshed = refresh ( false ) ; Portlet portlet = getPortletFromCaches ( portletHandle , justRefreshed ) ; if ( portlet != null ) { log . debug ( "<STR_LIT>" ) ; return portlet ; } else { log . debug ( "<STR_LIT>" ) ; try { Holder < PortletDescription > descriptionHolder = new Holder < PortletDescription > ( ) ; persistentEndpointInfo . getPortletManagementService ( ) . getPortletDescription ( getRegistrationContext ( ) , WSRPUtils . convertToWSRPPortletContext ( portletContext ) , UserAccess . getUserContext ( ) , WSRPConstants . getDefaultLocales ( ) , descriptionHolder , new Holder < ResourceList > ( ) , new Holder < List < Extension > > ( ) ) ; portlet = createWSRPPortletFromPortletDescription ( descriptionHolder . value ) ; if ( ccpsMap == null ) { ccpsMap = new HashMap < String , Portlet > ( ) ; } ccpsMap . put ( portletHandle , portlet ) ; return portlet ; } catch ( InvalidHandle invalidHandleFault ) { throw new NoSuchPortletException ( invalidHandleFault , portletHandle ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + getId ( ) + "<STR_LIT>" , e ) ; justRefreshed = refresh ( true ) ; portlet = getPortletFromCaches ( portletHandle , justRefreshed ) ; if ( portlet == null ) { throw new NoSuchPortletException ( portletHandle ) ; } else { return portlet ; } } } } private Portlet getPortletFromCaches ( String portletHandle , boolean justRefreshed ) { Portlet portlet = null ; if ( justRefreshed || ( useCache ( ) && ! isCacheExpired ( ) ) ) { log . debug ( "<STR_LIT>" ) ; portlet = popsMap . get ( portletHandle ) ; if ( portlet == null && ccpsMap != null ) { log . debug ( "<STR_LIT>" ) ; portlet = ccpsMap . get ( portletHandle ) ; } } return portlet ; } Map < String , Set < Portlet > > getPortletGroupMap ( ) throws PortletInvokerException { return portletGroups ; } public Map < String , Portlet > getPortletMap ( ) throws PortletInvokerException { refresh ( false ) ; return popsMap ; } private boolean useCache ( ) { return persistentExpirationCacheSeconds != null && persistentExpirationCacheSeconds > <NUM_LIT:0> ; } private void resetCacheTimerIfNeeded ( ) { expirationTimeMillis = System . currentTimeMillis ( ) + ( getSafeExpirationCacheSeconds ( ) * <NUM_LIT:1000> ) ; } private boolean isCacheExpired ( ) { boolean result = ! useCache ( ) || System . currentTimeMillis ( ) > expirationTimeMillis || popsMap == null || portletGroups == null ; if ( result ) { log . debug ( "<STR_LIT>" ) ; } return result ; } public Integer getExpirationCacheSeconds ( ) { return persistentExpirationCacheSeconds ; } public void setExpirationCacheSeconds ( Integer expirationCacheSeconds ) { if ( modifyNowIfNeeded ( persistentExpirationCacheSeconds , expirationCacheSeconds ) ) { Integer previousMS = getSafeExpirationCacheSeconds ( ) * <NUM_LIT:1000> ; this . persistentExpirationCacheSeconds = expirationCacheSeconds ; long lastExpirationTimeChange = expirationTimeMillis - previousMS ; int newMS = getSafeExpirationCacheSeconds ( ) * <NUM_LIT:1000> ; if ( lastExpirationTimeChange > <NUM_LIT:0> ) { expirationTimeMillis = lastExpirationTimeChange + newMS ; } else { expirationTimeMillis = System . currentTimeMillis ( ) ; } } } private int getSafeExpirationCacheSeconds ( ) { return useCache ( ) ? persistentExpirationCacheSeconds : <NUM_LIT:0> ; } private ServiceDescription getUnmanagedServiceDescription ( boolean asUnregistered ) throws PortletInvokerException , OperationFailed , InvalidRegistration , ModifyRegistrationRequired { ServiceDescription serviceDescription ; try { Holder < Boolean > requiresRegistration = new Holder < Boolean > ( ) ; Holder < List < PortletDescription > > offeredPortlets = new Holder < List < PortletDescription > > ( ) ; Holder < List < ItemDescription > > userCategoryDescriptions = new Holder < List < ItemDescription > > ( ) ; Holder < List < ItemDescription > > windowStateDescriptions = new Holder < List < ItemDescription > > ( ) ; Holder < List < ItemDescription > > modeDescriptions = new Holder < List < ItemDescription > > ( ) ; Holder < CookieProtocol > requiresInitCookie = new Holder < CookieProtocol > ( ) ; Holder < ModelDescription > registrationPropertyDescription = new Holder < ModelDescription > ( ) ; Holder < List < String > > locales = new Holder < List < String > > ( ) ; Holder < ResourceList > resourceList = new Holder < ResourceList > ( ) ; Holder < List < EventDescription > > eventDescriptions = new Holder < List < EventDescription > > ( ) ; Holder < ModelTypes > schemaTypes = new Holder < ModelTypes > ( ) ; Holder < List < String > > supportedOptions = new Holder < List < String > > ( ) ; Holder < ExportDescription > exportDescription = new Holder < ExportDescription > ( ) ; Holder < Boolean > mayReturnRegistrationState = new Holder < Boolean > ( ) ; final Holder < List < ExtensionDescription > > extensionDescriptions = new Holder < List < ExtensionDescription > > ( ) ; final Holder < List < Extension > > extensions = new Holder < List < Extension > > ( ) ; persistentEndpointInfo . getServiceDescriptionService ( ) . getServiceDescription ( asUnregistered ? null : getRegistrationContext ( ) , WSRPConstants . getDefaultLocales ( ) , null , UserAccess . getUserContext ( ) , requiresRegistration , offeredPortlets , userCategoryDescriptions , extensionDescriptions , windowStateDescriptions , modeDescriptions , requiresInitCookie , registrationPropertyDescription , locales , resourceList , eventDescriptions , schemaTypes , supportedOptions , exportDescription , mayReturnRegistrationState , extensions ) ; serviceDescription = WSRPTypeFactory . createServiceDescription ( requiresRegistration . value ) ; serviceDescription . setRegistrationPropertyDescription ( registrationPropertyDescription . value ) ; serviceDescription . setRequiresInitCookie ( requiresInitCookie . value ) ; serviceDescription . setResourceList ( resourceList . value ) ; serviceDescription . setSchemaType ( schemaTypes . value ) ; serviceDescription . setExportDescription ( exportDescription . value ) ; serviceDescription . setMayReturnRegistrationState ( mayReturnRegistrationState . value ) ; if ( ParameterValidation . existsAndIsNotEmpty ( modeDescriptions . value ) ) { serviceDescription . getCustomModeDescriptions ( ) . addAll ( modeDescriptions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( windowStateDescriptions . value ) ) { serviceDescription . getCustomWindowStateDescriptions ( ) . addAll ( windowStateDescriptions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( locales . value ) ) { serviceDescription . getLocales ( ) . addAll ( locales . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( offeredPortlets . value ) ) { serviceDescription . getOfferedPortlets ( ) . addAll ( offeredPortlets . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( userCategoryDescriptions . value ) ) { serviceDescription . getUserCategoryDescriptions ( ) . addAll ( userCategoryDescriptions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( eventDescriptions . value ) ) { serviceDescription . getEventDescriptions ( ) . addAll ( eventDescriptions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( extensionDescriptions . value ) ) { serviceDescription . getExtensionDescriptions ( ) . addAll ( extensionDescriptions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( extensions . value ) ) { serviceDescription . getExtensions ( ) . addAll ( extensions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( supportedOptions . value ) ) { serviceDescription . getSupportedOptions ( ) . addAll ( supportedOptions . value ) ; } return serviceDescription ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" , e ) ; setActiveAndSave ( false ) ; if ( e instanceof InvalidRegistration ) { resetRegistration ( ) ; throw ( InvalidRegistration ) e ; } else if ( e instanceof OperationFailed ) { throw ( OperationFailed ) e ; } else if ( e instanceof ModifyRegistrationRequired ) { throw ( ModifyRegistrationRequired ) e ; } return rethrowAsInvokerUnvailable ( e ) ; } } ServiceDescription getServiceDescription ( boolean asUnregistered ) throws PortletInvokerException { try { return getUnmanagedServiceDescription ( asUnregistered ) ; } catch ( OperationFailed operationFailedFault ) { return rethrowAsInvokerUnvailable ( operationFailedFault ) ; } catch ( InvalidRegistration invalidRegistrationFault ) { return rethrowAsInvokerUnvailable ( invalidRegistrationFault ) ; } catch ( ModifyRegistrationRequired modifyRegistrationRequired ) { return rethrowAsInvokerUnvailable ( modifyRegistrationRequired ) ; } } private ServiceDescription rethrowAsInvokerUnvailable ( Exception e ) throws InvokerUnavailableException { Throwable cause = e . getCause ( ) ; throw new InvokerUnavailableException ( "<STR_LIT>" + getId ( ) + "<STR_LIT>" , cause == null ? e : cause ) ; } public RegistrationContext getRegistrationContext ( ) throws PortletInvokerException { if ( persistentRegistrationInfo . isUndetermined ( ) ) { refresh ( false ) ; } return persistentRegistrationInfo . getRegistrationContext ( ) ; } public void resetRegistration ( ) throws PortletInvokerException { persistentRegistrationInfo . resetRegistration ( ) ; invalidateCache ( ) ; modifyNow ( ) ; registry . updateProducerInfo ( this ) ; } void modifyNow ( ) { setLastModified ( System . nanoTime ( ) ) ; } public PortletPropertyDescriptionResponse getPropertyDescriptionsFor ( String portletHandle ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( portletHandle , "<STR_LIT>" , null ) ; try { WSRPV2PortletManagementPortType service = getEndpointConfigurationInfo ( ) . getPortletManagementService ( ) ; Holder < ModelDescription > modelDescription = new Holder < ModelDescription > ( ) ; Holder < ResourceList > resourceList = new Holder < ResourceList > ( ) ; service . getPortletPropertyDescription ( getRegistrationContext ( ) , WSRPTypeFactory . createPortletContext ( portletHandle ) , UserAccess . getUserContext ( ) , WSRPConstants . getDefaultLocales ( ) , modelDescription , resourceList , new Holder < List < Extension > > ( ) ) ; PortletPropertyDescriptionResponse response = WSRPTypeFactory . createPortletPropertyDescriptionResponse ( null ) ; response . setModelDescription ( modelDescription . value ) ; response . setResourceList ( resourceList . value ) ; return response ; } catch ( InvalidHandle invalidHandleFault ) { throw new IllegalArgumentException ( "<STR_LIT>" + portletHandle + "<STR_LIT:'>" ) ; } catch ( InvalidRegistration invalidRegistrationFault ) { try { resetRegistration ( ) ; } catch ( PortletInvokerException e ) { throw new RuntimeException ( "<STR_LIT>" , e ) ; } throw new IllegalArgumentException ( "<STR_LIT>" + portletHandle + "<STR_LIT>" ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + portletHandle + "<STR_LIT:'>" , e ) ; return null ; } } public void register ( ) throws PortletInvokerException { try { register ( null , false ) ; } catch ( PortletInvokerException e ) { registry . updateProducerInfo ( this ) ; throw e ; } } private RefreshResult register ( ServiceDescription serviceDescription , boolean forceRefresh ) throws PortletInvokerException { if ( ! isRegistered ( ) ) { persistentEndpointInfo . refresh ( ) ; if ( serviceDescription == null ) { serviceDescription = getServiceDescription ( false ) ; } if ( serviceDescription . isRequiresRegistration ( ) ) { RefreshResult result = persistentRegistrationInfo . refresh ( serviceDescription , getId ( ) , true , forceRefresh , false ) ; if ( ! result . hasIssues ( ) ) { try { log . debug ( "<STR_LIT>" ) ; RegistrationData registrationData = persistentRegistrationInfo . getRegistrationData ( ) ; Holder < String > registrationHandle = new Holder < String > ( ) ; Holder < byte [ ] > registrationState = new Holder < byte [ ] > ( ) ; persistentEndpointInfo . getRegistrationService ( ) . register ( registrationData , null , UserAccess . getUserContext ( ) , registrationState , new Holder < Lifetime > ( ) , new Holder < List < Extension > > ( ) , registrationHandle ) ; RegistrationContext registrationContext = WSRPTypeFactory . createRegistrationContext ( registrationHandle . value ) ; registrationContext . setRegistrationState ( registrationState . value ) ; persistentRegistrationInfo . setRegistrationContext ( registrationContext ) ; if ( debug ) { String msg = "<STR_LIT>" + getId ( ) + "<STR_LIT>" + registrationContext . getRegistrationHandle ( ) + "<STR_LIT:'>" ; log . debug ( msg ) ; } RefreshResult res = new RefreshResult ( ) ; res . setRegistrationResult ( result ) ; return res ; } catch ( Exception e ) { persistentRegistrationInfo . resetRegistration ( ) ; setActive ( false ) ; throw new PortletInvokerException ( "<STR_LIT>" + getId ( ) + "<STR_LIT:'>" , e ) ; } } else { log . debug ( result . getStatus ( ) . toString ( ) ) ; setActive ( false ) ; throw new PortletInvokerException ( "<STR_LIT>" ) ; } } } return new RefreshResult ( RefreshResult . Status . BYPASSED ) ; } public void deregister ( ) throws PortletInvokerException { if ( isRegistered ( ) ) { persistentEndpointInfo . refresh ( ) ; try { RegistrationContext registrationContext = getRegistrationContext ( ) ; persistentEndpointInfo . getRegistrationService ( ) . deregister ( registrationContext , UserAccess . getUserContext ( ) ) ; log . info ( "<STR_LIT>" + getId ( ) + "<STR_LIT>" ) ; } catch ( Exception e ) { throw new PortletInvokerException ( "<STR_LIT>" + getId ( ) + "<STR_LIT:'>" , e ) ; } finally { resetRegistration ( ) ; } } else { throw new IllegalStateException ( "<STR_LIT>" + getId ( ) + "<STR_LIT>" ) ; } } public void modifyRegistration ( ) throws PortletInvokerException { try { modifyRegistration ( false ) ; } finally { registry . updateProducerInfo ( this ) ; } } private void modifyRegistration ( boolean force ) throws PortletInvokerException { if ( persistentRegistrationInfo . getRegistrationHandle ( ) != null ) { persistentEndpointInfo . refresh ( ) ; if ( force || isModifyRegistrationRequired ( ) ) { try { RegistrationContext registrationContext = getRegistrationContext ( ) ; Holder < byte [ ] > registrationState = new Holder < byte [ ] > ( ) ; persistentEndpointInfo . getRegistrationService ( ) . modifyRegistration ( registrationContext , persistentRegistrationInfo . getRegistrationData ( ) , UserAccess . getUserContext ( ) , registrationState , new Holder < Lifetime > ( ) , new Holder < List < Extension > > ( ) ) ; persistentRegistrationInfo . setRegistrationValidInternalState ( ) ; setModifyRegistrationRequired ( false ) ; persistentRegistrationInfo . setRegistrationState ( registrationState . value ) ; log . info ( "<STR_LIT>" + getId ( ) + "<STR_LIT>" ) ; invalidateCache ( ) ; } catch ( Exception e ) { throw new PortletInvokerException ( "<STR_LIT>" + getId ( ) + "<STR_LIT:'>" , e ) ; } } } else { throw new IllegalStateException ( "<STR_LIT>" + getId ( ) + "<STR_LIT>" ) ; } } private void invalidateCache ( ) { if ( useCache ( ) ) { expirationTimeMillis = System . currentTimeMillis ( ) ; } } private RefreshResult internalRefreshRegistration ( ServiceDescription serviceDescription , boolean mergeWithLocalInfo , boolean forceRefresh , boolean forceCheckOfExtraProps ) throws PortletInvokerException { RefreshResult result = persistentRegistrationInfo . refresh ( serviceDescription , getId ( ) , mergeWithLocalInfo , forceRefresh , forceCheckOfExtraProps ) ; log . debug ( "<STR_LIT>" + getId ( ) + "<STR_LIT:'>" ) ; return result ; } public boolean isRefreshNeeded ( boolean considerCache ) { boolean result = ( considerCache && isCacheExpired ( ) ) || persistentRegistrationInfo . isRefreshNeeded ( ) || persistentEndpointInfo . isRefreshNeeded ( ) ; if ( result ) { log . debug ( "<STR_LIT>" + getId ( ) + "<STR_LIT:'>" ) ; } return result ; } void removeHandleFromCaches ( String portletHandle ) { log . debug ( "<STR_LIT>" + portletHandle + "<STR_LIT>" ) ; ccpsMap . remove ( portletHandle ) ; popsMap . remove ( portletHandle ) ; } public void eraseRegistrationInfo ( ) { persistentRegistrationInfo = RegistrationInfo . createUndeterminedRegistration ( this ) ; registry . updateProducerInfo ( this ) ; log . warn ( ERASED_LOCAL_REGISTRATION_INFORMATION ) ; } public EventInfo getInfoForEvent ( QName name ) { if ( eventDescriptions == null ) { return null ; } else { return eventDescriptions . get ( name ) ; } } public long getLastModified ( ) { return lastModified ; } public void setLastModified ( long lastModified ) { this . lastModified = lastModified ; } public Collection < String > getSupportedOptions ( ) { return Collections . unmodifiableSet ( supportedOptions ) ; } public void setSupportedOption ( String option ) { if ( WSRP2Constants . OPTIONS_COPYPORTLETS . equals ( option ) || WSRP2Constants . OPTIONS_EVENTS . equals ( option ) || WSRP2Constants . OPTIONS_EXPORT . equals ( option ) || WSRP2Constants . OPTIONS_IMPORT . equals ( option ) || WSRP2Constants . OPTIONS_LEASING . equals ( option ) ) { if ( supportedOptions . isEmpty ( ) ) { supportedOptions = new HashSet < String > ( <NUM_LIT:5> ) ; } supportedOptions . add ( option ) ; } else { throw new IllegalArgumentException ( "<STR_LIT>" + option ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . portlet ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . Portlet ; import org . gatein . pc . api . PortletContext ; import org . gatein . pc . api . info . PortletInfo ; import org . gatein . wsrp . consumer . portlet . info . WSRPPortletInfo ; public class WSRPPortlet implements Portlet { private PortletContext portletContext ; private PortletInfo info ; public WSRPPortlet ( ) { } public WSRPPortlet ( PortletContext context , PortletInfo info ) { ParameterValidation . throwIllegalArgExceptionIfNull ( context , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( info , "<STR_LIT>" ) ; this . portletContext = context ; this . info = info ; } public static WSRPPortlet createClone ( PortletContext newContext , WSRPPortletInfo originalInfo ) { ParameterValidation . throwIllegalArgExceptionIfNull ( newContext , "<STR_LIT>" ) ; return new WSRPPortlet ( newContext , new WSRPPortletInfo ( originalInfo , newContext . getId ( ) ) ) ; } public PortletContext getContext ( ) { return portletContext ; } public PortletInfo getInfo ( ) { if ( info == null ) { throw new IllegalStateException ( "<STR_LIT>" + portletContext . getId ( ) + "<STR_LIT:'>" ) ; } return info ; } public boolean isRemote ( ) { return true ; } public void setInfo ( PortletInfo info ) { this . info = info ; } public WSRPPortletInfo getWSRPInfo ( ) { return ( WSRPPortletInfo ) getInfo ( ) ; } public void setPortletContext ( PortletContext context ) { ParameterValidation . throwIllegalArgExceptionIfNull ( context , "<STR_LIT>" ) ; this . portletContext = context ; } public String toString ( ) { return "<STR_LIT>" + portletContext + "<STR_LIT:]>" ; } } </s>
|
<s> package org . gatein . wsrp . consumer . portlet . info ; import org . gatein . common . i18n . LocalizedString ; import org . gatein . pc . api . info . ParameterInfo ; import javax . xml . namespace . QName ; import java . util . Collection ; public class WSRPParameterInfo implements ParameterInfo { private final String id ; private final QName name ; private final Collection < QName > aliases ; private final LocalizedString description ; public WSRPParameterInfo ( String id , QName name , Collection < QName > aliases , LocalizedString description ) { this . id = id ; this . name = name ; this . aliases = aliases ; this . description = description ; } public String getId ( ) { return id ; } public QName getName ( ) { return name ; } public Collection < QName > getAliases ( ) { return aliases ; } public LocalizedString getDescription ( ) { return description ; } } </s>
|
<s> package org . gatein . wsrp . consumer . portlet . info ; import org . gatein . common . net . media . MediaType ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . Mode ; import org . gatein . pc . api . TransportGuarantee ; import org . gatein . pc . api . WindowState ; import org . gatein . pc . api . info . CacheInfo ; import org . gatein . pc . api . info . CapabilitiesInfo ; import org . gatein . pc . api . info . EventInfo ; import org . gatein . pc . api . info . EventingInfo ; import org . gatein . pc . api . info . MetaInfo ; import org . gatein . pc . api . info . ModeInfo ; import org . gatein . pc . api . info . NavigationInfo ; import org . gatein . pc . api . info . ParameterInfo ; import org . gatein . pc . api . info . PreferenceInfo ; import org . gatein . pc . api . info . PreferencesInfo ; import org . gatein . pc . api . info . RuntimeOptionInfo ; import org . gatein . pc . api . info . SecurityInfo ; import org . gatein . pc . api . info . WindowStateInfo ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . oasis . wsrp . v2 . LocalizedString ; import org . oasis . wsrp . v2 . MarkupType ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ParameterDescription ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . PortletPropertyDescriptionResponse ; import org . oasis . wsrp . v2 . PropertyDescription ; import javax . xml . namespace . QName ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Locale ; import java . util . Map ; import java . util . Set ; public class WSRPPortletInfo implements org . gatein . pc . api . info . PortletInfo { public static final String PRODUCER_NAME_META_INFO_KEY = "<STR_LIT>" ; private WSRPCapabilitiesInfo capabilities ; private MetaInfo metaInfo ; private boolean usesMethodGet ; private boolean defaultMarkupSecure ; private boolean onlySecure ; private boolean hasUserSpecificState ; private boolean userContextStoredInSession ; private boolean templatesStoredInSession ; private boolean doesUrlTemplateProcessing ; private String applicationName ; private String groupId ; private PreferencesInfo prefInfo ; private ProducerInfo originatingProducer ; private String portletHandle ; private final EventingInfo eventingInfo ; private final NavigationInfo navigationInfo ; public WSRPPortletInfo ( final PortletDescription portletDescription , ProducerInfo originatingProducerInfo ) { ParameterValidation . throwIllegalArgExceptionIfNull ( portletDescription , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( originatingProducerInfo , "<STR_LIT>" ) ; this . originatingProducer = originatingProducerInfo ; this . portletHandle = portletDescription . getPortletHandle ( ) ; createCapabilitiesInfo ( portletDescription ) ; createMetaInfo ( portletDescription , originatingProducerInfo . getId ( ) ) ; createWSRPInfo ( portletDescription , originatingProducerInfo . getId ( ) ) ; this . eventingInfo = createEventingInfo ( portletDescription ) ; this . navigationInfo = createNavigationInfo ( portletDescription ) ; } private NavigationInfo createNavigationInfo ( PortletDescription portletDescription ) { List < ParameterDescription > parameterDescriptions = portletDescription . getNavigationalPublicValueDescriptions ( ) ; if ( ! parameterDescriptions . isEmpty ( ) ) { Collection < ParameterInfo > params = new ArrayList < ParameterInfo > ( parameterDescriptions . size ( ) ) ; for ( ParameterDescription parameterDescription : parameterDescriptions ) { List < QName > names = parameterDescription . getNames ( ) ; int nameNb = names . size ( ) ; QName name ; Collection < QName > aliases ; switch ( nameNb ) { case <NUM_LIT:0> : throw new IllegalArgumentException ( "<STR_LIT>" ) ; case <NUM_LIT:1> : name = names . get ( <NUM_LIT:0> ) ; aliases = Collections . emptyList ( ) ; break ; default : name = names . get ( <NUM_LIT:0> ) ; aliases = names . subList ( <NUM_LIT:1> , nameNb ) ; } params . add ( new WSRPParameterInfo ( parameterDescription . getIdentifier ( ) , name , aliases , WSRPUtils . convertToCommonLocalizedStringOrNull ( parameterDescription . getDescription ( ) ) ) ) ; } return new WSRPNavigationInfo ( params ) ; } else { return new WSRPNavigationInfo ( Collections . < ParameterInfo > emptyList ( ) ) ; } } private EventingInfo createEventingInfo ( PortletDescription portletDescription ) { Map < QName , EventInfo > produced = null ; Map < QName , EventInfo > consumed = null ; List < QName > events = portletDescription . getPublishedEvents ( ) ; if ( ! events . isEmpty ( ) ) { produced = new HashMap < QName , EventInfo > ( events . size ( ) ) ; for ( QName event : events ) { EventInfo desc = originatingProducer . getInfoForEvent ( event ) ; produced . put ( event , desc ) ; } } events = portletDescription . getHandledEvents ( ) ; if ( ! events . isEmpty ( ) ) { consumed = new HashMap < QName , EventInfo > ( events . size ( ) ) ; for ( QName event : events ) { EventInfo desc = originatingProducer . getInfoForEvent ( event ) ; consumed . put ( event , desc ) ; } } return new WSRPEventingInfo ( produced , consumed ) ; } public WSRPPortletInfo ( final WSRPPortletInfo other , String newHandle ) { ParameterValidation . throwIllegalArgExceptionIfNull ( other , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( newHandle , "<STR_LIT>" , "<STR_LIT>" ) ; usesMethodGet = other . usesMethodGet ; defaultMarkupSecure = other . defaultMarkupSecure ; onlySecure = other . onlySecure ; hasUserSpecificState = other . hasUserSpecificState ; userContextStoredInSession = other . userContextStoredInSession ; templatesStoredInSession = other . templatesStoredInSession ; doesUrlTemplateProcessing = other . doesUrlTemplateProcessing ; groupId = other . groupId ; applicationName = other . applicationName ; WSRPCapabilitiesInfo otherCapabilities = ( WSRPCapabilitiesInfo ) other . getCapabilities ( ) ; capabilities = new WSRPCapabilitiesInfo ( new HashMap < MediaType , MediaTypeInfo > ( otherCapabilities . mediaTypes ) , new HashSet < ModeInfo > ( otherCapabilities . modes ) , new HashSet < WindowStateInfo > ( otherCapabilities . windowStates ) , new HashSet < Locale > ( otherCapabilities . locales ) ) ; WSRPMetaInfo otherMeta = ( WSRPMetaInfo ) other . getMeta ( ) ; metaInfo = new WSRPMetaInfo ( new HashMap < String , org . gatein . common . i18n . LocalizedString > ( otherMeta . metaInfos ) ) ; WSRPPreferencesInfo otherPref = ( WSRPPreferencesInfo ) other . getPreferences ( ) ; prefInfo = new WSRPPreferencesInfo ( new HashMap < String , PreferenceInfo > ( otherPref . preferences ) ) ; eventingInfo = other . eventingInfo ; navigationInfo = other . navigationInfo ; originatingProducer = other . originatingProducer ; portletHandle = newHandle ; } public String getName ( ) { return portletHandle ; } public String getApplicationName ( ) { return applicationName ; } public CapabilitiesInfo getCapabilities ( ) { return capabilities ; } public PreferencesInfo getPreferences ( ) { if ( prefInfo == null ) { PortletPropertyDescriptionResponse propertyDescs = originatingProducer . getPropertyDescriptionsFor ( portletHandle ) ; Map < String , PreferenceInfo > prefInfos = null ; if ( propertyDescs != null ) { ModelDescription modelDesc = propertyDescs . getModelDescription ( ) ; if ( modelDesc != null ) { List < PropertyDescription > descs = modelDesc . getPropertyDescriptions ( ) ; if ( descs != null ) { prefInfos = new HashMap < String , PreferenceInfo > ( descs . size ( ) ) ; for ( PropertyDescription desc : descs ) { String keyAsString = desc . getName ( ) . toString ( ) ; prefInfos . put ( keyAsString , new WSRPPreferenceInfo ( keyAsString , WSRPUtils . convertToCommonLocalizedStringOrNull ( desc . getLabel ( ) ) , WSRPUtils . convertToCommonLocalizedStringOrNull ( desc . getHint ( ) ) ) ) ; } } else { prefInfos = Collections . emptyMap ( ) ; } } } if ( prefInfos == null ) { prefInfos = Collections . emptyMap ( ) ; } prefInfo = new WSRPPreferencesInfo ( prefInfos ) ; } return prefInfo ; } public MetaInfo getMeta ( ) { return metaInfo ; } public SecurityInfo getSecurity ( ) { return new SecurityInfo ( ) { public boolean containsTransportGuarantee ( TransportGuarantee transportGuarantee ) { return TransportGuarantee . NONE . equals ( transportGuarantee ) ; } public Set < TransportGuarantee > getTransportGuarantees ( ) { return Collections . singleton ( TransportGuarantee . NONE ) ; } } ; } public CacheInfo getCache ( ) { return new CacheInfo ( ) { public int getExpirationSecs ( ) { Integer expirationCacheSeconds = originatingProducer . getExpirationCacheSeconds ( ) ; return expirationCacheSeconds != null ? expirationCacheSeconds : <NUM_LIT:0> ; } } ; } public Boolean isRemotable ( ) { return Boolean . FALSE ; } public EventingInfo getEventing ( ) { return eventingInfo ; } public NavigationInfo getNavigation ( ) { return navigationInfo ; } public < T > T getAttachment ( Class < T > tClass ) throws IllegalArgumentException { return null ; } public Map < String , RuntimeOptionInfo > getRuntimeOptionsInfo ( ) { return Collections . emptyMap ( ) ; } public boolean isUsesMethodGet ( ) { return usesMethodGet ; } public boolean isDefaultMarkupSecure ( ) { return defaultMarkupSecure ; } public boolean isOnlySecure ( ) { return onlySecure ; } public boolean isHasUserSpecificState ( ) { return hasUserSpecificState ; } public boolean isUserContextStoredInSession ( ) { return userContextStoredInSession ; } public boolean isTemplatesStoredInSession ( ) { return templatesStoredInSession ; } public boolean isDoesUrlTemplateProcessing ( ) { return doesUrlTemplateProcessing ; } public String getGroupId ( ) { return groupId ; } private void createWSRPInfo ( PortletDescription portletDescription , String consumerId ) { usesMethodGet = Boolean . TRUE . equals ( portletDescription . isUsesMethodGet ( ) ) ; defaultMarkupSecure = Boolean . TRUE . equals ( portletDescription . isDefaultMarkupSecure ( ) ) ; onlySecure = Boolean . TRUE . equals ( portletDescription . isOnlySecure ( ) ) ; userContextStoredInSession = Boolean . TRUE . equals ( portletDescription . isUserContextStoredInSession ( ) ) ; templatesStoredInSession = Boolean . TRUE . equals ( portletDescription . isTemplatesStoredInSession ( ) ) ; hasUserSpecificState = Boolean . TRUE . equals ( portletDescription . isHasUserSpecificState ( ) ) ; doesUrlTemplateProcessing = Boolean . TRUE . equals ( portletDescription . isDoesUrlTemplateProcessing ( ) ) ; groupId = portletDescription . getGroupID ( ) ; if ( ParameterValidation . isNullOrEmpty ( groupId ) ) { applicationName = consumerId ; } else { applicationName = groupId ; } } private void createCapabilitiesInfo ( PortletDescription portletDescription ) { final List < MarkupType > markupTypes = portletDescription . getMarkupTypes ( ) ; final Map < MediaType , MediaTypeInfo > mediaTypes = new HashMap < MediaType , MediaTypeInfo > ( markupTypes . size ( ) ) ; capabilities = new WSRPCapabilitiesInfo ( ) ; for ( MarkupType markupType : markupTypes ) { MediaType mediaType = MediaType . create ( markupType . getMimeType ( ) ) ; MediaTypeInfo mediaTypeInfo = new MediaTypeInfo ( markupType ) ; mediaTypes . put ( mediaType , mediaTypeInfo ) ; capabilities . addModes ( mediaTypeInfo . modes ) ; capabilities . addWindowStates ( mediaTypeInfo . windowStates ) ; capabilities . addLocales ( mediaTypeInfo . locales ) ; } capabilities . setMediaTypes ( mediaTypes ) ; } private void createMetaInfo ( PortletDescription portletDescription , String producerId ) { final Map < String , org . gatein . common . i18n . LocalizedString > metaInfos = new HashMap < String , org . gatein . common . i18n . LocalizedString > ( ) ; metaInfos . put ( MetaInfo . DESCRIPTION , WSRPUtils . convertToCommonLocalizedStringOrNull ( portletDescription . getDescription ( ) ) ) ; metaInfos . put ( MetaInfo . DISPLAY_NAME , WSRPUtils . convertToCommonLocalizedStringOrNull ( portletDescription . getDisplayName ( ) ) ) ; metaInfos . put ( MetaInfo . SHORT_TITLE , WSRPUtils . convertToCommonLocalizedStringOrNull ( portletDescription . getShortTitle ( ) ) ) ; metaInfos . put ( MetaInfo . TITLE , WSRPUtils . convertToCommonLocalizedStringOrNull ( portletDescription . getTitle ( ) ) ) ; List < LocalizedString > keywords = portletDescription . getKeywords ( ) ; String keywordsString = "<STR_LIT>" ; Locale locale = Locale . ENGLISH ; if ( keywords != null ) { int keywordsNb = keywords . size ( ) ; if ( keywordsNb > <NUM_LIT:0> ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < keywordsNb ; i ++ ) { LocalizedString keyword = keywords . get ( i ) ; sb . append ( keyword . getValue ( ) ) ; if ( i != keywordsNb - <NUM_LIT:1> ) { sb . append ( "<STR_LIT:U+002C>" ) ; } } keywordsString = sb . toString ( ) ; locale = WSRPUtils . getLocale ( keywords . get ( <NUM_LIT:0> ) . getLang ( ) ) ; } } metaInfos . put ( MetaInfo . KEYWORDS , new org . gatein . common . i18n . LocalizedString ( keywordsString , locale ) ) ; metaInfos . put ( PRODUCER_NAME_META_INFO_KEY , new org . gatein . common . i18n . LocalizedString ( producerId , locale ) ) ; metaInfo = new WSRPMetaInfo ( metaInfos ) ; } class MediaTypeInfo { public MediaTypeInfo ( MarkupType markupType ) { mimeType = MediaType . create ( markupType . getMimeType ( ) ) ; List < String > modeNames = markupType . getModes ( ) ; modes = new HashSet < ModeInfo > ( modeNames . size ( ) ) ; for ( String modeName : modeNames ) { modes . add ( new BasicModeInfo ( WSRPUtils . getJSR168PortletModeFromWSRPName ( modeName ) ) ) ; } List < String > windStateNames = markupType . getWindowStates ( ) ; windowStates = new HashSet < WindowStateInfo > ( windStateNames . size ( ) ) ; for ( String windStateName : windStateNames ) { windowStates . add ( new BasicWindowStateInfo ( WSRPUtils . getJSR168WindowStateFromWSRPName ( windStateName ) ) ) ; } List < String > localeNames = markupType . getLocales ( ) ; if ( localeNames != null ) { locales = new HashSet < Locale > ( localeNames . size ( ) ) ; for ( String localeName : localeNames ) { locales . add ( WSRPUtils . getLocale ( localeName ) ) ; } } else { locales = Collections . emptySet ( ) ; } } MediaType mimeType ; Set < ModeInfo > modes ; Set < WindowStateInfo > windowStates ; Set < Locale > locales ; } class BasicWindowStateInfo implements WindowStateInfo { WindowState state ; public BasicWindowStateInfo ( WindowState state ) { this . state = state ; } public org . gatein . common . i18n . LocalizedString getDescription ( ) { return new org . gatein . common . i18n . LocalizedString ( getWindowStateName ( ) + "<STR_LIT>" , Locale . ENGLISH ) ; } public WindowState getWindowState ( ) { return state ; } public String getWindowStateName ( ) { return state . toString ( ) ; } } class BasicModeInfo implements ModeInfo { Mode mode ; public BasicModeInfo ( Mode mode ) { this . mode = mode ; } public org . gatein . common . i18n . LocalizedString getDescription ( ) { return new org . gatein . common . i18n . LocalizedString ( getModeName ( ) + "<STR_LIT>" , Locale . ENGLISH ) ; } public Mode getMode ( ) { return mode ; } public String getModeName ( ) { return mode . toString ( ) ; } } private class WSRPCapabilitiesInfo implements CapabilitiesInfo { private Map < MediaType , MediaTypeInfo > mediaTypes ; private Set < ModeInfo > modes ; private Set < WindowStateInfo > windowStates ; private Set < Locale > locales ; private WSRPCapabilitiesInfo ( ) { } private void setMediaTypes ( Map < MediaType , MediaTypeInfo > mediaTypes ) { this . mediaTypes = mediaTypes ; } public WSRPCapabilitiesInfo ( Map < MediaType , MediaTypeInfo > mediaTypes , Set < ModeInfo > modes , Set < WindowStateInfo > windowStates , Set < Locale > locales ) { this . mediaTypes = mediaTypes ; this . modes = modes ; this . windowStates = windowStates ; this . locales = locales ; } public Set < MediaType > getMediaTypes ( ) { return mediaTypes . keySet ( ) ; } public Set < ModeInfo > getAllModes ( ) { return modes ; } public Set < ModeInfo > getModes ( MediaType mediaType ) { MediaTypeInfo mimeTypeInfo = mediaTypes . get ( mediaType ) ; if ( mimeTypeInfo == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( mimeTypeInfo . modes ) ; } public ModeInfo getMode ( Mode mode ) { for ( ModeInfo info : modes ) { if ( info . getMode ( ) . equals ( mode ) ) { return info ; } } return null ; } public Set < WindowStateInfo > getAllWindowStates ( ) { return windowStates ; } public Set < WindowStateInfo > getWindowStates ( MediaType mediaType ) { MediaTypeInfo mimeTypeInfo = mediaTypes . get ( mediaType ) ; if ( mimeTypeInfo == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( mimeTypeInfo . windowStates ) ; } public WindowStateInfo getWindowState ( WindowState windowState ) { for ( WindowStateInfo info : windowStates ) { if ( info . getWindowState ( ) . equals ( windowState ) ) { return info ; } } return null ; } public Set < Locale > getAllLocales ( ) { return locales ; } public Set < Locale > getLocales ( MediaType mediaType ) { MediaTypeInfo mimeTypeInfo = mediaTypes . get ( mediaType ) ; if ( mimeTypeInfo == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( mimeTypeInfo . locales ) ; } private void addModes ( Set < ModeInfo > modes ) { if ( modes != null ) { int size = modes . size ( ) ; if ( this . modes == null ) { this . modes = new HashSet < ModeInfo > ( size ) ; } this . modes . addAll ( modes ) ; } } private void addWindowStates ( Set < WindowStateInfo > windowStates ) { if ( windowStates != null ) { int size = windowStates . size ( ) ; if ( this . windowStates == null ) { this . windowStates = new HashSet < WindowStateInfo > ( size ) ; } this . windowStates . addAll ( windowStates ) ; } } private void addLocales ( Set < Locale > locales ) { if ( locales != null ) { int size = locales . size ( ) ; if ( this . locales == null ) { this . locales = new HashSet < Locale > ( size ) ; } this . locales . addAll ( locales ) ; } } } private static class WSRPMetaInfo implements MetaInfo { private final Map < String , org . gatein . common . i18n . LocalizedString > metaInfos ; public WSRPMetaInfo ( Map < String , org . gatein . common . i18n . LocalizedString > metaInfos ) { this . metaInfos = metaInfos ; } public org . gatein . common . i18n . LocalizedString getMetaValue ( String key ) { return metaInfos . get ( key ) ; } } static class WSRPPreferencesInfo implements PreferencesInfo { private Map < String , PreferenceInfo > preferences ; public WSRPPreferencesInfo ( Map < String , PreferenceInfo > preferences ) { this . preferences = preferences ; } public Set < String > getKeys ( ) { return Collections . unmodifiableSet ( preferences . keySet ( ) ) ; } public PreferenceInfo getPreference ( String key ) throws IllegalArgumentException { return preferences . get ( key ) ; } } static class WSRPPreferenceInfo implements PreferenceInfo { private String key ; private org . gatein . common . i18n . LocalizedString displayName ; private org . gatein . common . i18n . LocalizedString description ; public WSRPPreferenceInfo ( String key , org . gatein . common . i18n . LocalizedString displayName , org . gatein . common . i18n . LocalizedString description ) { this . key = key ; this . displayName = displayName ; this . description = description ; } public String getKey ( ) { return key ; } public org . gatein . common . i18n . LocalizedString getDisplayName ( ) { return displayName ; } public org . gatein . common . i18n . LocalizedString getDescription ( ) { return description ; } public Boolean isReadOnly ( ) { return null ; } public List < String > getDefaultValue ( ) { return null ; } } private static class WSRPEventingInfo implements EventingInfo { private final Map < QName , ? extends EventInfo > produced ; private final Map < QName , ? extends EventInfo > consumed ; public WSRPEventingInfo ( Map < QName , ? extends EventInfo > produced , Map < QName , ? extends EventInfo > consumed ) { if ( produced != null ) { this . produced = Collections . unmodifiableMap ( produced ) ; } else { this . produced = Collections . emptyMap ( ) ; } if ( consumed != null ) { this . consumed = Collections . unmodifiableMap ( consumed ) ; } else { this . consumed = Collections . emptyMap ( ) ; } } public Map < QName , ? extends EventInfo > getProducedEvents ( ) { return produced ; } public Map < QName , ? extends EventInfo > getConsumedEvents ( ) { return consumed ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . portlet . info ; import org . gatein . common . i18n . LocalizedString ; import org . gatein . pc . api . info . EventInfo ; import org . gatein . pc . api . info . TypeInfo ; import javax . xml . namespace . QName ; import java . util . Collection ; import java . util . Collections ; public class WSRPEventInfo implements EventInfo { private final QName name ; private final LocalizedString displayName ; private final LocalizedString description ; private final TypeInfo type ; private final Collection < QName > aliases ; public WSRPEventInfo ( QName name , LocalizedString displayName , LocalizedString description , TypeInfo type , Collection < QName > aliases ) { this . name = name ; this . displayName = displayName ; this . description = description ; this . type = type ; this . aliases = Collections . unmodifiableCollection ( aliases ) ; } public QName getName ( ) { return name ; } public LocalizedString getDisplayName ( ) { return displayName ; } public LocalizedString getDescription ( ) { return description ; } public TypeInfo getType ( ) { return type ; } public Collection < QName > getAliases ( ) { return aliases ; } } </s>
|
<s> package org . gatein . wsrp . consumer . portlet . info ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . info . NavigationInfo ; import org . gatein . pc . api . info . ParameterInfo ; import javax . xml . namespace . QName ; import java . util . Collection ; import java . util . Collections ; import java . util . HashMap ; import java . util . Map ; public class WSRPNavigationInfo implements NavigationInfo { private final Map < String , ParameterInfo > byId ; private final Map < QName , ParameterInfo > byName ; public WSRPNavigationInfo ( Collection < ParameterInfo > params ) { if ( ParameterValidation . existsAndIsNotEmpty ( params ) ) { byId = new HashMap < String , ParameterInfo > ( params . size ( ) ) ; byName = new HashMap < QName , ParameterInfo > ( params . size ( ) ) ; for ( ParameterInfo param : params ) { byId . put ( param . getId ( ) , param ) ; byName . put ( param . getName ( ) , param ) ; } } else { byId = Collections . emptyMap ( ) ; byName = Collections . emptyMap ( ) ; } } public ParameterInfo getPublicParameter ( String id ) { return byId . get ( id ) ; } public ParameterInfo getPublicParameter ( QName name ) { return byName . get ( name ) ; } public Collection < ? extends ParameterInfo > getPublicParameters ( ) { return Collections . unmodifiableCollection ( byId . values ( ) ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer ; import org . gatein . common . NotYetImplemented ; import org . gatein . common . util . ParameterValidation ; import org . gatein . common . util . Version ; import org . gatein . pc . api . InvalidPortletIdException ; import org . gatein . pc . api . InvokerUnavailableException ; import org . gatein . pc . api . NoSuchPortletException ; import org . gatein . pc . api . Portlet ; import org . gatein . pc . api . PortletContext ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . PortletStateType ; import org . gatein . pc . api . PortletStatus ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . pc . api . spi . UserContext ; import org . gatein . pc . api . state . DestroyCloneFailure ; import org . gatein . pc . api . state . PropertyChange ; import org . gatein . pc . api . state . PropertyMap ; import org . gatein . pc . portlet . impl . spi . AbstractPortletInvocationContext ; import org . gatein . pc . portlet . state . SimplePropertyMap ; import org . gatein . wsrp . UserContextConverter ; import org . gatein . wsrp . WSRPConstants ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . api . extensions . DefaultConsumerExtensionAccessor ; import org . gatein . wsrp . api . session . SessionEvent ; import org . gatein . wsrp . consumer . handlers . InvocationDispatcher ; import org . gatein . wsrp . consumer . handlers . ProducerSessionInformation ; import org . gatein . wsrp . consumer . handlers . SessionHandler ; import org . gatein . wsrp . consumer . handlers . session . SessionRegistry ; import org . gatein . wsrp . consumer . migration . ExportInfo ; import org . gatein . wsrp . consumer . migration . ImportInfo ; import org . gatein . wsrp . consumer . migration . MigrationService ; import org . gatein . wsrp . consumer . portlet . WSRPPortlet ; import org . gatein . wsrp . consumer . portlet . info . WSRPPortletInfo ; import org . gatein . wsrp . consumer . spi . ConsumerRegistrySPI ; import org . gatein . wsrp . consumer . spi . WSRPConsumerSPI ; import org . gatein . wsrp . services . MarkupService ; import org . gatein . wsrp . services . PortletManagementService ; import org . gatein . wsrp . services . RegistrationService ; import org . gatein . wsrp . services . ServiceDescriptionService ; import org . gatein . wsrp . servlet . UserAccess ; import org . gatein . wsrp . spec . v2 . WSRP2Constants ; import org . oasis . wsrp . v2 . ExportedPortlet ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . FailedPortlets ; import org . oasis . wsrp . v2 . ImportPortlet ; import org . oasis . wsrp . v2 . ImportPortletsFailed ; import org . oasis . wsrp . v2 . ImportedPortlet ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . Property ; import org . oasis . wsrp . v2 . PropertyList ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . ResetProperty ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionParams ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . servlet . http . HttpServletRequest ; import javax . servlet . http . HttpSession ; import javax . xml . datatype . Duration ; import javax . xml . datatype . XMLGregorianCalendar ; import javax . xml . namespace . QName ; import javax . xml . ws . Holder ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Collections ; import java . util . HashSet ; import java . util . LinkedHashSet ; import java . util . List ; import java . util . Map ; import java . util . Set ; import java . util . SortedMap ; import java . util . TreeMap ; public class WSRPConsumerImpl implements WSRPConsumerSPI { private final SessionHandler sessionHandler ; private final InvocationDispatcher dispatcher ; private ProducerInfo producerInfo ; private final static RegistrationData REGISTRATION_NOT_NEEDED = WSRPTypeFactory . createDefaultRegistrationData ( ) ; private final static Logger log = LoggerFactory . getLogger ( WSRPConsumer . class ) ; private final static String PORTLET_INFO_KEY = "<STR_LIT>" ; static { REGISTRATION_NOT_NEEDED . setConsumerAgent ( "<STR_LIT>" ) ; REGISTRATION_NOT_NEEDED . setConsumerName ( "<STR_LIT>" ) ; DefaultConsumerExtensionAccessor . registerWithAPI ( ) ; } private static final Set < String > WSRP_DEFAULT_USER_SCOPE = new HashSet < String > ( <NUM_LIT:2> ) ; static { WSRP_DEFAULT_USER_SCOPE . add ( WSRPConstants . CACHE_FOR_ALL ) ; WSRP_DEFAULT_USER_SCOPE . add ( WSRPConstants . CACHE_PER_USER ) ; } private Set supportedUserScopes = WSRP_DEFAULT_USER_SCOPE ; private transient boolean started ; public WSRPConsumerImpl ( ProducerInfo info ) { ParameterValidation . throwIllegalArgExceptionIfNull ( info , "<STR_LIT>" ) ; producerInfo = info ; sessionHandler = new SessionHandler ( this ) ; dispatcher = new InvocationDispatcher ( this ) ; } public ProducerInfo getProducerInfo ( ) { return producerInfo ; } public Set < Portlet > getPortlets ( ) throws InvokerUnavailableException { try { Map portletMap = producerInfo . getPortletMap ( ) ; return new LinkedHashSet < Portlet > ( portletMap . values ( ) ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( e . getMessage ( ) , e . getCause ( ) ) ; } } public Portlet getPortlet ( PortletContext portletContext ) throws IllegalArgumentException , PortletInvokerException { ParameterValidation . throwIllegalArgExceptionIfNull ( portletContext , "<STR_LIT>" ) ; Portlet portlet = producerInfo . getPortlet ( portletContext ) ; if ( portlet == null ) { throw new NoSuchPortletException ( portletContext . getId ( ) ) ; } else { return portlet ; } } public PortletStatus getStatus ( PortletContext portletContext ) throws IllegalArgumentException , PortletInvokerException { if ( producerInfo . getPortlet ( portletContext ) != null ) { return PortletStatus . OFFERED ; } else { return null ; } } public PortletInvocationResponse invoke ( PortletInvocation invocation ) throws PortletInvokerException { return dispatcher . dispatchAndHandle ( invocation ) ; } public PortletContext createClone ( PortletStateType stateType , PortletContext portletContext ) throws IllegalArgumentException , PortletInvokerException , UnsupportedOperationException { ParameterValidation . throwIllegalArgExceptionIfNull ( portletContext , "<STR_LIT>" ) ; if ( ! PortletStateType . OPAQUE . equals ( stateType ) ) { throw new IllegalArgumentException ( "<STR_LIT>" + stateType ) ; } WSRPPortlet original = getWSRPPortlet ( portletContext ) ; if ( original == null ) { throw new PortletInvokerException ( "<STR_LIT>" + portletContext . getId ( ) + "<STR_LIT>" ) ; } try { Holder < String > handle = new Holder < String > ( ) ; Holder < byte [ ] > portletState = new Holder < byte [ ] > ( ) ; getPortletManagementService ( ) . clonePortlet ( getRegistrationContext ( ) , WSRPUtils . convertToWSRPPortletContext ( portletContext ) , UserAccess . getUserContext ( ) , null , handle , portletState , new Holder < Lifetime > ( ) , new Holder < List < Extension > > ( ) ) ; return WSRPUtils . convertToPortalPortletContext ( handle . value , portletState . value ) ; } catch ( Exception e ) { throw new PortletInvokerException ( "<STR_LIT>" + portletContext . getId ( ) + "<STR_LIT:'>" , e ) ; } } public List < DestroyCloneFailure > destroyClones ( List < PortletContext > portletContexts ) throws IllegalArgumentException , PortletInvokerException , UnsupportedOperationException { ParameterValidation . throwIllegalArgExceptionIfNull ( portletContexts , "<STR_LIT>" ) ; int numberOfClones = portletContexts . size ( ) ; if ( numberOfClones == <NUM_LIT:0> ) { return Collections . emptyList ( ) ; } List < String > handles = new ArrayList < String > ( numberOfClones ) ; for ( Object portletContext : portletContexts ) { PortletContext context = ( PortletContext ) portletContext ; String id = context . getId ( ) ; handles . add ( id ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "<STR_LIT>" + handles ) ; } try { Holder < List < FailedPortlets > > failedPortlets = new Holder < List < FailedPortlets > > ( ) ; getPortletManagementService ( ) . destroyPortlets ( getRegistrationContext ( ) , handles , UserAccess . getUserContext ( ) , failedPortlets , new Holder < List < Extension > > ( ) ) ; List < FailedPortlets > failures = failedPortlets . value ; List < DestroyCloneFailure > result = Collections . emptyList ( ) ; if ( failures != null ) { result = new ArrayList < DestroyCloneFailure > ( failures . size ( ) ) ; for ( FailedPortlets failure : failures ) { List < String > portletHandles = failure . getPortletHandles ( ) ; String reason = failure . getReason ( ) . getValue ( ) ; for ( String portletHandle : portletHandles ) { result . add ( new DestroyCloneFailure ( portletHandle , reason ) ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "<STR_LIT>" + portletHandles + "<STR_LIT:'>" ) ; } } handles . removeAll ( portletHandles ) ; } } if ( ! handles . isEmpty ( ) ) { for ( String handle : handles ) { producerInfo . removeHandleFromCaches ( handle ) ; } } return result ; } catch ( Exception e ) { throw new PortletInvokerException ( "<STR_LIT>" , e ) ; } } public PropertyMap getProperties ( PortletContext portletContext , Set < String > keys ) throws IllegalArgumentException , PortletInvokerException , UnsupportedOperationException { ParameterValidation . throwIllegalArgExceptionIfNull ( keys , "<STR_LIT>" ) ; return getProperties ( portletContext , new ArrayList < String > ( keys ) ) ; } private PropertyMap getProperties ( PortletContext portletContext , List < String > keys ) throws PortletInvokerException { ParameterValidation . throwIllegalArgExceptionIfNull ( portletContext , "<STR_LIT>" ) ; try { Holder < List < Property > > properties = new Holder < List < Property > > ( ) ; Holder < List < ResetProperty > > resetProperties = new Holder < List < ResetProperty > > ( ) ; getPortletManagementService ( ) . getPortletProperties ( getRegistrationContext ( ) , WSRPUtils . convertToWSRPPortletContext ( portletContext ) , UserAccess . getUserContext ( ) , keys , properties , resetProperties , new Holder < List < Extension > > ( ) ) ; List < Property > props = properties . value ; if ( props != null ) { PropertyMap result = new SimplePropertyMap ( props . size ( ) ) ; for ( Property prop : props ) { String name = prop . getName ( ) . toString ( ) ; String value = prop . getStringValue ( ) ; List < String > list = new ArrayList < String > ( ) ; list . add ( value ) ; result . put ( name , list ) ; } return result ; } else { return new SimplePropertyMap ( ) ; } } catch ( OperationNotSupported operationNotSupported ) { throw new UnsupportedOperationException ( operationNotSupported ) ; } catch ( InvalidHandle invalidHandle ) { throw new InvalidPortletIdException ( invalidHandle , portletContext . getId ( ) ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw new IllegalArgumentException ( inconsistentParameters ) ; } catch ( Exception e ) { throw new PortletInvokerException ( e ) ; } } public PropertyMap getProperties ( PortletContext portletContext ) throws IllegalArgumentException , PortletInvokerException , UnsupportedOperationException { return getProperties ( portletContext , Collections . < String > emptyList ( ) ) ; } public PortletContext setProperties ( PortletContext portletContext , PropertyChange [ ] changes ) throws IllegalArgumentException , PortletInvokerException , UnsupportedOperationException { ParameterValidation . throwIllegalArgExceptionIfNull ( portletContext , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( changes , "<STR_LIT>" ) ; WSRPPortlet portlet = getWSRPPortlet ( portletContext ) ; if ( portlet == null ) { throw new PortletInvokerException ( "<STR_LIT>" + portletContext . getId ( ) + "<STR_LIT>" ) ; } PropertyList propertyList = WSRPTypeFactory . createPropertyList ( ) ; int changesNumber = changes . length ; List < Property > updates = new ArrayList < Property > ( changesNumber ) ; List < ResetProperty > resets = new ArrayList < ResetProperty > ( changesNumber ) ; for ( int i = <NUM_LIT:0> ; i < changesNumber ; i ++ ) { PropertyChange change = changes [ i ] ; switch ( change . getType ( ) ) { case PropertyChange . PREF_RESET : resets . add ( WSRPTypeFactory . createResetProperty ( change . getKey ( ) ) ) ; break ; case PropertyChange . PREF_UPDATE : updates . add ( WSRPTypeFactory . createProperty ( change . getKey ( ) , WSRPConstants . DEFAULT_LOCALE , change . getValue ( ) . get ( <NUM_LIT:0> ) ) ) ; break ; default : throw new IllegalArgumentException ( "<STR_LIT>" + change . getType ( ) ) ; } } propertyList . getProperties ( ) . addAll ( updates ) ; propertyList . getResetProperties ( ) . addAll ( resets ) ; try { Holder < String > handle = new Holder < String > ( ) ; Holder < byte [ ] > portletState = new Holder < byte [ ] > ( ) ; getPortletManagementService ( ) . setPortletProperties ( getRegistrationContext ( ) , WSRPUtils . convertToWSRPPortletContext ( portletContext ) , UserAccess . getUserContext ( ) , propertyList , handle , portletState , new Holder < Lifetime > ( ) , new Holder < List < Extension > > ( ) ) ; PortletContext newPortletContext = PortletContext . createPortletContext ( handle . value , portletState . value , false ) ; portlet . setPortletContext ( newPortletContext ) ; return newPortletContext ; } catch ( Exception e ) { throw new PortletInvokerException ( "<STR_LIT>" + portletContext . getId ( ) + "<STR_LIT:'>" , e ) ; } } public PortletContext exportPortlet ( PortletStateType stateType , PortletContext originalPortletContext ) throws PortletInvokerException { throw new NotYetImplemented ( ) ; } public PortletContext importPortlet ( PortletStateType stateType , PortletContext originalPortletContext ) throws PortletInvokerException { throw new NotYetImplemented ( ) ; } public String getProducerId ( ) { return producerInfo . getId ( ) ; } public SessionHandler getSessionHandler ( ) { return sessionHandler ; } public Map < String , Set < Portlet > > getPortletGroupMap ( ) throws PortletInvokerException { return producerInfo . getPortletGroupMap ( ) ; } public static PortletContext getPortletContext ( PortletInvocation invocation ) { return invocation . getTarget ( ) ; } public WSRPPortletInfo getPortletInfo ( PortletInvocation invocation ) throws PortletInvokerException { Object info = invocation . getAttribute ( PORTLET_INFO_KEY ) ; if ( info == null ) { info = getWSRPPortlet ( getPortletContext ( invocation ) ) . getInfo ( ) ; invocation . setAttribute ( PORTLET_INFO_KEY , info ) ; } return ( WSRPPortletInfo ) info ; } WSRPPortlet getWSRPPortlet ( PortletContext portletContext ) throws PortletInvokerException { return ( WSRPPortlet ) getPortlet ( portletContext ) ; } public Set getSupportedUserScopes ( ) { return Collections . unmodifiableSet ( supportedUserScopes ) ; } public boolean supportsUserScope ( String userScope ) { return supportedUserScopes . contains ( userScope ) ; } public boolean isImportExportSupported ( ) { final Collection < String > supportedOptions = producerInfo . getSupportedOptions ( ) ; return isUsingWSRP2 ( ) && supportedOptions . contains ( WSRP2Constants . OPTIONS_IMPORT ) && supportedOptions . contains ( WSRP2Constants . OPTIONS_EXPORT ) ; } public void handleInvalidRegistrationFault ( ) throws PortletInvokerException { producerInfo . resetRegistration ( ) ; refreshProducerInfo ( true ) ; } public RegistrationContext getRegistrationContext ( ) throws PortletInvokerException { return producerInfo . getRegistrationContext ( ) ; } public ProducerSessionInformation getProducerSessionInformationFrom ( PortletInvocation invocation ) { return sessionHandler . getProducerSessionInformation ( invocation ) ; } public ProducerSessionInformation getProducerSessionInformationFrom ( HttpSession session ) { return sessionHandler . getProducerSessionInformation ( session ) ; } public void activate ( ) throws Exception { internalStart ( ) ; producerInfo . setActiveAndSave ( true ) ; log . info ( "<STR_LIT>" + getProducerId ( ) + "<STR_LIT>" ) ; } private void internalStart ( ) throws Exception { if ( ! started ) { try { start ( ) ; } catch ( Exception e ) { producerInfo . setActiveAndSave ( false ) ; throw e ; } } } public void deactivate ( ) throws Exception { producerInfo . setActiveAndSave ( false ) ; if ( started ) { stop ( ) ; log . info ( "<STR_LIT>" + getProducerId ( ) + "<STR_LIT>" ) ; } } public boolean isActive ( ) { return producerInfo . isActive ( ) && started ; } public boolean isRefreshNeeded ( ) { return ! started || producerInfo . isRefreshNeeded ( false ) ; } public RefreshResult refresh ( boolean forceRefresh ) throws PortletInvokerException { try { internalStart ( ) ; } catch ( Exception e ) { throw new PortletInvokerException ( e ) ; } return refreshProducerInfo ( forceRefresh ) ; } public void start ( ) throws Exception { getEndpointConfigurationInfo ( ) . start ( ) ; started = true ; log . info ( "<STR_LIT>" + getProducerId ( ) + "<STR_LIT>" ) ; } public void stop ( ) throws Exception { getEndpointConfigurationInfo ( ) . stop ( ) ; started = false ; log . info ( "<STR_LIT>" + getProducerId ( ) + "<STR_LIT>" ) ; } private EndpointConfigurationInfo getEndpointConfigurationInfo ( ) { return producerInfo . getEndpointConfigurationInfo ( ) ; } private ServiceDescriptionService getServiceDescriptionService ( ) throws PortletInvokerException { refreshProducerInfo ( false ) ; return getEndpointConfigurationInfo ( ) . getServiceDescriptionService ( ) ; } public MarkupService getMarkupService ( ) throws PortletInvokerException { refreshProducerInfo ( false ) ; return getEndpointConfigurationInfo ( ) . getMarkupService ( ) ; } private PortletManagementService getPortletManagementService ( ) throws PortletInvokerException { refreshProducerInfo ( false ) ; return getEndpointConfigurationInfo ( ) . getPortletManagementService ( ) ; } private RegistrationService getRegistrationService ( ) throws PortletInvokerException { refreshProducerInfo ( false ) ; return getEndpointConfigurationInfo ( ) . getRegistrationService ( ) ; } public void refreshProducerInfo ( ) throws PortletInvokerException { refreshProducerInfo ( true ) ; } private RefreshResult refreshProducerInfo ( boolean forceRefresh ) throws PortletInvokerException { return producerInfo . detailedRefresh ( forceRefresh ) ; } public void releaseSessions ( ) throws PortletInvokerException { sessionHandler . releaseSessions ( ) ; } private String getUserContextKeyFor ( UserContext userContext ) { String userId = userContext . getId ( ) ; if ( userId != null ) { return userId ; } else { return null ; } } public org . oasis . wsrp . v2 . UserContext getUserContextFrom ( WSRPPortletInfo info , PortletInvocation invocation , RuntimeContext runtimeContext ) throws PortletInvokerException { SessionParams sessionParams = runtimeContext . getSessionParams ( ) ; if ( info != null && info . isUserContextStoredInSession ( ) && sessionParams != null && sessionParams . getSessionID ( ) != null ) { return null ; } UserContext userContext = invocation . getUserContext ( ) ; if ( userContext != null ) { String userContextKey = getUserContextKeyFor ( userContext ) ; if ( userContextKey == null ) { return null ; } return UserContextConverter . createWSRPUserContextFrom ( userContext , userContextKey , null ) ; } return null ; } public void setTemplatesIfNeeded ( WSRPPortletInfo info , PortletInvocation invocation , RuntimeContext runtimeContext ) throws PortletInvokerException { SessionParams sessionParams = runtimeContext . getSessionParams ( ) ; if ( info != null && info . isDoesUrlTemplateProcessing ( ) && ( ! info . isTemplatesStoredInSession ( ) || sessionParams == null || sessionParams . getSessionID ( ) == null ) ) { runtimeContext . setTemplates ( WSRPTypeFactory . createTemplates ( invocation . getContext ( ) ) ) ; } } public static HttpServletRequest getHttpRequest ( PortletInvocation invocation ) { AbstractPortletInvocationContext invocationContext = ( AbstractPortletInvocationContext ) invocation . getContext ( ) ; return invocationContext . getClientRequest ( ) ; } public static HttpSession getHttpSession ( PortletInvocation invocation ) { return getHttpRequest ( invocation ) . getSession ( ) ; } public void onSessionEvent ( SessionEvent event ) { sessionHandler . onSessionEvent ( event ) ; } @ Override public boolean equals ( Object o ) { if ( this == o ) { return true ; } if ( o == null || getClass ( ) != o . getClass ( ) ) { return false ; } WSRPConsumerImpl that = ( WSRPConsumerImpl ) o ; return producerInfo . equals ( that . producerInfo ) ; } @ Override public int hashCode ( ) { return producerInfo . hashCode ( ) ; } public ExportInfo exportPortlets ( List < String > portletHandles ) throws PortletInvokerException { if ( isImportExportSupported ( ) ) { if ( ParameterValidation . existsAndIsNotEmpty ( portletHandles ) ) { List < org . oasis . wsrp . v2 . PortletContext > portletContexts = new ArrayList < org . oasis . wsrp . v2 . PortletContext > ( portletHandles . size ( ) ) ; for ( String handle : portletHandles ) { portletContexts . add ( WSRPTypeFactory . createPortletContext ( handle ) ) ; } try { Holder < byte [ ] > exportContextHolder = new Holder < byte [ ] > ( ) ; Holder < List < ExportedPortlet > > exportedPortletsHolder = new Holder < List < ExportedPortlet > > ( ) ; Holder < List < FailedPortlets > > failedPortletsHolder = new Holder < List < FailedPortlets > > ( ) ; Holder < Lifetime > lifetimeHolder = new Holder < Lifetime > ( ) ; getPortletManagementService ( ) . exportPortlets ( getRegistrationContext ( ) , portletContexts , UserAccess . getUserContext ( ) , lifetimeHolder , true , exportContextHolder , exportedPortletsHolder , failedPortletsHolder , new Holder < ResourceList > ( ) , new Holder < List < Extension > > ( ) ) ; SortedMap < String , byte [ ] > handleToState = null ; List < ExportedPortlet > exportedPortlets = exportedPortletsHolder . value ; if ( ParameterValidation . existsAndIsNotEmpty ( exportedPortlets ) ) { handleToState = new TreeMap < String , byte [ ] > ( ) ; for ( ExportedPortlet exportedPortlet : exportedPortlets ) { handleToState . put ( exportedPortlet . getPortletHandle ( ) , exportedPortlet . getExportData ( ) ) ; } } SortedMap < QName , List < String > > errorCodeToHandle = null ; List < FailedPortlets > failedPortlets = failedPortletsHolder . value ; if ( ParameterValidation . existsAndIsNotEmpty ( failedPortlets ) ) { errorCodeToHandle = new TreeMap < QName , List < String > > ( ) ; for ( FailedPortlets failedPortletsForReason : failedPortlets ) { errorCodeToHandle . put ( failedPortletsForReason . getErrorCode ( ) , failedPortletsForReason . getPortletHandles ( ) ) ; } } Lifetime lifetime = lifetimeHolder . value ; if ( lifetime != null ) { XMLGregorianCalendar currentTime = lifetime . getCurrentTime ( ) ; Duration refreshDuration = lifetime . getRefreshDuration ( ) ; XMLGregorianCalendar terminationTime = lifetime . getTerminationTime ( ) ; } ExportInfo exportInfo = new ExportInfo ( System . currentTimeMillis ( ) , errorCodeToHandle , handleToState , exportContextHolder . value ) ; getConsumerRegistry ( ) . getMigrationService ( ) . add ( exportInfo ) ; return exportInfo ; } catch ( OperationNotSupported operationNotSupported ) { throw new UnsupportedOperationException ( operationNotSupported ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw new IllegalArgumentException ( inconsistentParameters ) ; } catch ( Exception e ) { throw new PortletInvokerException ( e . getLocalizedMessage ( ) , e ) ; } } else { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } else { throw new UnsupportedOperationException ( "<STR_LIT>" + producerInfo . getId ( ) + "<STR_LIT>" ) ; } } private ConsumerRegistrySPI getConsumerRegistry ( ) { return producerInfo . getRegistry ( ) ; } public void releaseExport ( ExportInfo exportInfo ) throws PortletInvokerException { if ( isImportExportSupported ( ) ) { ParameterValidation . throwIllegalArgExceptionIfNull ( exportInfo , "<STR_LIT>" ) ; getPortletManagementService ( ) . releaseExport ( getRegistrationContext ( ) , exportInfo . getExportContext ( ) , UserAccess . getUserContext ( ) ) ; } else { throw new UnsupportedOperationException ( "<STR_LIT>" + producerInfo . getId ( ) + "<STR_LIT>" ) ; } } public ImportInfo importPortlets ( ExportInfo exportInfo , List < String > portlets ) throws PortletInvokerException { if ( isImportExportSupported ( ) ) { ParameterValidation . throwIllegalArgExceptionIfNull ( exportInfo , "<STR_LIT>" ) ; if ( ParameterValidation . existsAndIsNotEmpty ( portlets ) ) { try { List < ImportPortlet > importPortlets = new ArrayList < ImportPortlet > ( portlets . size ( ) ) ; for ( String portlet : portlets ) { importPortlets . add ( WSRPTypeFactory . createImportPortlet ( portlet , exportInfo . getPortletStateFor ( portlet ) ) ) ; } Holder < List < ImportedPortlet > > importedPortletsHolder = new Holder < List < ImportedPortlet > > ( ) ; Holder < List < ImportPortletsFailed > > failedPortletsHolder = new Holder < List < ImportPortletsFailed > > ( ) ; Holder < ResourceList > resourceListHolder = new Holder < ResourceList > ( ) ; getPortletManagementService ( ) . importPortlets ( getRegistrationContext ( ) , exportInfo . getExportContext ( ) , importPortlets , UserAccess . getUserContext ( ) , null , importedPortletsHolder , failedPortletsHolder , resourceListHolder , new Holder < List < Extension > > ( ) ) ; List < ImportedPortlet > importedPortlets = importedPortletsHolder . value ; SortedMap < String , PortletContext > importIdToPortletContext = new TreeMap < String , PortletContext > ( ) ; if ( ParameterValidation . existsAndIsNotEmpty ( importedPortlets ) ) { for ( ImportedPortlet importedPortlet : importedPortlets ) { org . oasis . wsrp . v2 . PortletContext portletContext = importedPortlet . getNewPortletContext ( ) ; PortletContext apiPC = PortletContext . createPortletContext ( portletContext . getPortletHandle ( ) , portletContext . getPortletState ( ) , false ) ; importIdToPortletContext . put ( importedPortlet . getImportID ( ) , PortletContext . reference ( getProducerId ( ) , apiPC ) ) ; } } SortedMap < QName , List < String > > errorCodeToHandle = null ; List < ImportPortletsFailed > failedPortlets = failedPortletsHolder . value ; if ( ParameterValidation . existsAndIsNotEmpty ( failedPortlets ) ) { errorCodeToHandle = new TreeMap < QName , List < String > > ( ) ; for ( ImportPortletsFailed failedPortletsForReason : failedPortlets ) { errorCodeToHandle . put ( failedPortletsForReason . getErrorCode ( ) , failedPortletsForReason . getImportID ( ) ) ; } } return new ImportInfo ( System . currentTimeMillis ( ) , errorCodeToHandle , importIdToPortletContext ) ; } catch ( OperationNotSupported operationNotSupported ) { throw new UnsupportedOperationException ( operationNotSupported ) ; } catch ( InconsistentParameters inconsistentParameters ) { throw new IllegalArgumentException ( inconsistentParameters ) ; } catch ( Exception e ) { throw new PortletInvokerException ( e . getLocalizedMessage ( ) , e ) ; } } else { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } else { throw new UnsupportedOperationException ( "<STR_LIT>" + producerInfo . getId ( ) + "<STR_LIT>" ) ; } } public boolean isUsingWSRP2 ( ) { Version wsrpVersion = getWSRPVersion ( ) ; return wsrpVersion != null && wsrpVersion . getMajor ( ) >= <NUM_LIT:2> ; } public MigrationService getMigrationService ( ) { return getConsumerRegistry ( ) . getMigrationService ( ) ; } public Version getWSRPVersion ( ) { return producerInfo . getEndpointConfigurationInfo ( ) . getWSRPVersion ( ) ; } public SessionRegistry getSessionRegistry ( ) { return getConsumerRegistry ( ) . getSessionRegistry ( ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . migration ; import org . gatein . wsrp . api . context . ConsumerStructureProvider ; import java . util . List ; public interface MigrationService { ConsumerStructureProvider getStructureProvider ( ) ; void setStructureProvider ( ConsumerStructureProvider structureProvider ) ; List < ExportInfo > getAvailableExportInfos ( ) ; ExportInfo getExportInfo ( long exportTime ) ; void add ( ExportInfo info ) ; ExportInfo remove ( ExportInfo info ) ; boolean isAvailableExportInfosEmpty ( ) ; } </s>
|
<s> package org . gatein . wsrp . consumer . migration ; import org . gatein . common . util . ParameterValidation ; import javax . xml . namespace . QName ; import java . text . DateFormat ; import java . util . Collections ; import java . util . Date ; import java . util . List ; import java . util . Locale ; import java . util . SortedMap ; import java . util . TreeMap ; public class BaseMigrationInfo { protected final static SortedMap < QName , List < String > > EMPTY_FAILED = new TreeMap < QName , List < String > > ( ) ; protected final SortedMap < QName , List < String > > errorCodeToHandles ; protected final long exportTime ; public BaseMigrationInfo ( long exportTime , SortedMap < QName , List < String > > errorCodeToHandles ) { if ( ParameterValidation . existsAndIsNotEmpty ( errorCodeToHandles ) ) { this . errorCodeToHandles = errorCodeToHandles ; } else { this . errorCodeToHandles = EMPTY_FAILED ; } this . exportTime = exportTime ; } public SortedMap < QName , List < String > > getErrorCodesToFailedPortletHandlesMapping ( ) { return Collections . unmodifiableSortedMap ( errorCodeToHandles ) ; } public long getExportTime ( ) { return exportTime ; } public String getHumanReadableExportTime ( Locale locale ) { return getHumanReadableTime ( locale , exportTime ) ; } protected String getHumanReadableTime ( Locale locale , final long time ) { if ( locale == null ) { locale = Locale . getDefault ( ) ; } return DateFormat . getDateTimeInstance ( DateFormat . FULL , DateFormat . FULL , locale ) . format ( new Date ( time ) ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . migration ; import org . gatein . common . util . ParameterValidation ; import org . gatein . wsrp . api . context . ConsumerStructureProvider ; import java . util . ArrayList ; import java . util . List ; import java . util . SortedMap ; import java . util . TreeMap ; public class InMemoryMigrationService implements MigrationService { private SortedMap < Long , ExportInfo > exportInfos ; private ConsumerStructureProvider structureProvider ; public ConsumerStructureProvider getStructureProvider ( ) { return structureProvider ; } public void setStructureProvider ( ConsumerStructureProvider structureProvider ) { this . structureProvider = structureProvider ; } public List < ExportInfo > getAvailableExportInfos ( ) { return new ArrayList < ExportInfo > ( getExportInfos ( ) . values ( ) ) ; } public ExportInfo getExportInfo ( long exportTime ) { return exportInfos . get ( exportTime ) ; } public void add ( ExportInfo info ) { ParameterValidation . throwIllegalArgExceptionIfNull ( info , "<STR_LIT>" ) ; getExportInfos ( ) . put ( info . getExportTime ( ) , info ) ; } public ExportInfo remove ( ExportInfo info ) { return info == null ? null : getExportInfos ( ) . remove ( info . getExportTime ( ) ) ; } private SortedMap < Long , ExportInfo > getExportInfos ( ) { if ( exportInfos == null ) { exportInfos = new TreeMap < Long , ExportInfo > ( ) ; } return exportInfos ; } public boolean isAvailableExportInfosEmpty ( ) { return exportInfos == null || exportInfos . isEmpty ( ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . migration ; import org . gatein . common . util . ParameterValidation ; import javax . xml . namespace . QName ; import java . util . ArrayList ; import java . util . List ; import java . util . Locale ; import java . util . SortedMap ; import java . util . TreeMap ; public class ExportInfo extends BaseMigrationInfo { private final byte [ ] exportContext ; private long expirationTime ; private final SortedMap < String , byte [ ] > handleToExportedState ; private final static SortedMap < String , byte [ ] > EMPTY_EXPORTED = new TreeMap < String , byte [ ] > ( ) ; public ExportInfo ( long exportTime , SortedMap < QName , List < String > > errorCodeToHandles , SortedMap < String , byte [ ] > handleToState , byte [ ] exportContext ) { super ( exportTime , errorCodeToHandles ) ; if ( ParameterValidation . existsAndIsNotEmpty ( handleToState ) ) { this . handleToExportedState = handleToState ; } else { handleToExportedState = EMPTY_EXPORTED ; } this . exportContext = exportContext ; } public long getExpirationTime ( ) { return expirationTime ; } public String getHumanReadableExpirationTime ( Locale locale ) { return getHumanReadableTime ( locale , expirationTime ) ; } public List < String > getExportedPortletHandles ( ) { return new ArrayList < String > ( handleToExportedState . keySet ( ) ) ; } public byte [ ] getPortletStateFor ( String portletHandle ) { return handleToExportedState . get ( portletHandle ) ; } @ Override public boolean equals ( Object o ) { if ( this == o ) { return true ; } if ( o == null || getClass ( ) != o . getClass ( ) ) { return false ; } ExportInfo that = ( ExportInfo ) o ; if ( exportTime != that . exportTime ) { return false ; } return true ; } @ Override public int hashCode ( ) { return ( int ) ( exportTime ^ ( exportTime > > > <NUM_LIT:32> ) ) ; } public byte [ ] getExportContext ( ) { return exportContext ; } } </s>
|
<s> package org . gatein . wsrp . consumer . migration ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletContext ; import javax . xml . namespace . QName ; import java . util . List ; import java . util . SortedMap ; import java . util . TreeMap ; public class ImportInfo extends BaseMigrationInfo { private final SortedMap < String , PortletContext > importIdToPortletContext ; private static final SortedMap < String , PortletContext > EMPTY_IMPORTED = new TreeMap < String , PortletContext > ( ) ; public ImportInfo ( long exportTime , SortedMap < QName , List < String > > errorCodeToHandles , SortedMap < String , PortletContext > importIdToPortletContext ) { super ( exportTime , errorCodeToHandles ) ; if ( ParameterValidation . existsAndIsNotEmpty ( importIdToPortletContext ) ) { this . importIdToPortletContext = importIdToPortletContext ; } else { this . importIdToPortletContext = EMPTY_IMPORTED ; } } public PortletContext getPortletContextFor ( String id ) { return importIdToPortletContext . get ( id ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer ; import org . gatein . common . util . ParameterValidation ; import org . gatein . common . util . Version ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . wsrp . WSRPConstants ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . registration . RegistrationPropertyDescription ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . Property ; import org . oasis . wsrp . v2 . PropertyDescription ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . ServiceDescription ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . xml . namespace . QName ; import java . io . Serializable ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . Set ; public class RegistrationInfo implements RegistrationProperty . PropertyChangeListener , Serializable { private static final Logger log = LoggerFactory . getLogger ( RegistrationInfo . class ) ; private Long key ; private String persistentConsumerName ; private String persistentRegistrationHandle ; private byte [ ] persistentRegistrationState ; private Map < QName , RegistrationProperty > persistentRegistrationProperties ; private transient Boolean requiresRegistration ; private transient Boolean consistentWithProducerExpectations ; private transient RegistrationData registrationData ; private transient boolean regenerateRegistrationData ; private transient boolean modifiedSinceLastRefresh ; private transient boolean modifyRegistrationNeeded ; private transient ProducerInfo parent ; private static final String UNDETERMINED_REGISTRATION = "<STR_LIT>" ; public RegistrationInfo ( ProducerInfo producerInfo ) { this ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( producerInfo , "<STR_LIT>" ) ; producerInfo . setRegistrationInfo ( this ) ; parent = producerInfo ; } static RegistrationInfo createUndeterminedRegistration ( ProducerInfo producerInfo ) { return new RegistrationInfo ( producerInfo ) ; } public boolean isUndetermined ( ) { return UNDETERMINED_REGISTRATION . equals ( persistentConsumerName ) ; } public RegistrationInfo ( ProducerInfo producerInfo , boolean requiresRegistration ) { this ( producerInfo ) ; this . requiresRegistration = requiresRegistration ; } RegistrationInfo ( ) { persistentConsumerName = UNDETERMINED_REGISTRATION ; } public RegistrationInfo ( RegistrationInfo other ) { ParameterValidation . throwIllegalArgExceptionIfNull ( other , "<STR_LIT>" ) ; this . persistentConsumerName = other . persistentConsumerName ; this . persistentRegistrationHandle = other . persistentRegistrationHandle ; this . parent = other . parent ; if ( other . persistentRegistrationState != null ) { this . persistentRegistrationState = new byte [ other . persistentRegistrationState . length ] ; System . arraycopy ( other . persistentRegistrationState , <NUM_LIT:0> , this . persistentRegistrationState , <NUM_LIT:0> , other . persistentRegistrationState . length ) ; } if ( other . persistentRegistrationProperties != null ) { this . persistentRegistrationProperties = new HashMap < QName , RegistrationProperty > ( other . persistentRegistrationProperties . size ( ) ) ; for ( RegistrationProperty otherProp : other . persistentRegistrationProperties . values ( ) ) { QName name = otherProp . getName ( ) ; RegistrationProperty prop = new RegistrationProperty ( name , otherProp . getValue ( ) , otherProp . getLang ( ) , this ) ; prop . setStatus ( otherProp . getStatus ( ) ) ; this . persistentRegistrationProperties . put ( name , prop ) ; } } } public Long getKey ( ) { return key ; } public void setKey ( Long key ) { this . key = key ; } public String getRegistrationHandle ( ) { return persistentRegistrationHandle ; } public void setRegistrationHandle ( String registrationHandle ) { this . persistentRegistrationHandle = registrationHandle ; } public byte [ ] getRegistrationState ( ) { return persistentRegistrationState ; } public void setRegistrationState ( byte [ ] registrationState ) { this . persistentRegistrationState = registrationState ; } public ProducerInfo getParent ( ) { return parent ; } public void setParent ( ProducerInfo parent ) { this . parent = parent ; } public boolean isRefreshNeeded ( ) { boolean result = requiresRegistration == null || isModifiedSinceLastRefresh ( ) ; if ( result ) { log . debug ( "<STR_LIT>" ) ; } return result ; } public Boolean isRegistrationValid ( ) { if ( consistentWithProducerExpectations == null || requiresRegistration == null ) { return null ; } return consistentWithProducerExpectations && hasRegisteredIfNeeded ( ) ; } private boolean hasRegisteredIfNeeded ( ) { return ( persistentRegistrationHandle != null && isRegistrationDeterminedRequired ( ) ) || isRegistrationDeterminedNotRequired ( ) ; } public Boolean isConsistentWithProducerExpectations ( ) { return consistentWithProducerExpectations ; } public Boolean isRegistrationRequired ( ) { return requiresRegistration ; } public boolean isRegistrationDeterminedRequired ( ) { if ( requiresRegistration == null ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } return requiresRegistration ; } public boolean isRegistrationDeterminedNotRequired ( ) { if ( requiresRegistration == null ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } return ! requiresRegistration ; } public boolean hasLocalInfo ( ) { return persistentRegistrationHandle != null || isRegistrationPropertiesExisting ( ) ; } public boolean isRegistrationPropertiesExisting ( ) { return persistentRegistrationProperties != null && ! persistentRegistrationProperties . isEmpty ( ) ; } public RegistrationData getRegistrationData ( ) { if ( registrationData == null || regenerateRegistrationData ) { registrationData = WSRPTypeFactory . createDefaultRegistrationData ( ) ; registrationData . setConsumerName ( persistentConsumerName ) ; List < Property > properties = new ArrayList < Property > ( ) ; Map regProps = getRegistrationProperties ( false ) ; if ( ! regProps . isEmpty ( ) ) { for ( Object o : regProps . values ( ) ) { RegistrationProperty prop = ( RegistrationProperty ) o ; String value = prop . getValue ( ) ; if ( value != null && ! prop . isDeterminedInvalid ( ) ) { properties . add ( WSRPTypeFactory . createProperty ( prop . getName ( ) , prop . getLang ( ) , prop . getValue ( ) ) ) ; } } registrationData . getRegistrationProperties ( ) . addAll ( properties ) ; } regenerateRegistrationData = false ; } return registrationData ; } public String getConsumerName ( ) { return persistentConsumerName ; } public void setConsumerName ( String consumerName ) { this . persistentConsumerName = consumerName ; } public String getConsumerAgent ( ) { return WSRPConstants . CONSUMER_AGENT ; } public RegistrationProperty getRegistrationProperty ( String name ) { QName qName = QName . valueOf ( name ) ; return getRegistrationProperty ( qName ) ; } public RegistrationProperty getRegistrationProperty ( QName name ) { ParameterValidation . throwIllegalArgExceptionIfNull ( name , "<STR_LIT>" ) ; return getRegistrationProperties ( false ) . get ( name ) ; } public RegistrationProperty setRegistrationPropertyValue ( String name , String value ) { QName qName = QName . valueOf ( name ) ; return setRegistrationPropertyValue ( qName , value ) ; } public RegistrationProperty setRegistrationPropertyValue ( QName name , String value ) { ParameterValidation . throwIllegalArgExceptionIfNull ( name , "<STR_LIT>" ) ; RegistrationProperty prop = getOrCreateRegistrationPropertiesMap ( true ) . get ( name ) ; if ( prop != null ) { prop . setValue ( value ) ; } else { prop = new RegistrationProperty ( name , value , WSRPConstants . DEFAULT_LOCALE , this ) ; getOrCreateRegistrationPropertiesMap ( false ) . put ( name , prop ) ; } return prop ; } public void removeRegistrationProperty ( String name ) { QName qName = QName . valueOf ( name ) ; removeRegistrationProperty ( qName ) ; } public void removeRegistrationProperty ( QName name ) { ParameterValidation . throwIllegalArgExceptionIfNull ( name , "<STR_LIT>" ) ; Map < QName , RegistrationProperty > propertiesMap = getOrCreateRegistrationPropertiesMap ( false ) ; if ( propertiesMap == null || propertiesMap . remove ( name ) == null ) { throw new IllegalArgumentException ( "<STR_LIT>" + name + "<STR_LIT:'>" ) ; } setModifiedSinceLastRefresh ( true ) ; setModifyRegistrationNeeded ( true ) ; } private Map < QName , RegistrationProperty > getOrCreateRegistrationPropertiesMap ( boolean forceCreate ) { if ( forceCreate && persistentRegistrationProperties == null ) { persistentRegistrationProperties = new HashMap < QName , RegistrationProperty > ( ) ; } return persistentRegistrationProperties ; } public Map < QName , RegistrationProperty > getRegistrationProperties ( ) { return getRegistrationProperties ( true ) ; } private Map < QName , RegistrationProperty > getRegistrationProperties ( boolean immutable ) { Map < QName , RegistrationProperty > properties = getOrCreateRegistrationPropertiesMap ( false ) ; if ( properties != null ) { if ( immutable ) { return Collections . unmodifiableMap ( properties ) ; } else { return properties ; } } else { return Collections . emptyMap ( ) ; } } public void setRegistrationProperties ( Map registrationProperties ) { this . persistentRegistrationProperties = registrationProperties ; regenerateRegistrationData = true ; } Set < QName > getRegistrationPropertyNames ( ) { return getRegistrationProperties ( ) . keySet ( ) ; } public RegistrationRefreshResult refresh ( ServiceDescription serviceDescription , String producerId , boolean mergeWithLocalInfo , boolean forceRefresh , boolean forceCheckOfExtraProps ) { log . debug ( "<STR_LIT>" ) ; if ( forceRefresh || isRefreshNeeded ( ) ) { if ( isUndetermined ( ) ) { Version version = parent . getEndpointConfigurationInfo ( ) . getWSRPVersion ( ) ; String versionInfo = version != null ? "<STR_LIT>" + version . getMajor ( ) + "<STR_LIT>" : "<STR_LIT>" ; setConsumerName ( WSRPConstants . DEFAULT_CONSUMER_NAME + versionInfo ) ; } String msg = "<STR_LIT>" ; if ( serviceDescription == null && parent != null ) { try { serviceDescription = parent . getServiceDescription ( true ) ; } catch ( PortletInvokerException e ) { log . debug ( msg , e ) ; serviceDescription = null ; } } if ( serviceDescription == null ) { throw new IllegalArgumentException ( msg ) ; } persistentRegistrationProperties = getOrCreateRegistrationPropertiesMap ( true ) ; RegistrationRefreshResult result = new RegistrationRefreshResult ( ) ; result . setServiceDescription ( serviceDescription ) ; if ( ! mergeWithLocalInfo ) { result . setRegistrationProperties ( new HashMap < QName , RegistrationProperty > ( persistentRegistrationProperties ) ) ; } setModifiedSinceLastRefresh ( false ) ; setModifyRegistrationNeeded ( false ) ; if ( serviceDescription . isRequiresRegistration ( ) ) { requiresRegistration = Boolean . TRUE ; log . debug ( "<STR_LIT>" + producerId + "<STR_LIT>" ) ; ModelDescription regPropDescs = serviceDescription . getRegistrationPropertyDescription ( ) ; if ( regPropDescs != null ) { result . setStatus ( RefreshResult . Status . SUCCESS ) ; List < PropertyDescription > propertyDescriptions = regPropDescs . getPropertyDescriptions ( ) ; if ( propertyDescriptions != null && ! propertyDescriptions . isEmpty ( ) ) { Map < QName , RegistrationProperty > descriptionsMap = getRegistrationPropertyDescriptionsFromWSRP ( propertyDescriptions ) ; Set < QName > expectedNames = descriptionsMap . keySet ( ) ; checkForExtraProperties ( producerId , result , expectedNames , persistentRegistrationProperties , ! mergeWithLocalInfo ) ; for ( RegistrationProperty prop : descriptionsMap . values ( ) ) { QName name = prop . getName ( ) ; RegistrationProperty existing = getRegistrationProperty ( name ) ; if ( existing != null ) { existing . setDescription ( prop . getDescription ( ) ) ; if ( existing . isDeterminedInvalid ( ) ) { result . setStatus ( RefreshResult . Status . FAILURE ) ; } } else { if ( mergeWithLocalInfo ) { persistentRegistrationProperties . put ( name , prop ) ; } else { prop . setStatus ( RegistrationProperty . Status . MISSING ) ; result . getRegistrationProperties ( ) . put ( name , prop ) ; } log . debug ( "<STR_LIT>" + name + "<STR_LIT:'>" ) ; setResultAsFailedOrModifyNeeded ( result ) ; } } } else { handleNoRequiredRegistrationProperties ( producerId , result , ! mergeWithLocalInfo , forceCheckOfExtraProps ) ; } } else { handleNoRequiredRegistrationProperties ( producerId , result , ! mergeWithLocalInfo , forceCheckOfExtraProps ) ; } } else { log . debug ( "<STR_LIT>" + producerId + "<STR_LIT>" ) ; requiresRegistration = Boolean . FALSE ; result . setStatus ( RefreshResult . Status . SUCCESS ) ; } if ( mergeWithLocalInfo ) { result . setRegistrationProperties ( persistentRegistrationProperties ) ; } consistentWithProducerExpectations = ! result . hasIssues ( ) ; log . debug ( "<STR_LIT>" + ( consistentWithProducerExpectations ? "<STR_LIT>" : "<STR_LIT>" ) + "<STR_LIT>" ) ; return result ; } else { RegistrationRefreshResult result = new RegistrationRefreshResult ( ) ; result . setStatus ( RefreshResult . Status . BYPASSED ) ; result . setRegistrationProperties ( persistentRegistrationProperties ) ; result . setServiceDescription ( serviceDescription ) ; return result ; } } private void handleNoRequiredRegistrationProperties ( String producerId , RegistrationRefreshResult result , boolean keepExtra , boolean forceCheckOfExtraProps ) { log . debug ( "<STR_LIT>" ) ; Map < QName , RegistrationProperty > properties = getOrCreateRegistrationPropertiesMap ( false ) ; if ( properties != null && ! properties . isEmpty ( ) ) { if ( forceCheckOfExtraProps || ! hasRegisteredIfNeeded ( ) ) { log . debug ( "<STR_LIT>" ) ; checkForExtraProperties ( producerId , result , Collections . < QName > emptySet ( ) , properties , keepExtra ) ; } else { log . debug ( "<STR_LIT>" ) ; result . setStatus ( RefreshResult . Status . SUCCESS ) ; } } else { log . debug ( "<STR_LIT>" + producerId + "<STR_LIT:'>" ) ; registrationData = WSRPTypeFactory . createDefaultRegistrationData ( ) ; registrationData . setConsumerName ( getConsumerName ( ) ) ; result . setStatus ( RefreshResult . Status . SUCCESS ) ; } } private void checkForExtraProperties ( String producerId , RegistrationRefreshResult result , Set < QName > expectedNames , Map < QName , RegistrationProperty > properties , boolean keepExtra ) { Set < QName > unexpected = new HashSet < QName > ( properties . keySet ( ) ) ; unexpected . removeAll ( expectedNames ) ; if ( ! unexpected . isEmpty ( ) ) { StringBuffer message = new StringBuffer ( "<STR_LIT>" ) ; int size = unexpected . size ( ) ; int index = <NUM_LIT:0> ; for ( QName name : unexpected ) { message . append ( "<STR_LIT:'>" ) . append ( name ) . append ( "<STR_LIT:'>" ) ; if ( keepExtra ) { RegistrationProperty prop = properties . get ( name ) ; prop . setStatus ( RegistrationProperty . Status . INVALID_VALUE ) ; prop = result . getRegistrationProperties ( ) . get ( name ) ; prop . setStatus ( RegistrationProperty . Status . INEXISTENT ) ; } else { message . append ( "<STR_LIT>" ) ; properties . remove ( name ) ; } if ( index ++ != size - <NUM_LIT:1> ) { message . append ( "<STR_LIT:;>" ) ; } } log . debug ( message . toString ( ) ) ; setResultAsFailedOrModifyNeeded ( result ) ; } } private void setResultAsFailedOrModifyNeeded ( RegistrationRefreshResult result ) { if ( persistentRegistrationHandle != null ) { result . setStatus ( RefreshResult . Status . MODIFY_REGISTRATION_REQUIRED ) ; setModifyRegistrationNeeded ( true ) ; } else { result . setStatus ( RefreshResult . Status . FAILURE ) ; } } private Map < QName , RegistrationProperty > getRegistrationPropertyDescriptionsFromWSRP ( List < PropertyDescription > descriptions ) { if ( ParameterValidation . existsAndIsNotEmpty ( descriptions ) ) { Map < QName , RegistrationProperty > result = new HashMap < QName , RegistrationProperty > ( descriptions . size ( ) ) ; for ( PropertyDescription description : descriptions ) { QName name = description . getName ( ) ; RegistrationPropertyDescription desc = WSRPUtils . convertToRegistrationPropertyDescription ( description ) ; RegistrationProperty prop = new RegistrationProperty ( name , null , WSRPUtils . toString ( desc . getLang ( ) ) , this ) ; prop . setDescription ( desc ) ; prop . setStatus ( RegistrationProperty . Status . MISSING_VALUE ) ; result . put ( name , prop ) ; } return result ; } else { return Collections . emptyMap ( ) ; } } void resetRegistration ( ) { persistentRegistrationHandle = null ; persistentRegistrationState = null ; } public void setRegistrationContext ( RegistrationContext registrationContext ) { ParameterValidation . throwIllegalArgExceptionIfNull ( registrationContext , "<STR_LIT>" ) ; String handle = registrationContext . getRegistrationHandle ( ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( handle , "<STR_LIT>" , "<STR_LIT>" ) ; persistentRegistrationHandle = handle ; persistentRegistrationState = registrationContext . getRegistrationState ( ) ; setRegistrationValidInternalState ( ) ; } void setRegistrationValidInternalState ( ) { getRegistrationData ( ) ; if ( persistentRegistrationProperties != null ) { for ( Object o : persistentRegistrationProperties . values ( ) ) { RegistrationProperty prop = ( RegistrationProperty ) o ; prop . setStatus ( RegistrationProperty . Status . VALID ) ; } } consistentWithProducerExpectations = Boolean . TRUE ; requiresRegistration = Boolean . TRUE ; setModifiedSinceLastRefresh ( false ) ; setModifyRegistrationNeeded ( false ) ; } public RegistrationContext getRegistrationContext ( ) { if ( persistentRegistrationHandle != null ) { RegistrationContext registrationContext = WSRPTypeFactory . createRegistrationContext ( persistentRegistrationHandle ) ; registrationContext . setRegistrationState ( persistentRegistrationState ) ; return registrationContext ; } else { return null ; } } public boolean isModifyRegistrationNeeded ( ) { return modifyRegistrationNeeded ; } public boolean isModifiedSinceLastRefresh ( ) { return modifiedSinceLastRefresh ; } public void setModifiedSinceLastRefresh ( boolean modifiedSinceLastRefresh ) { this . modifiedSinceLastRefresh = modifiedSinceLastRefresh ; } public void propertyValueChanged ( RegistrationProperty property , RegistrationProperty . Status previousStatus , Object oldValue , Object newValue ) { setModifiedSinceLastRefresh ( true ) ; if ( previousStatus != null && ! RegistrationProperty . Status . MISSING_VALUE . equals ( previousStatus ) && ! RegistrationProperty . Status . UNCHECKED_VALUE . equals ( previousStatus ) ) { setModifyRegistrationNeeded ( true ) ; } regenerateRegistrationData = true ; parent . modifyNow ( ) ; } private void setModifyRegistrationNeeded ( boolean modifyRegistrationNeeded ) { this . modifyRegistrationNeeded = modifyRegistrationNeeded ; } public boolean isRegistered ( ) { Boolean valid = isRegistrationValid ( ) ; if ( valid == null ) { return getRegistrationHandle ( ) != null ; } else { return valid ; } } public class RegistrationRefreshResult extends RefreshResult { private Map < QName , RegistrationProperty > registrationProperties ; public RegistrationRefreshResult ( ) { super ( ) ; } public Map < QName , RegistrationProperty > getRegistrationProperties ( ) { return registrationProperties ; } public void setRegistrationProperties ( Map < QName , RegistrationProperty > registrationProperties ) { this . registrationProperties = registrationProperties ; } } } </s>
|
<s> package org . gatein . wsrp . consumer ; import org . oasis . wsrp . v2 . ServiceDescription ; import static org . gatein . wsrp . consumer . RefreshResult . Status . * ; public class RefreshResult { public enum Status { SUCCESS , FAILURE , UNAVAILABLE , BYPASSED , UNKNOWN , MODIFY_REGISTRATION_REQUIRED } private ServiceDescription serviceDescription ; private Status status ; private RefreshResult registrationResult ; public RefreshResult ( ) { this ( SUCCESS ) ; } public RefreshResult ( Status status ) { this . status = status ; } public RefreshResult getRegistrationResult ( ) { return registrationResult ; } public void setRegistrationResult ( RefreshResult registrationResult ) { if ( registrationResult != null ) { this . registrationResult = registrationResult ; RefreshResult . Status regStatus = registrationResult . getStatus ( ) ; if ( ! BYPASSED . equals ( regStatus ) ) { status = regStatus ; } } } public boolean didRefreshHappen ( ) { return ! BYPASSED . equals ( status ) && ! FAILURE . equals ( status ) ; } public boolean hasIssues ( ) { return ! ( SUCCESS . equals ( status ) || BYPASSED . equals ( status ) ) ; } public Status getStatus ( ) { return status ; } public void setStatus ( Status status ) { this . status = status ; } public void setServiceDescription ( ServiceDescription serviceDescription ) { this . serviceDescription = serviceDescription ; } public ServiceDescription getServiceDescription ( ) { return serviceDescription ; } } </s>
|
<s> package org . gatein . wsrp . consumer ; import org . gatein . common . util . ParameterValidation ; import org . gatein . common . util . Version ; import org . gatein . pc . api . InvokerUnavailableException ; import org . gatein . wsrp . services . MarkupService ; import org . gatein . wsrp . services . PortletManagementService ; import org . gatein . wsrp . services . RegistrationService ; import org . gatein . wsrp . services . SOAPServiceFactory ; import org . gatein . wsrp . services . ServiceDescriptionService ; import org . gatein . wsrp . services . ServiceFactory ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; public class EndpointConfigurationInfo { private final static Logger log = LoggerFactory . getLogger ( EndpointConfigurationInfo . class ) ; private transient ServiceFactory serviceFactory ; private transient String remoteHostAddress ; private transient boolean started ; public EndpointConfigurationInfo ( ) { serviceFactory = new SOAPServiceFactory ( ) ; } public EndpointConfigurationInfo ( ServiceFactory serviceFactory ) { ParameterValidation . throwIllegalArgExceptionIfNull ( serviceFactory , "<STR_LIT>" ) ; this . serviceFactory = serviceFactory ; } public String getWsdlDefinitionURL ( ) { return serviceFactory . getWsdlDefinitionURL ( ) ; } public void setWsdlDefinitionURL ( String wsdlDefinitionURL ) { serviceFactory . setWsdlDefinitionURL ( wsdlDefinitionURL ) ; } public void start ( ) throws Exception { if ( ! started ) { serviceFactory . start ( ) ; started = true ; } } public void stop ( ) throws Exception { if ( started ) { serviceFactory . stop ( ) ; started = false ; } } ServiceFactory getServiceFactory ( ) { try { start ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } return serviceFactory ; } ServiceDescriptionService getServiceDescriptionService ( ) throws InvokerUnavailableException { try { return serviceFactory . getServiceDescriptionService ( ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( "<STR_LIT>" + e . getLocalizedMessage ( ) , e ) ; } } MarkupService getMarkupService ( ) throws InvokerUnavailableException { try { return serviceFactory . getMarkupService ( ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( "<STR_LIT>" + e . getLocalizedMessage ( ) , e ) ; } } PortletManagementService getPortletManagementService ( ) throws InvokerUnavailableException { try { return serviceFactory . getPortletManagementService ( ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( "<STR_LIT>" + e . getLocalizedMessage ( ) , e ) ; } } RegistrationService getRegistrationService ( ) throws InvokerUnavailableException { try { return serviceFactory . getRegistrationService ( ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( "<STR_LIT>" + e . getLocalizedMessage ( ) , e ) ; } } private < T > T getService ( Class < T > clazz ) throws InvokerUnavailableException { return getService ( clazz , getServiceFactory ( ) ) ; } private < T > T getService ( Class < T > clazz , ServiceFactory serviceFactory ) throws InvokerUnavailableException { try { return serviceFactory . getService ( clazz ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( "<STR_LIT>" + clazz . getSimpleName ( ) + "<STR_LIT>" + e . getLocalizedMessage ( ) , e ) ; } } public boolean isAvailable ( ) { return serviceFactory . isAvailable ( ) ; } public boolean isRefreshNeeded ( ) { boolean result = ! isAvailable ( ) ; if ( result && log . isDebugEnabled ( ) ) { log . debug ( "<STR_LIT>" ) ; } return result ; } public boolean refresh ( ) throws InvokerUnavailableException { return isRefreshNeeded ( ) && forceRefresh ( ) ; } boolean forceRefresh ( ) throws InvokerUnavailableException { try { return serviceFactory . refresh ( true ) ; } catch ( Exception e ) { throw new InvokerUnavailableException ( e ) ; } } public String getRemoteHostAddress ( ) { if ( remoteHostAddress == null ) { String wsdl = getWsdlDefinitionURL ( ) ; int hostBegin = wsdl . indexOf ( "<STR_LIT>" ) + <NUM_LIT:3> ; remoteHostAddress = wsdl . substring ( <NUM_LIT:0> , wsdl . indexOf ( '<CHAR_LIT:/>' , hostBegin ) ) ; } return remoteHostAddress ; } public void setWSOperationTimeOut ( int msBeforeTimeOut ) { serviceFactory . setWSOperationTimeOut ( msBeforeTimeOut ) ; } public int getWSOperationTimeOut ( ) { return serviceFactory . getWSOperationTimeOut ( ) ; } Version getWSRPVersion ( ) { return serviceFactory . getWSRPVersion ( ) ; } public boolean getWSSEnabled ( ) { return serviceFactory . isWSSEnabled ( ) ; } public void setWSSEnabled ( boolean enable ) { serviceFactory . enableWSS ( enable ) ; } public boolean isWSSAvailable ( ) { return serviceFactory . isWSSAvailable ( ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer ; public class ConsumerException extends RuntimeException { public ConsumerException ( ) { super ( ) ; } public ConsumerException ( String message ) { super ( message ) ; } public ConsumerException ( String message , Throwable cause ) { super ( message , cause ) ; } public ConsumerException ( Throwable cause ) { super ( cause ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . OpaqueStateString ; import org . gatein . pc . api . StateEvent ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . pc . api . invocation . response . UpdateNavigationalStateResponse ; import org . gatein . pc . api . spi . InstanceContext ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . gatein . wsrp . payload . PayloadUtils ; import org . oasis . wsrp . v2 . Event ; import org . oasis . wsrp . v2 . NamedString ; import org . oasis . wsrp . v2 . NavigationalContext ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . UpdateResponse ; import java . io . Serializable ; import java . util . Arrays ; import java . util . List ; import java . util . Map ; public abstract class NavigationalStateUpdatingHandler < Invocation extends PortletInvocation , Request , Response > extends InvocationHandler < Invocation , Request , Response > { public NavigationalStateUpdatingHandler ( WSRPConsumerImpl consumer ) { super ( consumer ) ; } protected UpdateNavigationalStateResponse processUpdateResponse ( Invocation invocation , RequestPrecursor < Invocation > requestPrecursor , UpdateResponse updateResponse , Response wsrpResponse ) { UpdateNavigationalStateResponse result = new UpdateNavigationalStateResponse ( ) ; String newMode = updateResponse . getNewMode ( ) ; if ( newMode != null ) { result . setMode ( WSRPUtils . getJSR168PortletModeFromWSRPName ( newMode ) ) ; } String newWindowState = updateResponse . getNewWindowState ( ) ; if ( newWindowState != null ) { result . setWindowState ( WSRPUtils . getJSR168WindowStateFromWSRPName ( newWindowState ) ) ; } NavigationalContext navigationalContext = updateResponse . getNavigationalContext ( ) ; if ( navigationalContext != null ) { String navigationalState = navigationalContext . getOpaqueValue ( ) ; if ( navigationalState != null ) { result . setNavigationalState ( new OpaqueStateString ( navigationalState ) ) ; } List < NamedString > publicParams = navigationalContext . getPublicValues ( ) ; if ( ParameterValidation . existsAndIsNotEmpty ( publicParams ) ) { Map < String , String [ ] > publicNS = WSRPUtils . createPublicNSFrom ( publicParams ) ; result . setPublicNavigationalStateUpdates ( publicNS ) ; } } List < Event > events = updateResponse . getEvents ( ) ; if ( ParameterValidation . existsAndIsNotEmpty ( events ) ) { for ( Event event : events ) { Serializable payloadAsSerializable = null ; boolean failedPayload = false ; try { payloadAsSerializable = PayloadUtils . getPayloadAsSerializable ( event ) ; } catch ( Exception e ) { failedPayload = true ; log . info ( "<STR_LIT>" + event . getName ( ) + "<STR_LIT>" , e ) ; } if ( ! failedPayload ) { result . queueEvent ( new UpdateNavigationalStateResponse . Event ( event . getName ( ) , payloadAsSerializable ) ) ; } } } processExtensions ( wsrpResponse ) ; PortletContext portletContext = updateResponse . getPortletContext ( ) ; SessionHandler sessionHandler = consumer . getSessionHandler ( ) ; if ( portletContext != null ) { PortletContext originalContext = requestPrecursor . getPortletContext ( ) ; InstanceContext context = invocation . getInstanceContext ( ) ; String handle = portletContext . getPortletHandle ( ) ; if ( ! originalContext . getPortletHandle ( ) . equals ( handle ) ) { if ( debug ) { log . debug ( "<STR_LIT>" + requestPrecursor . getPortletHandle ( ) + "<STR_LIT>" + handle + "<STR_LIT:'>" ) ; } StateEvent event = new StateEvent ( WSRPUtils . convertToPortalPortletContext ( portletContext ) , StateEvent . Type . PORTLET_CLONED_EVENT ) ; context . onStateEvent ( event ) ; } else { byte [ ] originalState = originalContext . getPortletState ( ) ; byte [ ] newState = portletContext . getPortletState ( ) ; if ( ! Arrays . equals ( originalState , newState ) ) { StateEvent event = new StateEvent ( WSRPUtils . convertToPortalPortletContext ( portletContext ) , StateEvent . Type . PORTLET_MODIFIED_EVENT ) ; context . onStateEvent ( event ) ; } } sessionHandler . updateSessionInfoFor ( originalContext . getPortletHandle ( ) , handle , invocation ) ; } else { portletContext = requestPrecursor . getPortletContext ( ) ; } sessionHandler . updateSessionIfNeeded ( updateResponse . getSessionContext ( ) , invocation , portletContext . getPortletHandle ( ) ) ; return result ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . InvokerUnavailableException ; import org . gatein . pc . api . Portlet ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . api . session . SessionEvent ; import org . gatein . wsrp . api . session . SessionEventListener ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . gatein . wsrp . consumer . portlet . info . WSRPPortletInfo ; import org . gatein . wsrp . handler . RequestHeaderClientHandler ; import org . gatein . wsrp . servlet . UserAccess ; import org . oasis . wsrp . v2 . CookieProtocol ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import org . oasis . wsrp . v2 . SessionParams ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . servlet . http . HttpSession ; import java . util . ArrayList ; import java . util . List ; import java . util . Map ; import java . util . Set ; public class SessionHandler implements SessionEventListener { protected WSRPConsumerImpl consumer ; private static Logger log = LoggerFactory . getLogger ( SessionHandler . class ) ; private static final String SESSION_ID_PREFIX = "<STR_LIT>" ; public SessionHandler ( WSRPConsumerImpl consumer ) { this . consumer = consumer ; } public boolean isPerUserCookieInit ( ) { return CookieProtocol . PER_USER . equals ( getRequiresInitCookie ( ) ) ; } public boolean requiresInitCookie ( ) { return getRequiresInitCookie ( ) != null && ! CookieProtocol . NONE . equals ( getRequiresInitCookie ( ) ) ; } void initProducerSessionInformation ( PortletInvocation invocation ) throws PortletInvokerException { String groupId ; if ( requiresGroupInitCookie ( ) ) { WSRPPortletInfo info = consumer . getPortletInfo ( invocation ) ; groupId = info . getGroupId ( ) ; } else { groupId = null ; } RequestHeaderClientHandler . setCurrentInfo ( groupId , getProducerSessionInformation ( invocation , true ) ) ; } private boolean requiresGroupInitCookie ( ) { return requiresInitCookie ( ) && CookieProtocol . PER_GROUP . equals ( getRequiresInitCookie ( ) ) ; } public void resetCurrentlyHeldInformation ( ) { RequestHeaderClientHandler . resetCurrentInfo ( ) ; } public void initCookieIfNeeded ( PortletInvocation invocation ) throws PortletInvokerException { initCookieIfNeeded ( invocation , true ) ; } private void initCookieIfNeeded ( PortletInvocation invocation , boolean retryIfFails ) throws PortletInvokerException { if ( ! requiresInitCookie ( ) ) { log . debug ( "<STR_LIT>" ) ; return ; } ProducerSessionInformation sessionInformation = getProducerSessionInformation ( invocation ) ; if ( sessionInformation . isInitCookieDone ( ) ) { return ; } RequestHeaderClientHandler . setCurrentInfo ( null , sessionInformation ) ; if ( isPerUserCookieInit ( ) ) { log . debug ( "<STR_LIT>" ) ; sessionInformation . setPerGroupCookies ( false ) ; initCookie ( invocation , retryIfFails ) ; } else { log . debug ( "<STR_LIT>" ) ; sessionInformation . setPerGroupCookies ( true ) ; Map < String , Set < Portlet > > groups = consumer . getPortletGroupMap ( ) ; try { for ( String groupId : groups . keySet ( ) ) { RequestHeaderClientHandler . setCurrentGroupId ( groupId ) ; log . debug ( "<STR_LIT>" + groupId + "<STR_LIT>" ) ; initCookie ( invocation , retryIfFails ) ; } } finally { resetCurrentlyHeldInformation ( ) ; } } sessionInformation . setInitCookieDone ( true ) ; } private void initCookie ( PortletInvocation invocation , boolean retryIfFails ) throws PortletInvokerException { try { consumer . getMarkupService ( ) . initCookie ( consumer . getRegistrationContext ( ) , UserAccess . getUserContext ( ) ) ; } catch ( InvalidRegistration invalidRegistration ) { consumer . handleInvalidRegistrationFault ( ) ; if ( retryIfFails ) { initCookieIfNeeded ( invocation , false ) ; } } catch ( Exception e ) { throw new InvokerUnavailableException ( "<STR_LIT>" , e ) ; } } void setSessionIdIfNeeded ( PortletInvocation invocation , RuntimeContext runtimeContext , String portletHandle ) { ProducerSessionInformation producerSessionInfo = getProducerSessionInformation ( invocation , false ) ; if ( producerSessionInfo != null ) { String sessionId = producerSessionInfo . getSessionIdForPortlet ( portletHandle ) ; SessionParams sessionParams = runtimeContext . getSessionParams ( ) ; if ( sessionParams == null ) { sessionParams = WSRPTypeFactory . createSessionParams ( sessionId ) ; runtimeContext . setSessionParams ( sessionParams ) ; } else { sessionParams . setSessionID ( sessionId ) ; } } } public void updateSessionIfNeeded ( SessionContext sessionContext , PortletInvocation invocation , String portletHandle ) { if ( sessionContext != null ) { log . debug ( "<STR_LIT>" + portletHandle + "<STR_LIT>" + sessionContext . getSessionID ( ) + "<STR_LIT:'>" ) ; ProducerSessionInformation sessionInfo = getProducerSessionInformation ( invocation ) ; sessionInfo . addSessionForPortlet ( portletHandle , sessionContext ) ; } } void updateCookiesIfNeeded ( PortletInvocation invocation ) { ProducerSessionInformation sessionInfo = getProducerSessionInformation ( invocation , true ) ; ProducerSessionInformation currentSessionInfo = RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ; if ( sessionInfo != currentSessionInfo ) { sessionInfo . replaceUserCookiesWith ( currentSessionInfo ) ; } } public ProducerSessionInformation getProducerSessionInformation ( PortletInvocation invocation ) { return getProducerSessionInformation ( invocation , true ) ; } private ProducerSessionInformation getProducerSessionInformation ( PortletInvocation invocation , boolean create ) { HttpSession session = WSRPConsumerImpl . getHttpSession ( invocation ) ; return getProducerSessionInformation ( session , create ) ; } public ProducerSessionInformation getProducerSessionInformation ( HttpSession session ) { return getProducerSessionInformation ( session , false ) ; } private ProducerSessionInformation getProducerSessionInformation ( HttpSession session , boolean create ) { ParameterValidation . throwIllegalArgExceptionIfNull ( session , "<STR_LIT>" ) ; String producerSessionKey = getProducerSessionInformationKey ( ) ; ProducerSessionInformation sessionInformation = ( ProducerSessionInformation ) session . getAttribute ( producerSessionKey ) ; if ( sessionInformation != null ) { sessionInformation . setParent ( this ) ; sessionInformation . setParentSessionId ( session . getId ( ) ) ; } else { if ( create ) { sessionInformation = new ProducerSessionInformation ( ) ; sessionInformation . setParentSessionId ( session . getId ( ) ) ; session . setAttribute ( producerSessionKey , sessionInformation ) ; sessionInformation . setParent ( this ) ; } } return sessionInformation ; } private String getProducerSessionInformationKey ( ) { return SESSION_ID_PREFIX + consumer . getProducerId ( ) ; } void handleInvalidSessionFault ( PortletInvocation invocation , RuntimeContext runtimeContext ) { log . info ( "<STR_LIT>" ) ; invalidateSession ( invocation ) ; if ( runtimeContext != null ) { runtimeContext . setSessionParams ( null ) ; } } private void invalidateSession ( PortletInvocation invocation ) { HttpSession session = WSRPConsumerImpl . getHttpSession ( invocation ) ; ProducerSessionInformation info = getProducerSessionInformation ( session , false ) ; if ( info != null ) { try { internalReleaseSessions ( info . removeSessions ( ) ) ; } catch ( PortletInvokerException e ) { } } session . removeAttribute ( getProducerSessionInformationKey ( ) ) ; RequestHeaderClientHandler . resetCurrentInfo ( ) ; } public void releaseSessions ( ) throws PortletInvokerException { List < String > idsToRelease = new ArrayList < String > ( ) ; Set < ProducerSessionInformation > uniqueInfos = consumer . getSessionRegistry ( ) . getAll ( ) ; for ( ProducerSessionInformation info : uniqueInfos ) { idsToRelease . addAll ( info . removeSessions ( ) ) ; } internalReleaseSessions ( idsToRelease ) ; } void releaseSessions ( String [ ] sessionIds ) throws PortletInvokerException { if ( sessionIds != null ) { List < String > idsToRelease = new ArrayList < String > ( ) ; for ( String sessionId : sessionIds ) { ProducerSessionInformation info = consumer . getSessionRegistry ( ) . get ( sessionId ) ; sessionId = info . removeSession ( sessionId ) ; if ( sessionId != null ) { idsToRelease . add ( sessionId ) ; } } internalReleaseSessions ( idsToRelease ) ; } } private void internalReleaseSessions ( List < String > idsToRelease ) throws PortletInvokerException { if ( idsToRelease != null && ! idsToRelease . isEmpty ( ) ) { try { consumer . getMarkupService ( ) . releaseSessions ( consumer . getRegistrationContext ( ) , idsToRelease , UserAccess . getUserContext ( ) ) ; } catch ( InvalidRegistration invalidRegistration ) { log . debug ( "<STR_LIT>" ) ; consumer . handleInvalidRegistrationFault ( ) ; } catch ( Exception e ) { String message = "<STR_LIT>" + idsToRelease ; log . debug ( message , e ) ; throw new PortletInvokerException ( message , e ) ; } } } void removeSessionId ( String id ) { consumer . getSessionRegistry ( ) . remove ( id ) ; } void addSessionMapping ( String sessionID , ProducerSessionInformation producerSessionInformation ) { consumer . getSessionRegistry ( ) . put ( sessionID , producerSessionInformation ) ; } public void onSessionEvent ( SessionEvent event ) { if ( SessionEvent . SessionEventType . SESSION_DESTROYED . equals ( event . getType ( ) ) ) { String id = getRealId ( event . getSession ( ) . getId ( ) ) ; ProducerSessionInformation info = RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ; if ( info != null ) { if ( id != null && id . equals ( info . getParentSessionId ( ) ) ) { try { internalReleaseSessions ( info . removeSessions ( ) ) ; } catch ( PortletInvokerException e ) { } log . debug ( "<STR_LIT>" + id + "<STR_LIT>" ) ; } } } } public static String getRealId ( String sessionId ) { int index = sessionId . lastIndexOf ( "<STR_LIT:.>" ) ; if ( index > <NUM_LIT:0> ) { return sessionId . substring ( <NUM_LIT:0> , index ) ; } else { return sessionId ; } } public void updateSessionInfoFor ( String originalHandle , String newHandle , PortletInvocation invocation ) { ProducerSessionInformation info = getProducerSessionInformation ( invocation , false ) ; if ( info != null ) { info . updateHandleAssociatedInfo ( originalHandle , newHandle ) ; } } private CookieProtocol getRequiresInitCookie ( ) { return consumer . getProducerInfo ( ) . getRequiresInitCookie ( ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . text . TextTools ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . URLFormat ; import org . gatein . pc . api . cache . CacheScope ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . pc . api . invocation . response . ContentResponse ; import org . gatein . pc . api . invocation . response . ErrorResponse ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . pc . api . spi . PortletInvocationContext ; import org . gatein . pc . api . spi . SecurityContext ; import org . gatein . wsrp . MIMEUtils ; import org . gatein . wsrp . WSRPConstants ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . WSRPPortletURL ; import org . gatein . wsrp . WSRPRewritingConstants ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . spi . WSRPConsumerSPI ; import org . oasis . wsrp . v2 . CacheControl ; import org . oasis . wsrp . v2 . MimeResponse ; import org . oasis . wsrp . v2 . SessionContext ; import java . io . UnsupportedEncodingException ; import java . util . Set ; public abstract class MimeResponseHandler < Invocation extends PortletInvocation , Request , Response , LocalMimeResponse extends MimeResponse > extends InvocationHandler < Invocation , Request , Response > { private static final org . gatein . pc . api . cache . CacheControl DEFAULT_CACHE_CONTROL = new org . gatein . pc . api . cache . CacheControl ( <NUM_LIT:0> , CacheScope . PRIVATE , null ) ; protected MimeResponseHandler ( WSRPConsumerSPI consumer ) { super ( consumer ) ; } protected abstract SessionContext getSessionContextFrom ( Response response ) ; protected abstract LocalMimeResponse getMimeResponseFrom ( Response response ) ; @ Override protected PortletInvocationResponse processResponse ( Response response , Invocation invocation , RequestPrecursor < Invocation > requestPrecursor ) throws PortletInvokerException { consumer . getSessionHandler ( ) . updateSessionIfNeeded ( getSessionContextFrom ( response ) , invocation , requestPrecursor . getPortletHandle ( ) ) ; LocalMimeResponse mimeResponse = getMimeResponseFrom ( response ) ; processExtensions ( response ) ; return rewriteResponseIfNeeded ( mimeResponse , invocation ) ; } PortletInvocationResponse rewriteResponseIfNeeded ( final LocalMimeResponse mimeResponse , final Invocation invocation ) throws PortletInvokerException { String markup = mimeResponse . getItemString ( ) ; byte [ ] binary = mimeResponse . getItemBinary ( ) ; if ( markup != null && binary != null ) { return new ErrorResponse ( new IllegalArgumentException ( "<STR_LIT>" + "<STR_LIT>" ) ) ; } if ( markup == null && binary == null ) { if ( mimeResponse . isUseCachedItem ( ) != null && mimeResponse . isUseCachedItem ( ) ) { log . debug ( "<STR_LIT>" + consumer . getProducerId ( ) + "<STR_LIT>" ) ; } else { return new ErrorResponse ( new IllegalArgumentException ( "<STR_LIT>" + "<STR_LIT>" ) ) ; } } String mimeType = mimeResponse . getMimeType ( ) ; if ( ParameterValidation . isNullOrEmpty ( mimeType ) ) { return new ErrorResponse ( new IllegalArgumentException ( "<STR_LIT>" ) ) ; } if ( Boolean . TRUE . equals ( mimeResponse . isRequiresRewriting ( ) ) ) { if ( ! ParameterValidation . isNullOrEmpty ( markup ) ) { markup = processMarkup ( markup , invocation ) ; } if ( binary != null && binary . length > <NUM_LIT:0> && MIMEUtils . isInterpretableAsText ( mimeType ) ) { try { final String charset = MIMEUtils . getCharsetFrom ( mimeType ) ; String binaryAsString = new String ( binary , charset ) ; binaryAsString = processMarkup ( binaryAsString , invocation ) ; binary = binaryAsString . getBytes ( charset ) ; } catch ( UnsupportedEncodingException e ) { throw new PortletInvokerException ( "<STR_LIT>" , e ) ; } } } return createContentResponse ( mimeResponse , invocation , mimeType , binary , markup , createCacheControl ( mimeResponse ) ) ; } private String processMarkup ( String markup , Invocation invocation ) { SecurityContext securityContext = invocation . getSecurityContext ( ) ; markup = processMarkup ( markup , WSRPTypeFactory . getNamespaceFrom ( invocation . getWindowContext ( ) ) , invocation . getContext ( ) , invocation . getTarget ( ) , new URLFormat ( securityContext . isSecure ( ) , securityContext . isAuthenticated ( ) , true , true ) , consumer ) ; return markup ; } protected PortletInvocationResponse createContentResponse ( LocalMimeResponse mimeResponse , Invocation invocation , String mimeType , byte [ ] bytes , String markup , org . gatein . pc . api . cache . CacheControl cacheControl ) { if ( markup != null ) { return new ContentResponse ( null , null , mimeType , null , markup , createCacheControl ( mimeResponse ) ) ; } else { return new ContentResponse ( null , null , mimeType , MIMEUtils . UTF_8 , bytes , createCacheControl ( mimeResponse ) ) ; } } static String processMarkup ( String markup , String namespace , PortletInvocationContext context , org . gatein . pc . api . PortletContext target , URLFormat format , WSRPConsumer consumer ) { markup = TextTools . replaceBoundedString ( markup , WSRPRewritingConstants . BEGIN_WSRP_REWRITE , WSRPRewritingConstants . END_WSRP_REWRITE , new MarkupProcessor ( namespace , context , target , format , consumer . getProducerInfo ( ) ) , true , false ) ; markup = markup . replaceAll ( WSRPRewritingConstants . WSRP_REWRITE_TOKEN , namespace ) ; return markup ; } protected org . gatein . pc . api . cache . CacheControl createCacheControl ( LocalMimeResponse mimeResponse ) { CacheControl cacheControl = mimeResponse . getCacheControl ( ) ; org . gatein . pc . api . cache . CacheControl result = DEFAULT_CACHE_CONTROL ; int expires ; if ( cacheControl != null ) { expires = cacheControl . getExpires ( ) ; String userScope = cacheControl . getUserScope ( ) ; if ( consumer . supportsUserScope ( userScope ) ) { if ( debug ) { log . debug ( "<STR_LIT>" + userScope + "<STR_LIT>" + expires + "<STR_LIT>" ) ; } CacheScope scope ; if ( WSRPConstants . CACHE_FOR_ALL . equals ( userScope ) ) { scope = CacheScope . PUBLIC ; } else if ( WSRPConstants . CACHE_PER_USER . equals ( userScope ) ) { scope = CacheScope . PRIVATE ; } else { throw new IllegalArgumentException ( "<STR_LIT>" + userScope ) ; } result = new org . gatein . pc . api . cache . CacheControl ( expires , scope , cacheControl . getValidateTag ( ) ) ; } } return result ; } private static class MarkupProcessor implements TextTools . StringReplacementGenerator { private final PortletInvocationContext context ; private final URLFormat format ; private final Set < String > supportedCustomModes ; private final Set < String > supportedCustomWindowStates ; private final String namespace ; protected MarkupProcessor ( String namespace , PortletInvocationContext context , org . gatein . pc . api . PortletContext target , URLFormat format , ProducerInfo info ) { this . namespace = namespace ; this . context = context ; this . format = format ; supportedCustomModes = info . getSupportedCustomModes ( ) ; supportedCustomWindowStates = info . getSupportedCustomWindowStates ( ) ; } public String getReplacementFor ( String match , String prefix , String suffix , boolean matchedPrefixOnly ) { boolean useJavaScriptEscaping = false ; if ( match . contains ( "<STR_LIT>" ) || match . contains ( "<STR_LIT>" ) ) { useJavaScriptEscaping = true ; match = match . replaceAll ( "<STR_LIT>" , "<STR_LIT:->" ) . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; } WSRPPortletURL portletURL = WSRPPortletURL . create ( match , supportedCustomModes , supportedCustomWindowStates , true ) ; URLFormat urlFormat ; if ( match . contains ( "<STR_LIT>" ) ) { urlFormat = new URLFormat ( format . getWantSecure ( ) , format . getWantAuthenticated ( ) , format . getWantRelative ( ) , true ) ; } else { urlFormat = new URLFormat ( format . getWantSecure ( ) , format . getWantAuthenticated ( ) , format . getWantRelative ( ) , false ) ; } String value = context . renderURL ( portletURL , urlFormat ) ; if ( useJavaScriptEscaping ) { value = value . replaceAll ( "<STR_LIT:->" , "<STR_LIT>" ) . replaceAll ( "<STR_LIT>" , "<STR_LIT>" ) ; } return value ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . apache . commons . httpclient . Cookie ; import org . gatein . common . io . IOTools ; import org . gatein . common . util . MultiValuedPropertyMap ; import org . gatein . common . util . Tools ; import org . gatein . pc . api . invocation . response . ResponseProperties ; import org . gatein . wsrp . MIMEUtils ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . consumer . spi . WSRPConsumerSPI ; import org . gatein . wsrp . handler . CookieUtil ; import org . gatein . wsrp . handler . RequestHeaderClientHandler ; import org . oasis . wsrp . v2 . GetResource ; import org . oasis . wsrp . v2 . ResourceContext ; import org . oasis . wsrp . v2 . ResourceResponse ; import java . net . URL ; import java . net . URLConnection ; import java . util . List ; import java . util . Map ; public class DirectResourceServingHandler extends ResourceHandler { protected DirectResourceServingHandler ( WSRPConsumerSPI consumer ) { super ( consumer ) ; } @ Override protected ResourceResponse performRequest ( GetResource getResource ) throws Exception { String resourceURL = getResource . getResourceParams ( ) . getResourceID ( ) ; URL url = new URL ( resourceURL ) ; URLConnection urlConnection = url . openConnection ( ) ; ProducerSessionInformation sessionInfo = RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ; if ( sessionInfo != null ) { String cookie = RequestHeaderClientHandler . createCookie ( sessionInfo ) ; if ( cookie . length ( ) != <NUM_LIT:0> ) { urlConnection . addRequestProperty ( CookieUtil . COOKIE , cookie ) ; } } String contentType = urlConnection . getContentType ( ) ; Map < String , List < String > > headers = urlConnection . getHeaderFields ( ) ; ResponseProperties props = new ResponseProperties ( ) ; MultiValuedPropertyMap < String > transportHeaders = props . getTransportHeaders ( ) ; for ( Map . Entry < String , List < String > > entry : headers . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( key != null ) { List < String > values = entry . getValue ( ) ; if ( values != null ) { if ( CookieUtil . SET_COOKIE . equals ( key ) ) { Cookie [ ] cookies = CookieUtil . extractCookiesFrom ( url , values . toArray ( new String [ values . size ( ) ] ) ) ; List < javax . servlet . http . Cookie > propCookies = props . getCookies ( ) ; for ( Cookie cookie : cookies ) { propCookies . add ( CookieUtil . convertFrom ( cookie ) ) ; } } else { for ( String value : values ) { transportHeaders . addValue ( key , value ) ; } } } } } int length = urlConnection . getContentLength ( ) ; length = ( length > <NUM_LIT:0> ? length : Tools . DEFAULT_BUFFER_SIZE * <NUM_LIT:8> ) ; byte [ ] bytes = IOTools . getBytes ( urlConnection . getInputStream ( ) , length ) ; ResourceContext resourceContext ; if ( MIMEUtils . isInterpretableAsText ( contentType ) ) { String charset = MIMEUtils . getCharsetFrom ( contentType ) ; String markup = new String ( bytes , charset ) ; resourceContext = WSRPTypeFactory . createResourceContext ( contentType , markup , null ) ; if ( MIMEUtils . needsRewriting ( contentType ) ) { resourceContext . setRequiresRewriting ( true ) ; } } else { resourceContext = WSRPTypeFactory . createResourceContext ( contentType , null , bytes ) ; resourceContext . setRequiresRewriting ( false ) ; } return WSRPTypeFactory . createResourceResponse ( resourceContext ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . net . media . MediaType ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . StateString ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . pc . api . invocation . response . ErrorResponse ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . pc . api . spi . InstanceContext ; import org . gatein . pc . api . spi . PortletInvocationContext ; import org . gatein . pc . api . spi . SecurityContext ; import org . gatein . pc . api . spi . WindowContext ; import org . gatein . wsrp . WSRPConstants ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . api . extensions . ExtensionAccess ; import org . gatein . wsrp . api . extensions . UnmarshalledExtension ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . gatein . wsrp . consumer . portlet . info . WSRPPortletInfo ; import org . gatein . wsrp . consumer . spi . WSRPConsumerSPI ; import org . gatein . wsrp . payload . PayloadUtils ; import org . gatein . wsrp . spec . v2 . WSRP2RewritingConstants ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . InvalidCookie ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidSession ; import org . oasis . wsrp . v2 . MarkupParams ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . NavigationalContext ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . UserContext ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import java . rmi . RemoteException ; import java . util . Collections ; import java . util . List ; import java . util . Map ; public abstract class InvocationHandler < Invocation extends PortletInvocation , Request , Response > { protected final WSRPConsumerSPI consumer ; protected static Logger log = LoggerFactory . getLogger ( InvocationHandler . class ) ; protected static boolean debug = log . isDebugEnabled ( ) ; protected static boolean trace = log . isTraceEnabled ( ) ; private static final int DO_NOT_RETRY = - <NUM_LIT:1> ; private static final int MAXIMUM_RETRY_NUMBER = <NUM_LIT:3> ; protected InvocationHandler ( WSRPConsumerSPI consumer ) { this . consumer = consumer ; } public PortletInvocationResponse handle ( Invocation invocation ) throws PortletInvokerException { RequestPrecursor < Invocation > requestPrecursor = new RequestPrecursor < Invocation > ( consumer , invocation ) ; Request request = prepareRequest ( requestPrecursor , invocation ) ; try { Response response = performRequest ( request , invocation ) ; return processResponse ( response , invocation , requestPrecursor ) ; } catch ( Exception e ) { if ( ! ( e instanceof PortletInvokerException ) ) { ErrorResponse errorResponse = dealWithError ( e , invocation , getRuntimeContextFrom ( request ) ) ; if ( errorResponse != null ) { return unwrapWSRPError ( errorResponse ) ; } else { return new ErrorResponse ( e ) ; } } else { throw ( PortletInvokerException ) e ; } } } protected Response performRequest ( Request request , PortletInvocation invocation ) throws Exception { int retryCount = <NUM_LIT:0> ; Response response = null ; while ( response == null && retryCount ++ <= MAXIMUM_RETRY_NUMBER ) { if ( debug ) { log . debug ( "<STR_LIT>" + retryCount + "<STR_LIT>" + MAXIMUM_RETRY_NUMBER + "<STR_LIT>" ) ; } SessionHandler sessionHandler = consumer . getSessionHandler ( ) ; RuntimeContext runtimeContext = getRuntimeContextFrom ( request ) ; if ( runtimeContext != null ) { WindowContext windowContext = invocation . getWindowContext ( ) ; runtimeContext . setNamespacePrefix ( WSRPTypeFactory . getNamespaceFrom ( windowContext ) ) ; InstanceContext instanceContext = invocation . getInstanceContext ( ) ; runtimeContext . setPortletInstanceKey ( instanceContext == null ? null : instanceContext . getId ( ) ) ; } try { sessionHandler . initCookieIfNeeded ( invocation ) ; sessionHandler . initProducerSessionInformation ( invocation ) ; response = performRequest ( request ) ; sessionHandler . updateCookiesIfNeeded ( invocation ) ; } finally { sessionHandler . resetCurrentlyHeldInformation ( ) ; } } if ( retryCount >= MAXIMUM_RETRY_NUMBER ) { throw new RuntimeException ( "<STR_LIT>" + MAXIMUM_RETRY_NUMBER + "<STR_LIT>" + "<STR_LIT>" ) ; } if ( debug ) { log . debug ( "<STR_LIT>" + ( response != null ? response . getClass ( ) . getName ( ) : null ) ) ; } return response ; } private ErrorResponse dealWithError ( Exception error , Invocation invocation , RuntimeContext runtimeContext ) throws PortletInvokerException { log . error ( "<STR_LIT>" , error ) ; SessionHandler sessionHandler = consumer . getSessionHandler ( ) ; if ( error instanceof InvalidCookie ) { log . debug ( "<STR_LIT>" ) ; consumer . refreshProducerInfo ( ) ; try { sessionHandler . initCookieIfNeeded ( invocation ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + e . getLocalizedMessage ( ) ) ; return new ErrorResponse ( e ) ; } } else if ( error instanceof InvalidSession ) { log . debug ( "<STR_LIT>" ) ; sessionHandler . handleInvalidSessionFault ( invocation , runtimeContext ) ; } else if ( error instanceof InvalidRegistration ) { log . debug ( "<STR_LIT>" ) ; consumer . handleInvalidRegistrationFault ( ) ; } else if ( error instanceof ModifyRegistrationRequired ) { ProducerInfo producerInfo = consumer . getProducerInfo ( ) ; log . debug ( "<STR_LIT>" + producerInfo . getId ( ) + "<STR_LIT>" ) ; producerInfo . setModifyRegistrationRequired ( true ) ; producerInfo . setActiveAndSave ( false ) ; return new ErrorResponse ( error ) ; } else { return new ErrorResponse ( error ) ; } return null ; } protected ErrorResponse unwrapWSRPError ( ErrorResponse errorResponse ) { Throwable cause = errorResponse . getCause ( ) ; if ( cause != null ) { if ( cause instanceof OperationFailed && cause . getCause ( ) != null ) { cause = cause . getCause ( ) ; } else if ( cause instanceof RemoteException ) { cause = ( ( RemoteException ) cause ) . detail ; } log . debug ( "<STR_LIT>" + cause . getMessage ( ) , cause ) ; return new ErrorResponse ( cause ) ; } else { log . debug ( "<STR_LIT>" + errorResponse . getMessage ( ) ) ; return errorResponse ; } } protected abstract RuntimeContext getRuntimeContextFrom ( Request request ) ; protected abstract Response performRequest ( Request request ) throws Exception ; protected abstract Request prepareRequest ( RequestPrecursor < Invocation > requestPrecursor , Invocation invocation ) ; protected abstract PortletInvocationResponse processResponse ( Response response , Invocation invocation , RequestPrecursor < Invocation > requestPrecursor ) throws PortletInvokerException ; protected abstract List < Extension > getExtensionsFrom ( Response response ) ; protected void processExtensions ( Response response ) { for ( Extension extension : getExtensionsFrom ( response ) ) { try { final UnmarshalledExtension unmarshalledExtension = PayloadUtils . unmarshallExtension ( extension . getAny ( ) ) ; ExtensionAccess . getConsumerExtensionAccessor ( ) . addResponseExtension ( response . getClass ( ) , unmarshalledExtension ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" , e ) ; } } } protected static class RequestPrecursor < Invocation extends PortletInvocation > { private final static Logger log = LoggerFactory . getLogger ( RequestPrecursor . class ) ; private final PortletContext portletContext ; private final RuntimeContext runtimeContext ; private final MarkupParams markupParams ; private final RegistrationContext registrationContext ; private final UserContext userContext ; private static final String PORTLET_HANDLE = "<STR_LIT>" ; private static final String SECURITY_CONTEXT = "<STR_LIT>" ; private static final String USER_CONTEXT = "<STR_LIT>" ; private static final String INVOCATION_CONTEXT = "<STR_LIT>" ; private static final String CONTENT_TYPE = "<STR_LIT>" ; private static final String USER_AGENT = "<STR_LIT>" ; public RequestPrecursor ( WSRPConsumerSPI wsrpConsumer , Invocation invocation ) throws PortletInvokerException { portletContext = WSRPUtils . convertToWSRPPortletContext ( WSRPConsumerImpl . getPortletContext ( invocation ) ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( getPortletHandle ( ) , PORTLET_HANDLE , null ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "<STR_LIT>" + getPortletHandle ( ) ) ; } registrationContext = wsrpConsumer . getRegistrationContext ( ) ; SecurityContext securityContext = invocation . getSecurityContext ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( securityContext , SECURITY_CONTEXT ) ; String authType = WSRPUtils . convertRequestAuthTypeToWSRPAuthType ( securityContext . getAuthType ( ) ) ; String portletInstanceKey = WSRPTypeFactory . getPortletInstanceKey ( invocation . getInstanceContext ( ) ) ; String namespacePrefix = WSRPTypeFactory . getNamespacePrefix ( invocation . getWindowContext ( ) , getPortletHandle ( ) ) ; runtimeContext = WSRPTypeFactory . createRuntimeContext ( authType , portletInstanceKey , namespacePrefix ) ; WSRPPortletInfo info = wsrpConsumer . getPortletInfo ( invocation ) ; userContext = wsrpConsumer . getUserContextFrom ( info , invocation , runtimeContext ) ; wsrpConsumer . setTemplatesIfNeeded ( info , invocation , getRuntimeContext ( ) ) ; wsrpConsumer . getSessionHandler ( ) . setSessionIdIfNeeded ( invocation , getRuntimeContext ( ) , getPortletHandle ( ) ) ; org . gatein . pc . api . spi . UserContext userContext = invocation . getUserContext ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( userContext , USER_CONTEXT ) ; PortletInvocationContext context = invocation . getContext ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( context , INVOCATION_CONTEXT ) ; final MediaType contentType = context . getResponseContentType ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( contentType , CONTENT_TYPE ) ; String mode ; try { mode = WSRPUtils . getWSRPNameFromJSR168PortletMode ( invocation . getMode ( ) ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" ) ; mode = WSRPConstants . VIEW_MODE ; } String windowState ; try { windowState = WSRPUtils . getWSRPNameFromJSR168WindowState ( invocation . getWindowState ( ) ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" ) ; windowState = WSRPConstants . NORMAL_WINDOW_STATE ; } this . markupParams = WSRPTypeFactory . createMarkupParams ( securityContext . isSecure ( ) , WSRPUtils . convertLocalesToRFC3066LanguageTags ( userContext . getLocales ( ) ) , Collections . singletonList ( contentType . getValue ( ) ) , mode , windowState ) ; String userAgent = WSRPConsumerImpl . getHttpRequest ( invocation ) . getHeader ( USER_AGENT ) ; getMarkupParams ( ) . setClientData ( WSRPTypeFactory . createClientData ( userAgent ) ) ; getMarkupParams ( ) . getExtensions ( ) . addAll ( ExtensionAccess . getConsumerExtensionAccessor ( ) . getRequestExtensionsFor ( MarkupParams . class ) ) ; StateString navigationalState = invocation . getNavigationalState ( ) ; Map < String , String [ ] > publicNavigationalState = invocation . getPublicNavigationalState ( ) ; String publicNS = ( String ) invocation . getAttribute ( WSRP2RewritingConstants . NAVIGATIONAL_VALUES ) ; if ( ! ParameterValidation . isNullOrEmpty ( publicNS ) ) { publicNavigationalState . putAll ( WSRPUtils . decodePublicNS ( publicNS ) ) ; } NavigationalContext navigationalContext = WSRPTypeFactory . createNavigationalContextOrNull ( navigationalState , publicNavigationalState ) ; getMarkupParams ( ) . setNavigationalContext ( navigationalContext ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( WSRPUtils . toString ( getMarkupParams ( ) ) ) ; } } public String getPortletHandle ( ) { return portletContext . getPortletHandle ( ) ; } public PortletContext getPortletContext ( ) { return portletContext ; } public RegistrationContext getRegistrationContext ( ) { return registrationContext ; } public UserContext getUserContext ( ) { return userContext ; } public RuntimeContext getRuntimeContext ( ) { return runtimeContext ; } public MarkupParams getMarkupParams ( ) { return markupParams ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . invocation . EventInvocation ; import org . gatein . pc . api . invocation . response . ErrorResponse ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . pc . api . spi . InstanceContext ; import org . gatein . pc . api . state . AccessMode ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . api . extensions . ExtensionAccess ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . oasis . wsrp . v2 . Event ; import org . oasis . wsrp . v2 . EventParams ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . HandleEvents ; import org . oasis . wsrp . v2 . HandleEventsFailed ; import org . oasis . wsrp . v2 . HandleEventsResponse ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . UpdateResponse ; import javax . xml . namespace . QName ; import javax . xml . ws . Holder ; import java . io . Serializable ; import java . util . Collections ; import java . util . List ; public class EventHandler extends NavigationalStateUpdatingHandler < EventInvocation , HandleEvents , HandleEventsResponse > { public EventHandler ( WSRPConsumerImpl consumer ) { super ( consumer ) ; } @ Override protected RuntimeContext getRuntimeContextFrom ( HandleEvents request ) { return request . getRuntimeContext ( ) ; } @ Override protected HandleEventsResponse performRequest ( HandleEvents request ) throws Exception { if ( InvocationHandler . debug ) { InvocationHandler . log . debug ( "<STR_LIT>" + request . getPortletContext ( ) . getPortletHandle ( ) + "<STR_LIT:'>" ) ; } Holder < List < HandleEventsFailed > > failedEvents = new Holder < List < HandleEventsFailed > > ( ) ; Holder < UpdateResponse > updateResponse = new Holder < UpdateResponse > ( ) ; final Holder < List < Extension > > extensions = new Holder < List < Extension > > ( ) ; consumer . getMarkupService ( ) . handleEvents ( request . getRegistrationContext ( ) , request . getPortletContext ( ) , request . getRuntimeContext ( ) , request . getUserContext ( ) , request . getMarkupParams ( ) , request . getEventParams ( ) , updateResponse , failedEvents , extensions ) ; HandleEventsResponse response = WSRPTypeFactory . createHandleEventsReponse ( ) ; response . setUpdateResponse ( updateResponse . value ) ; if ( ParameterValidation . existsAndIsNotEmpty ( extensions . value ) ) { response . getExtensions ( ) . addAll ( extensions . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( failedEvents . value ) ) { response . getFailedEvents ( ) . addAll ( failedEvents . value ) ; } return response ; } @ Override protected HandleEvents prepareRequest ( RequestPrecursor < EventInvocation > requestPrecursor , EventInvocation invocation ) { PortletContext portletContext = requestPrecursor . getPortletContext ( ) ; if ( InvocationHandler . debug ) { InvocationHandler . log . debug ( "<STR_LIT>" + portletContext . getPortletHandle ( ) + "<STR_LIT:'>" ) ; } InstanceContext instanceContext = invocation . getInstanceContext ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( instanceContext , "<STR_LIT>" ) ; AccessMode accessMode = instanceContext . getAccessMode ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( accessMode , "<STR_LIT>" ) ; if ( InvocationHandler . debug ) { InvocationHandler . log . debug ( "<STR_LIT>" + accessMode + "<STR_LIT>" ) ; } QName name = invocation . getName ( ) ; Serializable payload = invocation . getPayload ( ) ; Event event = WSRPTypeFactory . createEvent ( name , payload ) ; EventParams eventParams = WSRPTypeFactory . createEventParams ( Collections . singletonList ( event ) , WSRPUtils . getStateChangeFromAccessMode ( accessMode ) ) ; eventParams . getExtensions ( ) . addAll ( ExtensionAccess . getConsumerExtensionAccessor ( ) . getRequestExtensionsFor ( EventParams . class ) ) ; return WSRPTypeFactory . createHandleEvents ( requestPrecursor . getRegistrationContext ( ) , portletContext , requestPrecursor . getRuntimeContext ( ) , requestPrecursor . getUserContext ( ) , requestPrecursor . getMarkupParams ( ) , eventParams ) ; } @ Override protected PortletInvocationResponse processResponse ( HandleEventsResponse response , EventInvocation invocation , RequestPrecursor < EventInvocation > requestPrecursor ) throws PortletInvokerException { List < HandleEventsFailed > failed = response . getFailedEvents ( ) ; if ( ParameterValidation . existsAndIsNotEmpty ( failed ) ) { return new ErrorResponse ( "<STR_LIT>" + failed ) ; } return processUpdateResponse ( invocation , requestPrecursor , response . getUpdateResponse ( ) , response ) ; } @ Override protected List < Extension > getExtensionsFrom ( HandleEventsResponse handleEventsResponse ) { return handleEventsResponse . getExtensions ( ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . invocation . RenderInvocation ; import org . gatein . pc . api . invocation . response . FragmentResponse ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . consumer . spi . WSRPConsumerSPI ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetMarkup ; import org . oasis . wsrp . v2 . MarkupContext ; import org . oasis . wsrp . v2 . MarkupResponse ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import javax . xml . ws . Holder ; import java . util . List ; public class RenderHandler extends MimeResponseHandler < RenderInvocation , GetMarkup , MarkupResponse , MarkupContext > { public RenderHandler ( WSRPConsumerSPI consumer ) { super ( consumer ) ; } @ Override protected SessionContext getSessionContextFrom ( MarkupResponse response ) { return response . getSessionContext ( ) ; } @ Override protected MarkupContext getMimeResponseFrom ( MarkupResponse markupResponse ) { return markupResponse . getMarkupContext ( ) ; } @ Override protected PortletInvocationResponse createContentResponse ( MarkupContext markupContext , RenderInvocation invocation , String mimeType , byte [ ] bytes , String markup , org . gatein . pc . api . cache . CacheControl cacheControl ) { if ( markup != null ) { return new FragmentResponse ( null , null , mimeType , null , markup , markupContext . getPreferredTitle ( ) , cacheControl , invocation . getPortalContext ( ) . getModes ( ) ) ; } else { return new FragmentResponse ( null , null , mimeType , null , bytes , markupContext . getPreferredTitle ( ) , cacheControl , invocation . getPortalContext ( ) . getModes ( ) ) ; } } protected GetMarkup prepareRequest ( RequestPrecursor < RenderInvocation > requestPrecursor , RenderInvocation invocation ) { PortletContext portletContext = requestPrecursor . getPortletContext ( ) ; if ( debug ) { log . debug ( "<STR_LIT>" + portletContext . getPortletHandle ( ) + "<STR_LIT:'>" ) ; } return WSRPTypeFactory . createGetMarkup ( requestPrecursor . getRegistrationContext ( ) , portletContext , requestPrecursor . getRuntimeContext ( ) , requestPrecursor . getUserContext ( ) , requestPrecursor . getMarkupParams ( ) ) ; } @ Override protected List < Extension > getExtensionsFrom ( MarkupResponse markupResponse ) { return markupResponse . getExtensions ( ) ; } protected RuntimeContext getRuntimeContextFrom ( GetMarkup request ) { return request . getRuntimeContext ( ) ; } protected MarkupResponse performRequest ( GetMarkup request ) throws Exception { if ( debug ) { log . debug ( "<STR_LIT>" + request . getPortletContext ( ) . getPortletHandle ( ) + "<STR_LIT:'>" ) ; } Holder < SessionContext > sessionContextHolder = new Holder < SessionContext > ( ) ; Holder < MarkupContext > markupContextHolder = new Holder < MarkupContext > ( ) ; final Holder < List < Extension > > extensions = new Holder < List < Extension > > ( ) ; consumer . getMarkupService ( ) . getMarkup ( request . getRegistrationContext ( ) , request . getPortletContext ( ) , request . getRuntimeContext ( ) , request . getUserContext ( ) , request . getMarkupParams ( ) , markupContextHolder , sessionContextHolder , extensions ) ; MarkupResponse markupResponse = WSRPTypeFactory . createMarkupResponse ( markupContextHolder . value ) ; markupResponse . setSessionContext ( sessionContextHolder . value ) ; if ( ParameterValidation . existsAndIsNotEmpty ( extensions . value ) ) { markupResponse . getExtensions ( ) . addAll ( extensions . value ) ; } return markupResponse ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . StateString ; import org . gatein . pc . api . invocation . ResourceInvocation ; import org . gatein . pc . api . spi . InstanceContext ; import org . gatein . pc . api . state . AccessMode ; import org . gatein . wsrp . WSRPRewritingConstants ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . api . extensions . ExtensionAccess ; import org . gatein . wsrp . consumer . spi . WSRPConsumerSPI ; import org . gatein . wsrp . spec . v2 . WSRP2RewritingConstants ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetResource ; import org . oasis . wsrp . v2 . MarkupParams ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . ResourceContext ; import org . oasis . wsrp . v2 . ResourceParams ; import org . oasis . wsrp . v2 . ResourceResponse ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import javax . xml . ws . Holder ; import java . util . List ; import java . util . Map ; public class ResourceHandler extends MimeResponseHandler < ResourceInvocation , GetResource , ResourceResponse , ResourceContext > { public ResourceHandler ( WSRPConsumerSPI consumer ) { super ( consumer ) ; } @ Override protected SessionContext getSessionContextFrom ( ResourceResponse resourceResponse ) { return resourceResponse . getSessionContext ( ) ; } @ Override protected ResourceContext getMimeResponseFrom ( ResourceResponse resourceResponse ) { return resourceResponse . getResourceContext ( ) ; } @ Override protected RuntimeContext getRuntimeContextFrom ( GetResource request ) { return request . getRuntimeContext ( ) ; } @ Override protected GetResource prepareRequest ( RequestPrecursor < ResourceInvocation > requestPrecursor , ResourceInvocation invocation ) { String resourceId = ( String ) invocation . getAttribute ( WSRP2RewritingConstants . RESOURCE_ID ) ; if ( resourceId == null || ! consumer . isUsingWSRP2 ( ) ) { resourceId = ( String ) invocation . getAttribute ( WSRPRewritingConstants . RESOURCE_URL ) ; } PortletContext portletContext = requestPrecursor . getPortletContext ( ) ; MarkupParams params = requestPrecursor . getMarkupParams ( ) ; InstanceContext instanceContext = invocation . getInstanceContext ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( instanceContext , "<STR_LIT>" ) ; AccessMode accessMode = instanceContext . getAccessMode ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( accessMode , "<STR_LIT>" ) ; if ( debug ) { log . debug ( "<STR_LIT>" + accessMode + "<STR_LIT>" ) ; } if ( ParameterValidation . isNullOrEmpty ( resourceId ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } ResourceParams resourceParams = WSRPTypeFactory . createResourceParams ( params . isSecureClientCommunication ( ) , params . getLocales ( ) , params . getMimeTypes ( ) , params . getMode ( ) , params . getWindowState ( ) , resourceId , WSRPUtils . getStateChangeFromAccessMode ( accessMode ) ) ; resourceParams . setNavigationalContext ( params . getNavigationalContext ( ) ) ; resourceParams . setClientData ( params . getClientData ( ) ) ; resourceParams . setResourceCacheability ( WSRPUtils . getResourceCacheabilityFromCacheLevel ( invocation . getCacheLevel ( ) ) ) ; resourceParams . getExtensions ( ) . addAll ( ExtensionAccess . getConsumerExtensionAccessor ( ) . getRequestExtensionsFor ( ResourceParams . class ) ) ; for ( Map . Entry < String , String [ ] > entry : invocation . getForm ( ) . entrySet ( ) ) { String name = entry . getKey ( ) ; for ( String value : entry . getValue ( ) ) { resourceParams . getFormParameters ( ) . add ( WSRPTypeFactory . createNamedString ( name , value ) ) ; } } StateString resourceState = invocation . getResourceState ( ) ; if ( resourceState != null ) { String state = resourceState . getStringValue ( ) ; if ( ! StateString . JBPNS_PREFIX . equals ( state ) ) { resourceParams . setResourceState ( state ) ; } } return WSRPTypeFactory . createGetResource ( requestPrecursor . getRegistrationContext ( ) , portletContext , requestPrecursor . getRuntimeContext ( ) , requestPrecursor . getUserContext ( ) , resourceParams ) ; } @ Override protected List < Extension > getExtensionsFrom ( ResourceResponse resourceResponse ) { return resourceResponse . getExtensions ( ) ; } @ Override protected ResourceResponse performRequest ( GetResource request ) throws Exception { Holder < SessionContext > sessionContextHolder = new Holder < SessionContext > ( ) ; Holder < ResourceContext > resourceContextHolder = new Holder < ResourceContext > ( ) ; Holder < PortletContext > portletContextHolder = new Holder < PortletContext > ( request . getPortletContext ( ) ) ; final Holder < List < Extension > > extensions = new Holder < List < Extension > > ( ) ; consumer . getMarkupService ( ) . getResource ( request . getRegistrationContext ( ) , portletContextHolder , request . getRuntimeContext ( ) , request . getUserContext ( ) , request . getResourceParams ( ) , resourceContextHolder , sessionContextHolder , extensions ) ; ResourceResponse resourceResponse = WSRPTypeFactory . createResourceResponse ( resourceContextHolder . value ) ; resourceResponse . setPortletContext ( portletContextHolder . value ) ; resourceResponse . setSessionContext ( sessionContextHolder . value ) ; if ( ParameterValidation . existsAndIsNotEmpty ( extensions . value ) ) { resourceResponse . getExtensions ( ) . addAll ( extensions . value ) ; } return resourceResponse ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers . session ; import org . gatein . wsrp . consumer . handlers . ProducerSessionInformation ; import java . util . Set ; public interface SessionRegistry { Set < ProducerSessionInformation > getAll ( ) ; ProducerSessionInformation get ( String sessionId ) ; ProducerSessionInformation remove ( String sessionId ) ; void put ( String sessionId , ProducerSessionInformation sessionInformation ) ; } </s>
|
<s> package org . gatein . wsrp . consumer . handlers . session ; import org . gatein . wsrp . consumer . handlers . ProducerSessionInformation ; import java . util . HashSet ; import java . util . Map ; import java . util . Set ; import java . util . concurrent . ConcurrentHashMap ; public class InMemorySessionRegistry implements SessionRegistry { private Map < String , ProducerSessionInformation > sessionInfos = new ConcurrentHashMap < String , ProducerSessionInformation > ( ) ; public Set < ProducerSessionInformation > getAll ( ) { return new HashSet < ProducerSessionInformation > ( sessionInfos . values ( ) ) ; } public ProducerSessionInformation get ( String sessionId ) { return sessionInfos . get ( sessionId ) ; } public ProducerSessionInformation remove ( String sessionId ) { return sessionInfos . remove ( sessionId ) ; } public void put ( String sessionId , ProducerSessionInformation sessionInformation ) { sessionInfos . put ( sessionId , sessionInformation ) ; } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . apache . commons . fileupload . FileItemIterator ; import org . apache . commons . fileupload . FileItemStream ; import org . apache . commons . fileupload . FileUpload ; import org . apache . commons . fileupload . util . Streams ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . StateString ; import org . gatein . pc . api . invocation . ActionInvocation ; import org . gatein . pc . api . invocation . response . ErrorResponse ; import org . gatein . pc . api . invocation . response . HTTPRedirectionResponse ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . pc . api . spi . InstanceContext ; import org . gatein . pc . api . spi . RequestContext ; import org . gatein . pc . api . state . AccessMode ; import org . gatein . wsrp . WSRPTypeFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . api . extensions . ExtensionAccess ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . oasis . wsrp . v2 . BlockingInteractionResponse ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . InteractionParams ; import org . oasis . wsrp . v2 . NamedString ; import org . oasis . wsrp . v2 . PerformBlockingInteraction ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . UpdateResponse ; import org . oasis . wsrp . v2 . UploadContext ; import javax . xml . ws . Holder ; import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . ByteArrayOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . util . ArrayList ; import java . util . List ; import java . util . Map ; public class ActionHandler extends NavigationalStateUpdatingHandler < ActionInvocation , PerformBlockingInteraction , BlockingInteractionResponse > { public ActionHandler ( WSRPConsumerImpl consumer ) { super ( consumer ) ; } @ Override protected RuntimeContext getRuntimeContextFrom ( PerformBlockingInteraction performBlockingInteraction ) { return performBlockingInteraction . getRuntimeContext ( ) ; } @ Override protected BlockingInteractionResponse performRequest ( PerformBlockingInteraction interaction ) throws Exception { Holder < UpdateResponse > updateResponseHolder = new Holder < UpdateResponse > ( ) ; Holder < String > redirectURL = new Holder < String > ( ) ; if ( debug ) { log . debug ( "<STR_LIT>" + interaction . getPortletContext ( ) . getPortletHandle ( ) + "<STR_LIT:'>" ) ; } final Holder < List < Extension > > extensions = new Holder < List < Extension > > ( ) ; consumer . getMarkupService ( ) . performBlockingInteraction ( interaction . getRegistrationContext ( ) , interaction . getPortletContext ( ) , interaction . getRuntimeContext ( ) , interaction . getUserContext ( ) , interaction . getMarkupParams ( ) , interaction . getInteractionParams ( ) , updateResponseHolder , redirectURL , extensions ) ; final BlockingInteractionResponse response ; if ( redirectURL . value != null ) { response = WSRPTypeFactory . createBlockingInteractionResponse ( redirectURL . value ) ; } else { response = WSRPTypeFactory . createBlockingInteractionResponse ( updateResponseHolder . value ) ; } if ( ParameterValidation . existsAndIsNotEmpty ( extensions . value ) ) { response . getExtensions ( ) . addAll ( extensions . value ) ; } return response ; } protected PerformBlockingInteraction prepareRequest ( RequestPrecursor < ActionInvocation > requestPrecursor , ActionInvocation invocation ) { if ( ! ( invocation instanceof ActionInvocation ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } ActionInvocation actionInvocation = ( ActionInvocation ) invocation ; PortletContext portletContext = requestPrecursor . getPortletContext ( ) ; if ( debug ) { log . debug ( "<STR_LIT>" + portletContext . getPortletHandle ( ) + "<STR_LIT:'>" ) ; } InstanceContext instanceContext = invocation . getInstanceContext ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( instanceContext , "<STR_LIT>" ) ; AccessMode accessMode = instanceContext . getAccessMode ( ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( accessMode , "<STR_LIT>" ) ; if ( debug ) { log . debug ( "<STR_LIT>" + accessMode + "<STR_LIT>" ) ; } InteractionParams interactionParams = WSRPTypeFactory . createInteractionParams ( WSRPUtils . getStateChangeFromAccessMode ( accessMode ) ) ; interactionParams . getExtensions ( ) . addAll ( ExtensionAccess . getConsumerExtensionAccessor ( ) . getRequestExtensionsFor ( InteractionParams . class ) ) ; StateString interactionState = actionInvocation . getInteractionState ( ) ; if ( interactionState != null ) { String state = interactionState . getStringValue ( ) ; if ( ! StateString . JBPNS_PREFIX . equals ( state ) ) { interactionParams . setInteractionState ( state ) ; } } RequestContextWrapper requestContext = new RequestContextWrapper ( actionInvocation . getRequestContext ( ) ) ; try { if ( FileUpload . isMultipartContent ( requestContext ) ) { FileUpload upload = new FileUpload ( ) ; FileItemIterator iter = upload . getItemIterator ( requestContext ) ; List < UploadContext > uploadContexts = new ArrayList < UploadContext > ( <NUM_LIT:7> ) ; List < NamedString > formParameters = new ArrayList < NamedString > ( <NUM_LIT:7> ) ; while ( iter . hasNext ( ) ) { FileItemStream item = iter . next ( ) ; InputStream stream = item . openStream ( ) ; if ( ! item . isFormField ( ) ) { String contentType = item . getContentType ( ) ; if ( debug ) { log . debug ( "<STR_LIT>" + item . getFieldName ( ) + "<STR_LIT>" + item . getName ( ) + "<STR_LIT>" + contentType + "<STR_LIT>" ) ; } BufferedInputStream bufIn = new BufferedInputStream ( stream ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; BufferedOutputStream bos = new BufferedOutputStream ( baos ) ; int c = bufIn . read ( ) ; while ( c != - <NUM_LIT:1> ) { bos . write ( c ) ; c = bufIn . read ( ) ; } bos . flush ( ) ; baos . flush ( ) ; bufIn . close ( ) ; bos . close ( ) ; UploadContext uploadContext = WSRPTypeFactory . createUploadContext ( contentType , baos . toByteArray ( ) ) ; List < NamedString > mimeAttributes = new ArrayList < NamedString > ( <NUM_LIT:2> ) ; String value = FileUpload . FORM_DATA + "<STR_LIT:;>" + "<STR_LIT>" + item . getFieldName ( ) + "<STR_LIT>" + "<STR_LIT>" + item . getName ( ) + "<STR_LIT:\">" ; NamedString mimeAttribute = WSRPTypeFactory . createNamedString ( FileUpload . CONTENT_DISPOSITION , value ) ; mimeAttributes . add ( mimeAttribute ) ; mimeAttribute = WSRPTypeFactory . createNamedString ( FileUpload . CONTENT_TYPE , item . getContentType ( ) ) ; mimeAttributes . add ( mimeAttribute ) ; uploadContext . getMimeAttributes ( ) . addAll ( mimeAttributes ) ; uploadContexts . add ( uploadContext ) ; } else { NamedString formParameter = WSRPTypeFactory . createNamedString ( item . getFieldName ( ) , Streams . asString ( stream ) ) ; formParameters . add ( formParameter ) ; } } interactionParams . getUploadContexts ( ) . addAll ( uploadContexts ) ; interactionParams . getFormParameters ( ) . addAll ( formParameters ) ; } else { Map < String , String [ ] > params = actionInvocation . getForm ( ) ; if ( params != null && ! params . isEmpty ( ) ) { int capacity = params . size ( ) ; List < NamedString > formParameters = new ArrayList < NamedString > ( capacity ) ; for ( Map . Entry param : params . entrySet ( ) ) { String name = ( String ) param . getKey ( ) ; String [ ] values = ( String [ ] ) param . getValue ( ) ; NamedString formParameter ; for ( String value : values ) { formParameter = WSRPTypeFactory . createNamedString ( name , value ) ; formParameters . add ( formParameter ) ; } } interactionParams . getFormParameters ( ) . addAll ( formParameters ) ; } } } catch ( Exception e ) { log . debug ( "<STR_LIT>" , e ) ; } if ( trace ) { log . trace ( WSRPUtils . toString ( interactionParams ) ) ; } return WSRPTypeFactory . createPerformBlockingInteraction ( requestPrecursor . getRegistrationContext ( ) , portletContext , requestPrecursor . getRuntimeContext ( ) , requestPrecursor . getUserContext ( ) , requestPrecursor . getMarkupParams ( ) , interactionParams ) ; } protected PortletInvocationResponse processResponse ( BlockingInteractionResponse response , ActionInvocation invocation , RequestPrecursor < ActionInvocation > requestPrecursor ) throws PortletInvokerException { String redirectURL = response . getRedirectURL ( ) ; UpdateResponse updateResponse = response . getUpdateResponse ( ) ; if ( redirectURL != null && updateResponse != null ) { return new ErrorResponse ( new IllegalArgumentException ( "<STR_LIT>" ) ) ; } if ( redirectURL == null && updateResponse == null ) { return new ErrorResponse ( new IllegalArgumentException ( "<STR_LIT>" ) ) ; } if ( redirectURL != null ) { return new HTTPRedirectionResponse ( redirectURL ) ; } else { return processUpdateResponse ( invocation , requestPrecursor , updateResponse , response ) ; } } @ Override protected List < Extension > getExtensionsFrom ( BlockingInteractionResponse blockingInteractionResponse ) { return blockingInteractionResponse . getExtensions ( ) ; } public static class RequestContextWrapper implements org . apache . commons . fileupload . RequestContext { private RequestContext requestContext ; public RequestContextWrapper ( RequestContext requestContext ) { this . requestContext = requestContext ; } public String getCharacterEncoding ( ) { return requestContext . getCharacterEncoding ( ) ; } public String getContentType ( ) { return requestContext . getContentType ( ) ; } public int getContentLength ( ) { return requestContext . getContentLength ( ) ; } public InputStream getInputStream ( ) throws IOException { return requestContext . getInputStream ( ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . apache . commons . httpclient . Cookie ; import org . gatein . common . util . ParameterValidation ; import org . gatein . common . util . Tools ; import org . gatein . wsrp . WSRPConstants ; import org . oasis . wsrp . v2 . SessionContext ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import java . io . Serializable ; import java . util . ArrayList ; import java . util . Collection ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class ProducerSessionInformation implements Serializable { private static Logger log = LoggerFactory . getLogger ( ProducerSessionInformation . class ) ; private boolean initCookieDone = false ; private boolean perGroupCookies = false ; private Map < String , Cookie [ ] > groupCookies ; private Map < String , SessionInfo > portletSessions ; private Map < String , String > sessionId2PortletHandle ; private Cookie [ ] userCookie ; private transient SessionHandler parent ; private String parentSessionId ; public String getParentSessionId ( ) { return parentSessionId ; } public void setParentSessionId ( String parentSessionId ) { boolean error = false ; if ( parentSessionId != null ) { parentSessionId = SessionHandler . getRealId ( parentSessionId ) ; if ( this . parentSessionId != null && ! parentSessionId . equals ( this . parentSessionId ) ) { error = true ; } } else { if ( this . parentSessionId != null ) { error = true ; } } if ( error ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } this . parentSessionId = parentSessionId ; } public String getUserCookie ( ) { if ( userCookie == null ) { return null ; } userCookie = purgeExpiredCookies ( userCookie ) ; if ( userCookie . length == <NUM_LIT:0> ) { setInitCookieDone ( false ) ; } return outputToExternalForm ( userCookie ) ; } public void setUserCookie ( Cookie [ ] userCookie ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( userCookie , "<STR_LIT>" ) ; this . userCookie = userCookie ; } public boolean isInitCookieDone ( ) { return initCookieDone ; } public void setInitCookieDone ( boolean initCookieDone ) { this . initCookieDone = initCookieDone ; } public boolean isPerGroupCookies ( ) { return perGroupCookies ; } public void setPerGroupCookies ( boolean perGroupCookies ) { this . perGroupCookies = perGroupCookies ; } public void setGroupCookieFor ( String groupId , Cookie [ ] cookies ) { if ( ! isPerGroupCookies ( ) ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } if ( groupId == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( cookies , "<STR_LIT>" ) ; if ( groupCookies == null ) { groupCookies = new HashMap < String , Cookie [ ] > ( ) ; } if ( groupCookies . containsKey ( groupId ) ) { log . debug ( "<STR_LIT>" + groupId ) ; } groupCookies . put ( groupId , cookies ) ; } public String getGroupCookieFor ( String groupId ) { if ( groupCookies == null ) { return null ; } Cookie [ ] cookies = groupCookies . get ( groupId ) ; if ( cookies != null ) { cookies = purgeExpiredCookies ( cookies ) ; if ( cookies . length == <NUM_LIT:0> ) { setInitCookieDone ( false ) ; } groupCookies . put ( groupId , cookies ) ; return outputToExternalForm ( cookies ) ; } else { return null ; } } public void clearGroupCookies ( ) { groupCookies = null ; } public void addSessionForPortlet ( String portletHandle , SessionContext sessionContext ) { SessionInfo info = new SessionInfo ( sessionContext , portletHandle ) ; if ( portletSessions == null ) { portletSessions = new HashMap < String , SessionInfo > ( ) ; sessionId2PortletHandle = new HashMap < String , String > ( ) ; } portletSessions . put ( portletHandle , info ) ; sessionId2PortletHandle . put ( sessionContext . getSessionID ( ) , portletHandle ) ; if ( parent != null ) { parent . addSessionMapping ( sessionContext . getSessionID ( ) , this ) ; } } public String getSessionIdForPortlet ( String portletHandle ) { ProducerSessionInformation . SessionIdResult idResult = internalGetSessionIdForPortlet ( portletHandle ) ; if ( idResult . expired ) { return null ; } return idResult . id ; } public int getNumberOfSessions ( ) { if ( portletSessions != null ) { return portletSessions . size ( ) ; } else { return <NUM_LIT:0> ; } } public String removeSession ( String sessionId ) { ParameterValidation . throwIllegalArgExceptionIfNull ( sessionId , "<STR_LIT>" ) ; String portletHandle = sessionId2PortletHandle . get ( sessionId ) ; if ( portletHandle == null ) { throw new IllegalArgumentException ( "<STR_LIT>" + sessionId + "<STR_LIT:'>" ) ; } return removeSessionForPortlet ( portletHandle ) ; } public List < String > removeSessions ( ) { List < String > idsToRelease = new ArrayList < String > ( getNumberOfSessions ( ) ) ; List < String > handlesCopy = new ArrayList < String > ( portletSessions . keySet ( ) ) ; for ( String handle : handlesCopy ) { SessionIdResult result = removeSessionIdForPortlet ( handle ) ; if ( ! result . expired ) { idsToRelease . add ( result . id ) ; } } return idsToRelease ; } public String removeSessionForPortlet ( String portletHandle ) { SessionIdResult result = removeSessionIdForPortlet ( portletHandle ) ; return result . expired ? null : result . id ; } private SessionIdResult removeSessionIdForPortlet ( String portletHandle ) { ProducerSessionInformation . SessionIdResult result = internalGetSessionIdForPortlet ( portletHandle ) ; final String id = result . id ; if ( id == null ) { throw new IllegalArgumentException ( "<STR_LIT>" + portletHandle + "<STR_LIT:'>" ) ; } if ( ! result . expired ) { portletSessions . remove ( portletHandle ) ; sessionId2PortletHandle . remove ( id ) ; if ( parent != null ) { parent . removeSessionId ( id ) ; } } return result ; } public void replaceUserCookiesWith ( ProducerSessionInformation currentSessionInfo ) { if ( currentSessionInfo != null && currentSessionInfo . userCookie != null && currentSessionInfo . userCookie . length > <NUM_LIT:0> ) { this . userCookie = currentSessionInfo . userCookie ; } } private String outputToExternalForm ( Cookie [ ] cookies ) { if ( cookies != null && cookies . length != <NUM_LIT:0> ) { int cookieNumber = cookies . length ; StringBuffer sb = new StringBuffer ( <NUM_LIT> * cookieNumber ) ; for ( int i = <NUM_LIT:0> ; i < cookieNumber ; i ++ ) { sb . append ( cookies [ i ] . toExternalForm ( ) ) ; if ( i != cookieNumber - <NUM_LIT:1> ) { sb . append ( "<STR_LIT:U+002C>" ) ; } } return sb . toString ( ) ; } return null ; } private Cookie [ ] purgeExpiredCookies ( Cookie [ ] cookies ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( cookies , "<STR_LIT>" ) ; List < Cookie > cleanCookies = Tools . toList ( cookies ) ; for ( Cookie cookie : cookies ) { if ( cookie . isExpired ( ) ) { cleanCookies . remove ( cookie ) ; } } return cleanCookies . toArray ( new Cookie [ cleanCookies . size ( ) ] ) ; } private SessionIdResult internalGetSessionIdForPortlet ( String portletHandle ) { SessionInfo session = getSessionInfoFor ( portletHandle ) ; if ( session != null ) { String id = session . getSessionId ( ) ; if ( ! session . isStillValid ( ) ) { portletSessions . remove ( session . getPortletHandle ( ) ) ; sessionId2PortletHandle . remove ( session . getSessionId ( ) ) ; if ( parent != null ) { parent . removeSessionId ( session . getSessionId ( ) ) ; } return new SessionIdResult ( id , true ) ; } else { return new SessionIdResult ( id , false ) ; } } return new SessionIdResult ( null , false ) ; } private SessionInfo getSessionInfoFor ( String portletHandle ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( portletHandle , "<STR_LIT>" , null ) ; if ( portletSessions == null ) { return null ; } return portletSessions . get ( portletHandle ) ; } Collection < String > getSessionIds ( ) { return sessionId2PortletHandle . keySet ( ) ; } void setParent ( SessionHandler sessionHandler ) { parent = sessionHandler ; } public void updateHandleAssociatedInfo ( String originalHandle , String newHandle ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( originalHandle , "<STR_LIT>" , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( newHandle , "<STR_LIT>" , "<STR_LIT>" ) ; String sessionId = getSessionIdForPortlet ( originalHandle ) ; ProducerSessionInformation . SessionInfo info = getSessionInfoFor ( originalHandle ) ; if ( sessionId != null && info != null ) { portletSessions . put ( newHandle , info ) ; portletSessions . remove ( originalHandle ) ; sessionId2PortletHandle . put ( sessionId , newHandle ) ; log . debug ( "<STR_LIT>" + originalHandle + "<STR_LIT>" + newHandle + "<STR_LIT>" ) ; } } private class SessionInfo implements Serializable { private SessionContext sessionContext ; private long lastInvocationTime ; private String portletHandle ; public SessionInfo ( SessionContext sessionContext , String portletHandle ) { ParameterValidation . throwIllegalArgExceptionIfNull ( sessionContext , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( sessionContext . getSessionID ( ) , "<STR_LIT>" , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( portletHandle , "<STR_LIT>" , "<STR_LIT>" ) ; this . sessionContext = sessionContext ; this . portletHandle = portletHandle ; lastInvocationTime = System . currentTimeMillis ( ) ; } private boolean isStillValid ( ) { int expires = sessionContext . getExpires ( ) ; if ( expires == WSRPConstants . SESSION_NEVER_EXPIRES ) { return true ; } long now = System . currentTimeMillis ( ) ; long secondsSinceLastInvocation = ( now - lastInvocationTime ) / <NUM_LIT:1000> ; lastInvocationTime = now ; long diff = expires - secondsSinceLastInvocation ; log . debug ( "<STR_LIT>" + sessionContext . getSessionID ( ) + "<STR_LIT>" + ( ( diff > <NUM_LIT:0> ) ? "<STR_LIT>" : "<STR_LIT>" ) + "<STR_LIT>" + diff + "<STR_LIT:)>" ) ; return diff > <NUM_LIT:0> ; } private String getSessionId ( ) { return sessionContext . getSessionID ( ) ; } private String getPortletHandle ( ) { return portletHandle ; } } private class SessionIdResult { private String id ; private boolean expired ; public SessionIdResult ( String id , boolean expired ) { this . id = id ; this . expired = expired ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . handlers ; import org . gatein . common . util . ParameterValidation ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . invocation . ActionInvocation ; import org . gatein . pc . api . invocation . EventInvocation ; import org . gatein . pc . api . invocation . InvocationException ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . pc . api . invocation . RenderInvocation ; import org . gatein . pc . api . invocation . ResourceInvocation ; import org . gatein . pc . api . invocation . response . ErrorResponse ; import org . gatein . pc . api . invocation . response . PortletInvocationResponse ; import org . gatein . wsrp . WSRPResourceURL ; import org . gatein . wsrp . WSRPRewritingConstants ; import org . gatein . wsrp . api . extensions . ExtensionAccess ; import org . gatein . wsrp . api . extensions . InvocationHandlerDelegate ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . WSRPConsumerImpl ; import org . gatein . wsrp . spec . v2 . WSRP2Constants ; import org . gatein . wsrp . spec . v2 . WSRP2RewritingConstants ; import java . util . Map ; public class InvocationDispatcher { private final ActionHandler actionHandler ; private final RenderHandler renderHandler ; private final ResourceHandler resourceHandler ; private final EventHandler eventHandler ; private final WSRPConsumerImpl consumer ; private final DirectResourceServingHandler directResourceHandler ; public InvocationDispatcher ( WSRPConsumerImpl consumer ) { this . consumer = consumer ; actionHandler = new ActionHandler ( consumer ) ; renderHandler = new RenderHandler ( consumer ) ; resourceHandler = new ResourceHandler ( consumer ) ; eventHandler = new EventHandler ( consumer ) ; directResourceHandler = new DirectResourceServingHandler ( consumer ) ; } public PortletInvocationResponse dispatchAndHandle ( PortletInvocation invocation ) throws PortletInvokerException { InvocationHandler handler ; if ( invocation instanceof RenderInvocation ) { handler = renderHandler ; } else if ( invocation instanceof ActionInvocation ) { handler = actionHandler ; } else if ( invocation instanceof ResourceInvocation ) { ResourceInvocation resourceInvocation = ( ResourceInvocation ) invocation ; String resourceInvocationId = resourceInvocation . getResourceId ( ) ; String resourceId ; String resourceURL ; String preferOperationAsString ; if ( ! ParameterValidation . isNullOrEmpty ( resourceInvocationId ) ) { Map < String , String > resourceMap = WSRPResourceURL . decodeResource ( resourceInvocationId ) ; resourceId = resourceMap . get ( WSRP2RewritingConstants . RESOURCE_ID ) ; resourceURL = resourceMap . get ( WSRPRewritingConstants . RESOURCE_URL ) ; preferOperationAsString = resourceMap . get ( WSRP2RewritingConstants . RESOURCE_PREFER_OPERATION ) ; resourceInvocation . setAttribute ( WSRPRewritingConstants . RESOURCE_URL , resourceURL ) ; resourceInvocation . setAttribute ( WSRP2RewritingConstants . RESOURCE_ID , resourceId ) ; resourceInvocation . setAttribute ( WSRP2RewritingConstants . RESOURCE_PREFER_OPERATION , preferOperationAsString ) ; } else { resourceId = null ; resourceURL = ( String ) resourceInvocation . getAttribute ( WSRPRewritingConstants . RESOURCE_URL ) ; preferOperationAsString = ( String ) resourceInvocation . getAttribute ( WSRP2RewritingConstants . RESOURCE_PREFER_OPERATION ) ; } boolean preferOperation = ( preferOperationAsString != null && Boolean . parseBoolean ( preferOperationAsString ) ) ; if ( consumer . isUsingWSRP2 ( ) && ( preferOperation || resourceURL == null || ( resourceId != null && resourceId . length ( ) > <NUM_LIT:0> ) ) ) { handler = resourceHandler ; } else if ( resourceURL != null ) { handler = directResourceHandler ; } else { if ( consumer . isUsingWSRP2 ( ) ) { return new ErrorResponse ( "<STR_LIT>" ) ; } else { return new ErrorResponse ( "<STR_LIT>" ) ; } } } else if ( invocation instanceof EventInvocation ) { final ProducerInfo producerInfo = consumer . getProducerInfo ( ) ; if ( producerInfo . getSupportedOptions ( ) . contains ( WSRP2Constants . OPTIONS_EVENTS ) ) { handler = eventHandler ; } else { return new ErrorResponse ( "<STR_LIT>" + producerInfo . getId ( ) + "<STR_LIT>" ) ; } } else { throw new InvocationException ( "<STR_LIT>" + invocation ) ; } final InvocationHandlerDelegate delegate = InvocationHandlerDelegate . consumerDelegate ( ) ; if ( delegate != null ) { delegate . processInvocation ( invocation ) ; } try { final PortletInvocationResponse response = handler . handle ( invocation ) ; if ( delegate != null ) { delegate . processInvocationResponse ( response , invocation ) ; } return response ; } finally { ExtensionAccess . getConsumerExtensionAccessor ( ) . clear ( ) ; } } } </s>
|
<s> package org . gatein . wsrp . consumer . spi ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . handlers . SessionHandler ; import org . gatein . wsrp . consumer . handlers . session . SessionRegistry ; import org . gatein . wsrp . consumer . portlet . info . WSRPPortletInfo ; import org . gatein . wsrp . services . MarkupService ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . UserContext ; public interface WSRPConsumerSPI extends WSRPConsumer { RegistrationContext getRegistrationContext ( ) throws PortletInvokerException ; UserContext getUserContextFrom ( WSRPPortletInfo info , PortletInvocation invocation , RuntimeContext runtimeContext ) throws PortletInvokerException ; SessionHandler getSessionHandler ( ) ; void setTemplatesIfNeeded ( WSRPPortletInfo info , PortletInvocation invocation , RuntimeContext runtimeContext ) throws PortletInvokerException ; void refreshProducerInfo ( ) throws PortletInvokerException ; void handleInvalidRegistrationFault ( ) throws PortletInvokerException ; ProducerInfo getProducerInfo ( ) ; MarkupService getMarkupService ( ) throws PortletInvokerException ; boolean supportsUserScope ( String userScope ) ; WSRPPortletInfo getPortletInfo ( PortletInvocation invocation ) throws PortletInvokerException ; SessionRegistry getSessionRegistry ( ) ; } </s>
|
<s> package org . gatein . wsrp . consumer . spi ; import org . gatein . pc . federation . FederatingPortletInvoker ; import org . gatein . wsrp . WSRPConsumer ; import org . gatein . wsrp . api . session . SessionEventBroadcaster ; import org . gatein . wsrp . consumer . ConsumerException ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . handlers . session . SessionRegistry ; import org . gatein . wsrp . consumer . migration . MigrationService ; import org . gatein . wsrp . consumer . registry . ConsumerRegistry ; import java . util . Iterator ; public interface ConsumerRegistrySPI extends ConsumerRegistry { void setSessionEventBroadcaster ( SessionEventBroadcaster sessionEventBroadcaster ) ; void setFederatingPortletInvoker ( FederatingPortletInvoker federatingPortletInvoker ) ; MigrationService getMigrationService ( ) ; void setMigrationService ( MigrationService migrationService ) ; SessionRegistry getSessionRegistry ( ) ; void setSessionRegistry ( SessionRegistry sessionRegistry ) ; void start ( ) throws Exception ; void stop ( ) throws Exception ; void save ( ProducerInfo info , String messageOnError ) throws ConsumerException ; void delete ( ProducerInfo info ) throws ConsumerException ; String update ( ProducerInfo producerInfo ) ; Iterator < ProducerInfo > getProducerInfosFromStorage ( ) ; ProducerInfo loadProducerInfo ( String id ) ; WSRPConsumer createConsumerFrom ( ProducerInfo producerInfo , boolean putInCache ) ; void registerWithFederatingPortletInvoker ( WSRPConsumer consumer ) ; void deregisterWithFederatingPortletInvoker ( WSRPConsumer consumer ) ; long getPersistedLastModifiedForProducerInfoWith ( String id ) ; } </s>
|
<s> package org . gatein . wsrp . consumer ; import org . gatein . common . util . ParameterValidation ; import org . gatein . wsrp . registration . RegistrationPropertyDescription ; import javax . xml . namespace . QName ; import java . io . Serializable ; import static org . gatein . wsrp . consumer . RegistrationProperty . Status . * ; public class RegistrationProperty implements Comparable < RegistrationProperty > , Serializable { private String persistentId ; private RegistrationPropertyDescription persistentDescription ; private String persistentLang ; private QName persistentName ; private String persistentValue ; private Status status ; private transient PropertyChangeListener listener ; public int compareTo ( RegistrationProperty o ) { return persistentName . toString ( ) . compareTo ( o . persistentName . toString ( ) ) ; } public enum Status { INEXISTENT ( "<STR_LIT>" ) , MISSING ( "<STR_LIT>" ) , MISSING_VALUE ( "<STR_LIT>" ) , UNCHECKED_VALUE ( "<STR_LIT>" ) , INVALID_VALUE ( "<STR_LIT>" ) , VALID ( "<STR_LIT>" ) ; Status ( String localizationKey ) { this . localizationKey = localizationKey ; } public String getLocalizationKey ( ) { return localizationKey ; } private String localizationKey ; } public RegistrationProperty ( ) { } public RegistrationProperty ( String name , String stringValue , String lang , PropertyChangeListener listener ) { this ( QName . valueOf ( name ) , stringValue , lang , listener ) ; } public RegistrationProperty ( QName name , String stringValue , String lang , PropertyChangeListener listener ) { ParameterValidation . throwIllegalArgExceptionIfNull ( name , "<STR_LIT:Name>" ) ; ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( lang , "<STR_LIT>" , "<STR_LIT>" ) ; ParameterValidation . throwIllegalArgExceptionIfNull ( listener , "<STR_LIT>" ) ; this . persistentName = name ; this . persistentLang = lang ; this . listener = listener ; setValue ( stringValue ) ; } @ Override public boolean equals ( Object o ) { if ( this == o ) { return true ; } if ( ! ( o instanceof RegistrationProperty ) ) { return false ; } RegistrationProperty that = ( RegistrationProperty ) o ; if ( persistentId != null ? ! persistentId . equals ( that . persistentId ) : that . persistentId != null ) { return false ; } if ( ! persistentName . equals ( that . persistentName ) ) { return false ; } return ! ( persistentValue != null ? ! persistentValue . equals ( that . persistentValue ) : that . persistentValue != null ) ; } @ Override public int hashCode ( ) { int result ; result = ( persistentId != null ? persistentId . hashCode ( ) : <NUM_LIT:0> ) ; result = <NUM_LIT:31> * result + persistentName . hashCode ( ) ; result = <NUM_LIT:31> * result + ( persistentValue != null ? persistentValue . hashCode ( ) : <NUM_LIT:0> ) ; return result ; } public String getPersistentKey ( ) { return persistentId ; } public void setPersistentKey ( String key ) { this . persistentId = key ; } public QName getName ( ) { return persistentName ; } public void setName ( QName name ) { ParameterValidation . throwIllegalArgExceptionIfNull ( name , "<STR_LIT:Name>" ) ; this . persistentName = name ; } public String getValue ( ) { return persistentValue ; } public RegistrationPropertyDescription getDescription ( ) { return persistentDescription ; } public void setDescription ( RegistrationPropertyDescription description ) { this . persistentDescription = description ; } public Boolean isInvalid ( ) { if ( UNCHECKED_VALUE . equals ( status ) ) { return null ; } else { return ! VALID . equals ( status ) ; } } public boolean isDeterminedInvalid ( ) { return ! VALID . equals ( status ) && ! UNCHECKED_VALUE . equals ( status ) ; } public void setValue ( String stringValue ) { if ( ( persistentValue != null && ! persistentValue . equals ( stringValue ) ) || ( persistentValue == null && stringValue != null ) ) { String oldValue = persistentValue ; Status oldStatus = status ; persistentValue = stringValue ; if ( persistentValue == null ) { status = MISSING_VALUE ; } else { status = UNCHECKED_VALUE ; } notifyListener ( oldValue , persistentValue , oldStatus ) ; } } public String getLang ( ) { return persistentLang ; } public void setLang ( String lang ) { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( lang , "<STR_LIT>" , "<STR_LIT>" ) ; this . persistentLang = lang ; } public Status getStatus ( ) { return status ; } public void setStatus ( Status status ) { this . status = status ; } private void notifyListener ( String oldValue , String newValue , Status oldStatus ) { ParameterValidation . throwIllegalArgExceptionIfNull ( listener , "<STR_LIT>" ) ; listener . propertyValueChanged ( this , oldStatus , oldValue , newValue ) ; } public void setListener ( PropertyChangeListener listener ) { this . listener = listener ; } static interface PropertyChangeListener { void propertyValueChanged ( RegistrationProperty property , Status previousStatus , Object oldValue , Object newValue ) ; } } </s>
|
<s> package org . gatein . wsrp . services ; public interface ManageableServiceFactory extends ServiceFactory { void setFailed ( boolean failed ) ; void setAvailable ( boolean available ) ; } </s>
|
<s> package org . gatein . wsrp . services . v2 ; import org . gatein . wsrp . services . MarkupService ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . EventParams ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . HandleEventsFailed ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InteractionParams ; import org . oasis . wsrp . v2 . InvalidCookie ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidSession ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . MarkupContext ; import org . oasis . wsrp . v2 . MarkupParams ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletStateChangeRequired ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceContext ; import org . oasis . wsrp . v2 . ResourceParams ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import org . oasis . wsrp . v2 . UnsupportedLocale ; import org . oasis . wsrp . v2 . UnsupportedMimeType ; import org . oasis . wsrp . v2 . UnsupportedMode ; import org . oasis . wsrp . v2 . UnsupportedWindowState ; import org . oasis . wsrp . v2 . UpdateResponse ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2MarkupPortType ; import javax . xml . ws . Holder ; import java . util . List ; public class V2MarkupService extends MarkupService < WSRPV2MarkupPortType > { public V2MarkupService ( WSRPV2MarkupPortType port ) { super ( port ) ; } @ Override public void getMarkup ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , Holder < MarkupContext > markupContext , Holder < SessionContext > sessionContext , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { service . getMarkup ( registrationContext , portletContext , runtimeContext , userContext , markupParams , markupContext , sessionContext , extensions ) ; } @ Override public void getResource ( RegistrationContext registrationContext , Holder < PortletContext > portletContext , RuntimeContext runtimeContext , UserContext userContext , ResourceParams resourceParams , Holder < ResourceContext > resourceContext , Holder < SessionContext > sessionContext , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { service . getResource ( registrationContext , portletContext , runtimeContext , userContext , resourceParams , resourceContext , sessionContext , extensions ) ; } @ Override public void performBlockingInteraction ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , InteractionParams interactionParams , Holder < UpdateResponse > updateResponse , Holder < String > redirectURL , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { service . performBlockingInteraction ( registrationContext , portletContext , runtimeContext , userContext , markupParams , interactionParams , updateResponse , redirectURL , extensions ) ; } @ Override public void handleEvents ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , EventParams eventParams , Holder < UpdateResponse > updateResponse , Holder < List < HandleEventsFailed > > failedEvents , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { service . handleEvents ( registrationContext , portletContext , runtimeContext , userContext , markupParams , eventParams , updateResponse , failedEvents , extensions ) ; } @ Override public List < Extension > releaseSessions ( RegistrationContext registrationContext , List < String > sessionIDs , UserContext userContext ) throws AccessDenied , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return service . releaseSessions ( registrationContext , sessionIDs , userContext ) ; } @ Override public List < Extension > initCookie ( RegistrationContext registrationContext , UserContext userContext ) throws AccessDenied , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return service . initCookie ( registrationContext , userContext ) ; } } </s>
|
<s> package org . gatein . wsrp . services . v2 ; import org . gatein . wsrp . services . ServiceDescriptionService ; import org . oasis . wsrp . v2 . CookieProtocol ; import org . oasis . wsrp . v2 . EventDescription ; import org . oasis . wsrp . v2 . ExportDescription ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . ExtensionDescription ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . ItemDescription ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModelTypes ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2ServiceDescriptionPortType ; import javax . xml . ws . Holder ; import java . util . List ; public class V2ServiceDescriptionService extends ServiceDescriptionService < WSRPV2ServiceDescriptionPortType > implements WSRPV2ServiceDescriptionPortType { public V2ServiceDescriptionService ( WSRPV2ServiceDescriptionPortType service ) { super ( service ) ; } @ Override public void getServiceDescription ( RegistrationContext registrationContext , List < String > desiredLocales , List < String > portletHandles , UserContext userContext , Holder < Boolean > requiresRegistration , Holder < List < PortletDescription > > offeredPortlets , Holder < List < ItemDescription > > userCategoryDescriptions , Holder < List < ExtensionDescription > > extensionDescriptions , Holder < List < ItemDescription > > customWindowStateDescriptions , Holder < List < ItemDescription > > customModeDescriptions , Holder < CookieProtocol > requiresInitCookie , Holder < ModelDescription > registrationPropertyDescription , Holder < List < String > > locales , Holder < ResourceList > resourceList , Holder < List < EventDescription > > eventDescriptions , Holder < ModelTypes > schemaType , Holder < List < String > > supportedOptions , Holder < ExportDescription > exportDescription , Holder < Boolean > mayReturnRegistrationState , Holder < List < Extension > > extensions ) throws InvalidRegistration , ModifyRegistrationRequired , OperationFailed , ResourceSuspended { service . getServiceDescription ( registrationContext , desiredLocales , portletHandles , userContext , requiresRegistration , offeredPortlets , userCategoryDescriptions , extensionDescriptions , customWindowStateDescriptions , customModeDescriptions , requiresInitCookie , registrationPropertyDescription , locales , resourceList , eventDescriptions , schemaType , supportedOptions , exportDescription , mayReturnRegistrationState , extensions ) ; } } </s>
|
<s> package org . gatein . wsrp . services . v2 ; import org . gatein . wsrp . services . PortletManagementService ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . CopiedPortlet ; import org . oasis . wsrp . v2 . ExportByValueNotSupported ; import org . oasis . wsrp . v2 . ExportNoLongerValid ; import org . oasis . wsrp . v2 . ExportedPortlet ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . FailedPortlets ; import org . oasis . wsrp . v2 . ImportPortlet ; import org . oasis . wsrp . v2 . ImportPortletsFailed ; import org . oasis . wsrp . v2 . ImportedPortlet ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . PortletLifetime ; import org . oasis . wsrp . v2 . Property ; import org . oasis . wsrp . v2 . PropertyList ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResetProperty ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetExportLifetime ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2PortletManagementPortType ; import javax . xml . ws . Holder ; import java . util . List ; public class V2PortletManagementService extends PortletManagementService < WSRPV2PortletManagementPortType > { public V2PortletManagementService ( WSRPV2PortletManagementPortType port ) { super ( port ) ; } @ Override public void getPortletDescription ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > desiredLocales , Holder < PortletDescription > portletDescription , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . getPortletDescription ( registrationContext , portletContext , userContext , desiredLocales , portletDescription , resourceList , extensions ) ; } @ Override public void clonePortlet ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , Lifetime lifetime , Holder < String > portletHandle , Holder < byte [ ] > portletState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . clonePortlet ( registrationContext , portletContext , userContext , lifetime , portletHandle , portletState , scheduledDestruction , extensions ) ; } @ Override public void destroyPortlets ( RegistrationContext registrationContext , List < String > portletHandles , UserContext userContext , Holder < List < FailedPortlets > > failedPortlets , Holder < List < Extension > > extensions ) throws InconsistentParameters , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . destroyPortlets ( registrationContext , portletHandles , userContext , failedPortlets , extensions ) ; } @ Override public void getPortletsLifetime ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Holder < List < PortletLifetime > > portletLifetime , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . getPortletsLifetime ( registrationContext , portletContext , userContext , portletLifetime , failedPortlets , resourceList , extensions ) ; } @ Override public void setPortletsLifetime ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Lifetime lifetime , Holder < List < PortletLifetime > > updatedPortlet , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . setPortletsLifetime ( registrationContext , portletContext , userContext , lifetime , updatedPortlet , failedPortlets , resourceList , extensions ) ; } @ Override public void copyPortlets ( RegistrationContext toRegistrationContext , UserContext toUserContext , RegistrationContext fromRegistrationContext , UserContext fromUserContext , List < PortletContext > fromPortletContexts , Lifetime lifetime , Holder < List < CopiedPortlet > > copiedPortlets , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . copyPortlets ( toRegistrationContext , toUserContext , fromRegistrationContext , fromUserContext , fromPortletContexts , lifetime , copiedPortlets , failedPortlets , resourceList , extensions ) ; } @ Override public void exportPortlets ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Holder < Lifetime > lifetime , Boolean exportByValueRequired , Holder < byte [ ] > exportContext , Holder < List < ExportedPortlet > > exportedPortlet , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , ExportByValueNotSupported , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . exportPortlets ( registrationContext , portletContext , userContext , lifetime , exportByValueRequired , exportContext , exportedPortlet , failedPortlets , resourceList , extensions ) ; } @ Override public void importPortlets ( RegistrationContext registrationContext , byte [ ] importContext , List < ImportPortlet > importPortlet , UserContext userContext , Lifetime lifetime , Holder < List < ImportedPortlet > > importedPortlets , Holder < List < ImportPortletsFailed > > importFailed , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , ExportNoLongerValid , InconsistentParameters , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . importPortlets ( registrationContext , importContext , importPortlet , userContext , lifetime , importedPortlets , importFailed , resourceList , extensions ) ; } @ Override public List < Extension > releaseExport ( RegistrationContext registrationContext , byte [ ] exportContext , UserContext userContext ) { return service . releaseExport ( registrationContext , exportContext , userContext ) ; } @ Override public Lifetime setExportLifetime ( SetExportLifetime setExportLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return service . setExportLifetime ( setExportLifetime ) ; } @ Override public void setPortletProperties ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , PropertyList propertyList , Holder < String > portletHandle , Holder < byte [ ] > portletState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . setPortletProperties ( registrationContext , portletContext , userContext , propertyList , portletHandle , portletState , scheduledDestruction , extensions ) ; } @ Override public void getPortletProperties ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > names , Holder < List < Property > > properties , Holder < List < ResetProperty > > resetProperties , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . getPortletProperties ( registrationContext , portletContext , userContext , names , properties , resetProperties , extensions ) ; } @ Override public void getPortletPropertyDescription ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > desiredLocales , Holder < ModelDescription > modelDescription , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { service . getPortletPropertyDescription ( registrationContext , portletContext , userContext , desiredLocales , modelDescription , resourceList , extensions ) ; } } </s>
|
<s> package org . gatein . wsrp . services . v2 ; import org . gatein . wsrp . services . RegistrationService ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetRegistrationLifetime ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetRegistrationLifetime ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2RegistrationPortType ; import javax . xml . ws . Holder ; import java . util . List ; public class V2RegistrationService extends RegistrationService < WSRPV2RegistrationPortType > { public V2RegistrationService ( WSRPV2RegistrationPortType service ) { super ( service ) ; } @ Override public void register ( RegistrationData registrationData , Lifetime lifetime , UserContext userContext , Holder < byte [ ] > registrationState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions , Holder < String > registrationHandle ) throws MissingParameters , OperationFailed , OperationNotSupported { service . register ( registrationData , lifetime , userContext , registrationState , scheduledDestruction , extensions , registrationHandle ) ; } @ Override public List < Extension > deregister ( RegistrationContext registrationContext , UserContext userContext ) throws InvalidRegistration , OperationFailed , OperationNotSupported , ResourceSuspended { return service . deregister ( registrationContext , userContext ) ; } @ Override public void modifyRegistration ( RegistrationContext registrationContext , RegistrationData registrationData , UserContext userContext , Holder < byte [ ] > registrationState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws InvalidRegistration , MissingParameters , OperationFailed , OperationNotSupported , ResourceSuspended { service . modifyRegistration ( registrationContext , registrationData , userContext , registrationState , scheduledDestruction , extensions ) ; } @ Override public Lifetime getRegistrationLifetime ( GetRegistrationLifetime getRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return service . getRegistrationLifetime ( getRegistrationLifetime ) ; } @ Override public Lifetime setRegistrationLifetime ( SetRegistrationLifetime setRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { return null ; } } </s>
|
<s> package org . gatein . wsrp . services ; import org . gatein . common . util . ParameterValidation ; import org . gatein . common . util . Version ; import org . gatein . wsrp . handler . RequestHeaderClientHandler ; import org . gatein . wsrp . services . v1 . V1MarkupService ; import org . gatein . wsrp . services . v1 . V1PortletManagementService ; import org . gatein . wsrp . services . v1 . V1RegistrationService ; import org . gatein . wsrp . services . v1 . V1ServiceDescriptionService ; import org . gatein . wsrp . services . v2 . V2MarkupService ; import org . gatein . wsrp . services . v2 . V2PortletManagementService ; import org . gatein . wsrp . services . v2 . V2RegistrationService ; import org . gatein . wsrp . services . v2 . V2ServiceDescriptionService ; import org . gatein . wsrp . wss . CustomizePortListener ; import org . gatein . wsrp . wss . WebServiceSecurityFactory ; import org . oasis . wsrp . v1 . WSRPV1MarkupPortType ; import org . oasis . wsrp . v1 . WSRPV1PortletManagementPortType ; import org . oasis . wsrp . v1 . WSRPV1RegistrationPortType ; import org . oasis . wsrp . v1 . WSRPV1ServiceDescriptionPortType ; import org . oasis . wsrp . v2 . WSRPV2MarkupPortType ; import org . oasis . wsrp . v2 . WSRPV2PortletManagementPortType ; import org . oasis . wsrp . v2 . WSRPV2RegistrationPortType ; import org . oasis . wsrp . v2 . WSRPV2ServiceDescriptionPortType ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import javax . wsdl . Definition ; import javax . wsdl . Port ; import javax . wsdl . WSDLException ; import javax . wsdl . factory . WSDLFactory ; import javax . wsdl . xml . WSDLReader ; import javax . xml . namespace . QName ; import javax . xml . ws . Binding ; import javax . xml . ws . BindingProvider ; import javax . xml . ws . Service ; import javax . xml . ws . handler . Handler ; import java . net . MalformedURLException ; import java . net . URI ; import java . net . URL ; import java . util . ArrayList ; import java . util . List ; import java . util . Map ; public class SOAPServiceFactory implements ManageableServiceFactory { static final String JBOSS_WS_TIMEOUT = "<STR_LIT>" ; static final String SUN_WS_TIMEOUT = "<STR_LIT>" ; static final String IBM_WS_TIMEOUT = "<STR_LIT>" ; static final RequestHeaderClientHandler REQUEST_HEADER_CLIENT_HANDLER = new RequestHeaderClientHandler ( ) ; static final String JBOSS_WS_STUBEXT_PROPERTY_CHUNKED_ENCODING_SIZE = "<STR_LIT>" ; private static final Logger log = LoggerFactory . getLogger ( SOAPServiceFactory . class ) ; private String wsdlDefinitionURL ; private boolean isV2 = false ; private Service wsService ; private static final String WSRP_V1_BINDING = "<STR_LIT>" ; private static final String WSRP_V2_BINDING = "<STR_LIT>" ; private String markupURL ; private String serviceDescriptionURL ; private String portletManagementURL ; private String registrationURL ; private boolean failed ; private boolean available ; private int msBeforeTimeOut = DEFAULT_TIMEOUT_MS ; private boolean wssEnabled ; private void setTimeout ( Map < String , Object > requestContext ) { int timeout = getWSOperationTimeOut ( ) ; requestContext . put ( JBOSS_WS_TIMEOUT , timeout ) ; requestContext . put ( SUN_WS_TIMEOUT , timeout ) ; requestContext . put ( IBM_WS_TIMEOUT , timeout ) ; } private < T > T customizePort ( Class < T > expectedServiceInterface , Object service , String portAddress ) { configureWSS ( service ) ; BindingProvider bindingProvider = ( BindingProvider ) service ; Map < String , Object > requestContext = bindingProvider . getRequestContext ( ) ; setTimeout ( requestContext ) ; requestContext . put ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY , portAddress ) ; requestContext . put ( JBOSS_WS_STUBEXT_PROPERTY_CHUNKED_ENCODING_SIZE , "<STR_LIT:0>" ) ; Binding binding = bindingProvider . getBinding ( ) ; List < Handler > handlerChain = binding . getHandlerChain ( ) ; if ( handlerChain != null ) { if ( ! handlerChain . contains ( REQUEST_HEADER_CLIENT_HANDLER ) ) { handlerChain . add ( REQUEST_HEADER_CLIENT_HANDLER ) ; } } else { handlerChain = new ArrayList < Handler > ( <NUM_LIT:1> ) ; handlerChain . add ( REQUEST_HEADER_CLIENT_HANDLER ) ; } binding . setHandlerChain ( handlerChain ) ; return expectedServiceInterface . cast ( service ) ; } public < T > T getService ( Class < T > clazz ) throws Exception { if ( log . isDebugEnabled ( ) ) { log . debug ( "<STR_LIT>" + clazz ) ; } refresh ( false ) ; Object service = null ; try { service = wsService . getPort ( clazz ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + clazz , e ) ; } String portAddress = null ; boolean isMandatoryInterface = false ; if ( WSRPV2ServiceDescriptionPortType . class . isAssignableFrom ( clazz ) || WSRPV1ServiceDescriptionPortType . class . isAssignableFrom ( clazz ) ) { portAddress = serviceDescriptionURL ; isMandatoryInterface = true ; } else if ( WSRPV2MarkupPortType . class . isAssignableFrom ( clazz ) || WSRPV1MarkupPortType . class . isAssignableFrom ( clazz ) ) { portAddress = markupURL ; isMandatoryInterface = true ; } else if ( WSRPV2RegistrationPortType . class . isAssignableFrom ( clazz ) || WSRPV1RegistrationPortType . class . isAssignableFrom ( clazz ) ) { portAddress = registrationURL ; } else if ( WSRPV2PortletManagementPortType . class . isAssignableFrom ( clazz ) || WSRPV1PortletManagementPortType . class . isAssignableFrom ( clazz ) ) { portAddress = portletManagementURL ; } if ( service != null ) { if ( portAddress != null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "<STR_LIT>" + portAddress ) ; } T result = customizePort ( clazz , service , portAddress ) ; setFailed ( false ) ; setAvailable ( true ) ; return result ; } else { if ( isMandatoryInterface ) { setFailed ( true ) ; throw new IllegalStateException ( "<STR_LIT>" + clazz . getName ( ) ) ; } else { throw new IllegalStateException ( "<STR_LIT>" + clazz . getName ( ) ) ; } } } else { return null ; } } public boolean isAvailable ( ) { return available ; } public boolean isFailed ( ) { return failed ; } public void stop ( ) { } public void setFailed ( boolean failed ) { this . failed = failed ; } public void setAvailable ( boolean available ) { this . available = available ; } public void setWSOperationTimeOut ( int msBeforeTimeOut ) { if ( msBeforeTimeOut < <NUM_LIT:0> ) { msBeforeTimeOut = DEFAULT_TIMEOUT_MS ; } this . msBeforeTimeOut = msBeforeTimeOut ; } public int getWSOperationTimeOut ( ) { return msBeforeTimeOut ; } public String getWsdlDefinitionURL ( ) { return wsdlDefinitionURL ; } public void setWsdlDefinitionURL ( String wsdlDefinitionURL ) { this . wsdlDefinitionURL = wsdlDefinitionURL ; setAvailable ( false ) ; setFailed ( false ) ; } public void start ( ) throws Exception { try { ParameterValidation . throwIllegalArgExceptionIfNullOrEmpty ( wsdlDefinitionURL , "<STR_LIT>" , "<STR_LIT>" ) ; URL wsdlURL = new URI ( wsdlDefinitionURL ) . toURL ( ) ; WSDLInfo wsdlInfo = new WSDLInfo ( wsdlDefinitionURL ) ; QName wsrp2 = wsdlInfo . getWSRP2ServiceQName ( ) ; QName wsrp1 = wsdlInfo . getWSRP1ServiceQName ( ) ; if ( wsrp2 != null ) { wsService = Service . create ( wsdlURL , wsrp2 ) ; Class portTypeClass = null ; try { portTypeClass = WSRPV2MarkupPortType . class ; WSRPV2MarkupPortType markupPortType = wsService . getPort ( WSRPV2MarkupPortType . class ) ; markupURL = ( String ) ( ( BindingProvider ) markupPortType ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; portTypeClass = WSRPV2ServiceDescriptionPortType . class ; WSRPV2ServiceDescriptionPortType sdPort = wsService . getPort ( WSRPV2ServiceDescriptionPortType . class ) ; serviceDescriptionURL = ( String ) ( ( BindingProvider ) sdPort ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; } catch ( Exception e ) { setFailed ( true ) ; throw new IllegalArgumentException ( "<STR_LIT>" + portTypeClass . getName ( ) + "<STR_LIT>" + wsdlDefinitionURL , e ) ; } try { WSRPV2PortletManagementPortType managementPortType = wsService . getPort ( WSRPV2PortletManagementPortType . class ) ; portletManagementURL = ( String ) ( ( BindingProvider ) managementPortType ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + wsdlDefinitionURL , e ) ; portletManagementURL = null ; } try { WSRPV2RegistrationPortType registrationPortType = wsService . getPort ( WSRPV2RegistrationPortType . class ) ; registrationURL = ( String ) ( ( BindingProvider ) registrationPortType ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + wsdlDefinitionURL , e ) ; registrationURL = null ; } setFailed ( false ) ; setAvailable ( true ) ; isV2 = true ; } else if ( wsrp1 != null ) { wsService = Service . create ( wsdlURL , wsrp1 ) ; Class portTypeClass = null ; try { portTypeClass = WSRPV1MarkupPortType . class ; WSRPV1MarkupPortType markupPortType = wsService . getPort ( WSRPV1MarkupPortType . class ) ; markupURL = ( String ) ( ( BindingProvider ) markupPortType ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; portTypeClass = WSRPV1ServiceDescriptionPortType . class ; WSRPV1ServiceDescriptionPortType sdPort = wsService . getPort ( WSRPV1ServiceDescriptionPortType . class ) ; serviceDescriptionURL = ( String ) ( ( BindingProvider ) sdPort ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; } catch ( Exception e ) { setFailed ( true ) ; throw new IllegalArgumentException ( "<STR_LIT>" + portTypeClass . getName ( ) + "<STR_LIT>" + wsdlDefinitionURL , e ) ; } try { WSRPV1PortletManagementPortType managementPortType = wsService . getPort ( WSRPV1PortletManagementPortType . class ) ; portletManagementURL = ( String ) ( ( BindingProvider ) managementPortType ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + wsdlDefinitionURL , e ) ; portletManagementURL = null ; } try { WSRPV1RegistrationPortType registrationPortType = wsService . getPort ( WSRPV1RegistrationPortType . class ) ; registrationURL = ( String ) ( ( BindingProvider ) registrationPortType ) . getRequestContext ( ) . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; } catch ( Exception e ) { log . debug ( "<STR_LIT>" + wsdlDefinitionURL , e ) ; registrationURL = null ; } setFailed ( false ) ; setAvailable ( true ) ; isV2 = false ; } else { throw new IllegalArgumentException ( "<STR_LIT>" + wsdlDefinitionURL ) ; } } catch ( MalformedURLException e ) { setFailed ( true ) ; throw new IllegalArgumentException ( wsdlDefinitionURL + "<STR_LIT>" , e ) ; } catch ( Exception e ) { log . info ( "<STR_LIT>" + wsdlDefinitionURL + "<STR_LIT>" , e ) ; setAvailable ( false ) ; setFailed ( true ) ; throw e ; } } public ServiceDescriptionService getServiceDescriptionService ( ) throws Exception { if ( isV2 ) { WSRPV2ServiceDescriptionPortType port = getService ( WSRPV2ServiceDescriptionPortType . class ) ; return new V2ServiceDescriptionService ( port ) ; } else { WSRPV1ServiceDescriptionPortType port = getService ( WSRPV1ServiceDescriptionPortType . class ) ; return new V1ServiceDescriptionService ( port ) ; } } public MarkupService getMarkupService ( ) throws Exception { if ( isV2 ) { WSRPV2MarkupPortType port = getService ( WSRPV2MarkupPortType . class ) ; return new V2MarkupService ( port ) ; } else { WSRPV1MarkupPortType port = getService ( WSRPV1MarkupPortType . class ) ; return new V1MarkupService ( port ) ; } } public PortletManagementService getPortletManagementService ( ) throws Exception { if ( isV2 ) { WSRPV2PortletManagementPortType port = getService ( WSRPV2PortletManagementPortType . class ) ; return new V2PortletManagementService ( port ) ; } else { WSRPV1PortletManagementPortType port = getService ( WSRPV1PortletManagementPortType . class ) ; return new V1PortletManagementService ( port ) ; } } public RegistrationService getRegistrationService ( ) throws Exception { if ( isV2 ) { WSRPV2RegistrationPortType port = getService ( WSRPV2RegistrationPortType . class ) ; return new V2RegistrationService ( port ) ; } else { WSRPV1RegistrationPortType port = getService ( WSRPV1RegistrationPortType . class ) ; return new V1RegistrationService ( port ) ; } } public Version getWSRPVersion ( ) { if ( isAvailable ( ) ) { if ( isV2 ) { return WSRP2 ; } else { return WSRP1 ; } } else { return null ; } } public boolean refresh ( boolean force ) throws Exception { if ( force || ( ! isAvailable ( ) && ! isFailed ( ) ) ) { start ( ) ; return true ; } return false ; } public void enableWSS ( boolean enable ) { this . wssEnabled = enable ; } public boolean isWSSEnabled ( ) { return this . wssEnabled ; } public boolean isWSSAvailable ( ) { WebServiceSecurityFactory wssFactory = WebServiceSecurityFactory . getInstance ( ) ; if ( wssFactory != null && wssFactory . getCustomizePortListeners ( ) != null && ! wssFactory . getCustomizePortListeners ( ) . isEmpty ( ) ) { return true ; } else { return false ; } } protected void configureWSS ( Object service ) { if ( wssEnabled ) { WebServiceSecurityFactory wssFactory = WebServiceSecurityFactory . getInstance ( ) ; if ( wssFactory . getCustomizePortListeners ( ) != null ) { for ( CustomizePortListener listener : wssFactory . getCustomizePortListeners ( ) ) { listener . customizePort ( service ) ; } } else { log . debug ( "<STR_LIT>" ) ; } } else { log . debug ( "<STR_LIT>" ) ; } } protected static class WSDLInfo { private final QName wsrp2ServiceQName ; private final QName wsrp1ServiceQName ; private final static WSDLFactory wsdlFactory ; static { try { wsdlFactory = WSDLFactory . newInstance ( ) ; } catch ( WSDLException e ) { throw new RuntimeException ( e ) ; } } public WSDLInfo ( String wsdlURL ) throws WSDLException { WSDLReader wsdlReader = wsdlFactory . newWSDLReader ( ) ; wsdlReader . setFeature ( "<STR_LIT>" , false ) ; wsdlReader . setFeature ( "<STR_LIT>" , false ) ; Definition definition = wsdlReader . readWSDL ( wsdlURL ) ; Map < QName , javax . wsdl . Service > services = definition . getServices ( ) ; int serviceNb = services . size ( ) ; if ( serviceNb > <NUM_LIT:2> ) { throw new WSDLException ( WSDLException . OTHER_ERROR , "<STR_LIT>" ) ; } QName wsrp1 = null , wsrp2 = null ; String ns = definition . getTargetNamespace ( ) ; for ( QName name : services . keySet ( ) ) { javax . wsdl . Service service = services . get ( name ) ; Map < String , Port > ports = service . getPorts ( ) ; String bindingNSURI = null ; for ( Port port : ports . values ( ) ) { QName bindingName = port . getBinding ( ) . getQName ( ) ; String newBindingNS = bindingName . getNamespaceURI ( ) ; if ( WSRP_V1_BINDING . equals ( newBindingNS ) || WSRP_V2_BINDING . equals ( newBindingNS ) ) { if ( bindingNSURI != null && ! bindingNSURI . equals ( newBindingNS ) ) { throw new WSDLException ( WSDLException . OTHER_ERROR , "<STR_LIT>" ) ; } bindingNSURI = newBindingNS ; } else { log . debug ( "<STR_LIT>" + newBindingNS + "<STR_LIT>" + bindingName ) ; } } if ( WSRP_V1_BINDING . equals ( bindingNSURI ) ) { wsrp1 = checkPotentialServiceName ( wsrp1 , name , ns ) ; } else if ( WSRP_V2_BINDING . equals ( bindingNSURI ) ) { wsrp2 = checkPotentialServiceName ( wsrp2 , name , ns ) ; } } wsrp2ServiceQName = wsrp2 ; wsrp1ServiceQName = wsrp1 ; if ( wsrp1 == null && wsrp2 == null ) { throw new WSDLException ( WSDLException . INVALID_WSDL , "<STR_LIT>" ) ; } } public QName getWSRP2ServiceQName ( ) { return wsrp2ServiceQName ; } public QName getWSRP1ServiceQName ( ) { return wsrp1ServiceQName ; } private QName checkPotentialServiceName ( QName potentiallyExisting , QName candidate , String namespace ) throws WSDLException { if ( potentiallyExisting != null ) { throw new WSDLException ( WSDLException . OTHER_ERROR , "<STR_LIT>" + namespace + "<STR_LIT>" ) ; } return candidate ; } } } </s>
|
<s> package org . gatein . wsrp . services ; import org . oasis . wsrp . v2 . CookieProtocol ; import org . oasis . wsrp . v2 . EventDescription ; import org . oasis . wsrp . v2 . ExportDescription ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . ExtensionDescription ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . ItemDescription ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModelTypes ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2ServiceDescriptionPortType ; import javax . xml . ws . Holder ; import java . util . List ; public abstract class ServiceDescriptionService < T > extends WSRPService < T > implements WSRPV2ServiceDescriptionPortType { protected ServiceDescriptionService ( T service ) { super ( service ) ; } public abstract void getServiceDescription ( RegistrationContext registrationContext , List < String > desiredLocales , List < String > portletHandles , UserContext userContext , Holder < Boolean > requiresRegistration , Holder < List < PortletDescription > > offeredPortlets , Holder < List < ItemDescription > > userCategoryDescriptions , Holder < List < ExtensionDescription > > extensionDescriptions , Holder < List < ItemDescription > > customWindowStateDescriptions , Holder < List < ItemDescription > > customModeDescriptions , Holder < CookieProtocol > requiresInitCookie , Holder < ModelDescription > registrationPropertyDescription , Holder < List < String > > locales , Holder < ResourceList > resourceList , Holder < List < EventDescription > > eventDescriptions , Holder < ModelTypes > schemaType , Holder < List < String > > supportedOptions , Holder < ExportDescription > exportDescription , Holder < Boolean > mayReturnRegistrationState , Holder < List < Extension > > extensions ) throws InvalidRegistration , ModifyRegistrationRequired , OperationFailed , ResourceSuspended ; } </s>
|
<s> package org . gatein . wsrp . services ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . CopiedPortlet ; import org . oasis . wsrp . v2 . ExportByValueNotSupported ; import org . oasis . wsrp . v2 . ExportNoLongerValid ; import org . oasis . wsrp . v2 . ExportedPortlet ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . FailedPortlets ; import org . oasis . wsrp . v2 . ImportPortlet ; import org . oasis . wsrp . v2 . ImportPortletsFailed ; import org . oasis . wsrp . v2 . ImportedPortlet ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . PortletLifetime ; import org . oasis . wsrp . v2 . Property ; import org . oasis . wsrp . v2 . PropertyList ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResetProperty ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetExportLifetime ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2PortletManagementPortType ; import javax . xml . ws . Holder ; import java . util . List ; public abstract class PortletManagementService < T > extends WSRPService < T > implements WSRPV2PortletManagementPortType { public PortletManagementService ( T service ) { super ( service ) ; } public abstract void getPortletDescription ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > desiredLocales , Holder < PortletDescription > portletDescription , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void clonePortlet ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , Lifetime lifetime , Holder < String > portletHandle , Holder < byte [ ] > portletState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void destroyPortlets ( RegistrationContext registrationContext , List < String > portletHandles , UserContext userContext , Holder < List < FailedPortlets > > failedPortlets , Holder < List < Extension > > extensions ) throws InconsistentParameters , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void getPortletsLifetime ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Holder < List < PortletLifetime > > portletLifetime , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void setPortletsLifetime ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Lifetime lifetime , Holder < List < PortletLifetime > > updatedPortlet , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void copyPortlets ( RegistrationContext toRegistrationContext , UserContext toUserContext , RegistrationContext fromRegistrationContext , UserContext fromUserContext , List < PortletContext > fromPortletContexts , Lifetime lifetime , Holder < List < CopiedPortlet > > copiedPortlets , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void exportPortlets ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Holder < Lifetime > lifetime , Boolean exportByValueRequired , Holder < byte [ ] > exportContext , Holder < List < ExportedPortlet > > exportedPortlet , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , ExportByValueNotSupported , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void importPortlets ( RegistrationContext registrationContext , byte [ ] importContext , List < ImportPortlet > importPortlet , UserContext userContext , Lifetime lifetime , Holder < List < ImportedPortlet > > importedPortlets , Holder < List < ImportPortletsFailed > > importFailed , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , ExportNoLongerValid , InconsistentParameters , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract List < Extension > releaseExport ( RegistrationContext registrationContext , byte [ ] exportContext , UserContext userContext ) ; public abstract Lifetime setExportLifetime ( SetExportLifetime setExportLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void setPortletProperties ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , PropertyList propertyList , Holder < String > portletHandle , Holder < byte [ ] > portletState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void getPortletProperties ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > names , Holder < List < Property > > properties , Holder < List < ResetProperty > > resetProperties , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void getPortletPropertyDescription ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > desiredLocales , Holder < ModelDescription > modelDescription , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; } </s>
|
<s> package org . gatein . wsrp . services ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . EventParams ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . HandleEventsFailed ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InteractionParams ; import org . oasis . wsrp . v2 . InvalidCookie ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidSession ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . MarkupContext ; import org . oasis . wsrp . v2 . MarkupParams ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletStateChangeRequired ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceContext ; import org . oasis . wsrp . v2 . ResourceParams ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import org . oasis . wsrp . v2 . UnsupportedLocale ; import org . oasis . wsrp . v2 . UnsupportedMimeType ; import org . oasis . wsrp . v2 . UnsupportedMode ; import org . oasis . wsrp . v2 . UnsupportedWindowState ; import org . oasis . wsrp . v2 . UpdateResponse ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2MarkupPortType ; import javax . xml . ws . Holder ; import java . util . List ; public abstract class MarkupService < T > extends WSRPService < T > implements WSRPV2MarkupPortType { protected MarkupService ( T service ) { super ( service ) ; } public abstract void getMarkup ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , Holder < MarkupContext > markupContext , Holder < SessionContext > sessionContext , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState ; public abstract void getResource ( RegistrationContext registrationContext , Holder < PortletContext > portletContext , RuntimeContext runtimeContext , UserContext userContext , ResourceParams resourceParams , Holder < ResourceContext > resourceContext , Holder < SessionContext > sessionContext , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState ; public abstract void performBlockingInteraction ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , InteractionParams interactionParams , Holder < UpdateResponse > updateResponse , Holder < String > redirectURL , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState ; public abstract void handleEvents ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , EventParams eventParams , Holder < UpdateResponse > updateResponse , Holder < List < HandleEventsFailed > > failedEvents , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState ; public abstract List < Extension > releaseSessions ( RegistrationContext registrationContext , List < String > sessionIDs , UserContext userContext ) throws AccessDenied , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract List < Extension > initCookie ( RegistrationContext registrationContext , UserContext userContext ) throws AccessDenied , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; } </s>
|
<s> package org . gatein . wsrp . services ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetRegistrationLifetime ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetRegistrationLifetime ; import org . oasis . wsrp . v2 . UserContext ; import org . oasis . wsrp . v2 . WSRPV2RegistrationPortType ; import javax . xml . ws . Holder ; import java . util . List ; public abstract class RegistrationService < T > extends WSRPService < T > implements WSRPV2RegistrationPortType { public RegistrationService ( T service ) { super ( service ) ; } public abstract void register ( RegistrationData registrationData , Lifetime lifetime , UserContext userContext , Holder < byte [ ] > registrationState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions , Holder < String > registrationHandle ) throws MissingParameters , OperationFailed , OperationNotSupported ; public abstract List < Extension > deregister ( RegistrationContext registrationContext , UserContext userContext ) throws InvalidRegistration , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract void modifyRegistration ( RegistrationContext registrationContext , RegistrationData registrationData , UserContext userContext , Holder < byte [ ] > registrationState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws InvalidRegistration , MissingParameters , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract Lifetime getRegistrationLifetime ( GetRegistrationLifetime getRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; public abstract Lifetime setRegistrationLifetime ( SetRegistrationLifetime setRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended ; } </s>
|
<s> package org . gatein . wsrp . services . v1 ; import org . gatein . common . NotYetImplemented ; import org . gatein . wsrp . WSRPExceptionFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . services . PortletManagementService ; import org . gatein . wsrp . spec . v1 . V1ToV2Converter ; import org . gatein . wsrp . spec . v1 . V2ToV1Converter ; import org . oasis . wsrp . v1 . V1AccessDenied ; import org . oasis . wsrp . v1 . V1DestroyFailed ; import org . oasis . wsrp . v1 . V1Extension ; import org . oasis . wsrp . v1 . V1InconsistentParameters ; import org . oasis . wsrp . v1 . V1InvalidHandle ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1InvalidUserCategory ; import org . oasis . wsrp . v1 . V1MissingParameters ; import org . oasis . wsrp . v1 . V1ModelDescription ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1PortletDescription ; import org . oasis . wsrp . v1 . V1Property ; import org . oasis . wsrp . v1 . V1ResetProperty ; import org . oasis . wsrp . v1 . V1ResourceList ; import org . oasis . wsrp . v1 . WSRPV1PortletManagementPortType ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . CopiedPortlet ; import org . oasis . wsrp . v2 . ExportByValueNotSupported ; import org . oasis . wsrp . v2 . ExportNoLongerValid ; import org . oasis . wsrp . v2 . ExportedPortlet ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . FailedPortlets ; import org . oasis . wsrp . v2 . ImportPortlet ; import org . oasis . wsrp . v2 . ImportPortletsFailed ; import org . oasis . wsrp . v2 . ImportedPortlet ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . PortletLifetime ; import org . oasis . wsrp . v2 . Property ; import org . oasis . wsrp . v2 . PropertyList ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResetProperty ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetExportLifetime ; import org . oasis . wsrp . v2 . UserContext ; import javax . xml . ws . Holder ; import java . util . List ; public class V1PortletManagementService extends PortletManagementService < WSRPV1PortletManagementPortType > { public V1PortletManagementService ( WSRPV1PortletManagementPortType port ) { super ( port ) ; } @ Override public void getPortletDescription ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > desiredLocales , Holder < PortletDescription > portletDescription , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < V1PortletDescription > v1PortletDescriptionHolder = new Holder < V1PortletDescription > ( ) ; Holder < V1ResourceList > v1ResourceListHolder = new Holder < V1ResourceList > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . getPortletDescription ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , desiredLocales , v1PortletDescriptionHolder , v1ResourceListHolder , v1Extensions ) ; portletDescription . value = V1ToV2Converter . toV2PortletDescription ( v1PortletDescriptionHolder . value ) ; resourceList . value = V1ToV2Converter . toV2ResourceList ( v1ResourceListHolder . value ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied v1AccessDenied ) { throw V1ToV2Converter . toV2Exception ( AccessDenied . class , v1AccessDenied ) ; } catch ( V1InconsistentParameters v1InconsistentParameters ) { WSRPExceptionFactory . throwWSException ( InconsistentParameters . class , v1InconsistentParameters . getMessage ( ) , v1InconsistentParameters ) ; } catch ( V1InvalidHandle v1InvalidHandle ) { WSRPExceptionFactory . throwWSException ( InvalidHandle . class , v1InvalidHandle . getMessage ( ) , v1InvalidHandle ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { WSRPExceptionFactory . throwWSException ( InvalidRegistration . class , v1InvalidRegistration . getMessage ( ) , v1InvalidRegistration ) ; } catch ( V1InvalidUserCategory v1InvalidUserCategory ) { WSRPExceptionFactory . throwWSException ( InvalidUserCategory . class , v1InvalidUserCategory . getMessage ( ) , v1InvalidUserCategory ) ; } catch ( V1MissingParameters v1MissingParameters ) { WSRPExceptionFactory . throwWSException ( MissingParameters . class , v1MissingParameters . getMessage ( ) , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { WSRPExceptionFactory . throwWSException ( OperationFailed . class , v1OperationFailed . getMessage ( ) , v1OperationFailed ) ; } } @ Override public void clonePortlet ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , Lifetime lifetime , Holder < String > portletHandle , Holder < byte [ ] > portletState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . clonePortlet ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , portletHandle , portletState , v1Extensions ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied v1AccessDenied ) { WSRPExceptionFactory . throwWSException ( AccessDenied . class , v1AccessDenied . getMessage ( ) , v1AccessDenied ) ; } catch ( V1InconsistentParameters v1InconsistentParameters ) { WSRPExceptionFactory . throwWSException ( InconsistentParameters . class , v1InconsistentParameters . getMessage ( ) , v1InconsistentParameters ) ; } catch ( V1InvalidHandle v1InvalidHandle ) { WSRPExceptionFactory . throwWSException ( InvalidHandle . class , v1InvalidHandle . getMessage ( ) , v1InvalidHandle ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { WSRPExceptionFactory . throwWSException ( InvalidRegistration . class , v1InvalidRegistration . getMessage ( ) , v1InvalidRegistration ) ; } catch ( V1InvalidUserCategory v1InvalidUserCategory ) { WSRPExceptionFactory . throwWSException ( InvalidUserCategory . class , v1InvalidUserCategory . getMessage ( ) , v1InvalidUserCategory ) ; } catch ( V1MissingParameters v1MissingParameters ) { WSRPExceptionFactory . throwWSException ( MissingParameters . class , v1MissingParameters . getMessage ( ) , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { WSRPExceptionFactory . throwWSException ( OperationFailed . class , v1OperationFailed . getMessage ( ) , v1OperationFailed ) ; } } @ Override public void destroyPortlets ( RegistrationContext registrationContext , List < String > portletHandles , UserContext userContext , Holder < List < FailedPortlets > > failedPortlets , Holder < List < Extension > > extensions ) throws InconsistentParameters , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < List < V1DestroyFailed > > destroyFailed = new Holder < List < V1DestroyFailed > > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . destroyPortlets ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , portletHandles , destroyFailed , v1Extensions ) ; failedPortlets . value = V1ToV2Converter . toV2FailedPortlets ( destroyFailed . value ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1InconsistentParameters v1InconsistentParameters ) { WSRPExceptionFactory . throwWSException ( InconsistentParameters . class , v1InconsistentParameters . getMessage ( ) , v1InconsistentParameters ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { WSRPExceptionFactory . throwWSException ( InvalidRegistration . class , v1InvalidRegistration . getMessage ( ) , v1InvalidRegistration ) ; } catch ( V1MissingParameters v1MissingParameters ) { WSRPExceptionFactory . throwWSException ( MissingParameters . class , v1MissingParameters . getMessage ( ) , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { WSRPExceptionFactory . throwWSException ( OperationFailed . class , v1OperationFailed . getMessage ( ) , v1OperationFailed ) ; } } @ Override public void getPortletsLifetime ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Holder < List < PortletLifetime > > portletLifetime , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { WSRPExceptionFactory . throwWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public void setPortletsLifetime ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Lifetime lifetime , Holder < List < PortletLifetime > > updatedPortlet , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { WSRPExceptionFactory . throwWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public void copyPortlets ( RegistrationContext toRegistrationContext , UserContext toUserContext , RegistrationContext fromRegistrationContext , UserContext fromUserContext , List < PortletContext > fromPortletContexts , Lifetime lifetime , Holder < List < CopiedPortlet > > copiedPortlets , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { WSRPExceptionFactory . throwWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public void exportPortlets ( RegistrationContext registrationContext , List < PortletContext > portletContext , UserContext userContext , Holder < Lifetime > lifetime , Boolean exportByValueRequired , Holder < byte [ ] > exportContext , Holder < List < ExportedPortlet > > exportedPortlet , Holder < List < FailedPortlets > > failedPortlets , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , ExportByValueNotSupported , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { WSRPExceptionFactory . throwWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public void importPortlets ( RegistrationContext registrationContext , byte [ ] importContext , List < ImportPortlet > importPortlet , UserContext userContext , Lifetime lifetime , Holder < List < ImportedPortlet > > importedPortlets , Holder < List < ImportPortletsFailed > > importFailed , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , ExportNoLongerValid , InconsistentParameters , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { WSRPExceptionFactory . throwWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public List < Extension > releaseExport ( RegistrationContext registrationContext , byte [ ] exportContext , UserContext userContext ) { throw new NotYetImplemented ( ) ; } @ Override public Lifetime setExportLifetime ( SetExportLifetime setExportLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { throw WSRPExceptionFactory . throwWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public void setPortletProperties ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , PropertyList propertyList , Holder < String > portletHandle , Holder < byte [ ] > portletState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . setPortletProperties ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , V2ToV1Converter . toV1PropertyList ( propertyList ) , portletHandle , portletState , v1Extensions ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied v1AccessDenied ) { WSRPExceptionFactory . throwWSException ( AccessDenied . class , v1AccessDenied . getMessage ( ) , v1AccessDenied ) ; } catch ( V1InconsistentParameters v1InconsistentParameters ) { WSRPExceptionFactory . throwWSException ( InconsistentParameters . class , v1InconsistentParameters . getMessage ( ) , v1InconsistentParameters ) ; } catch ( V1InvalidHandle v1InvalidHandle ) { WSRPExceptionFactory . throwWSException ( InvalidHandle . class , v1InvalidHandle . getMessage ( ) , v1InvalidHandle ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { WSRPExceptionFactory . throwWSException ( InvalidRegistration . class , v1InvalidRegistration . getMessage ( ) , v1InvalidRegistration ) ; } catch ( V1InvalidUserCategory v1InvalidUserCategory ) { WSRPExceptionFactory . throwWSException ( InvalidUserCategory . class , v1InvalidUserCategory . getMessage ( ) , v1InvalidUserCategory ) ; } catch ( V1MissingParameters v1MissingParameters ) { WSRPExceptionFactory . throwWSException ( MissingParameters . class , v1MissingParameters . getMessage ( ) , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { WSRPExceptionFactory . throwWSException ( OperationFailed . class , v1OperationFailed . getMessage ( ) , v1OperationFailed ) ; } } @ Override public void getPortletProperties ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > names , Holder < List < Property > > properties , Holder < List < ResetProperty > > resetProperties , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < List < V1Property > > v1PropertyList = new Holder < List < V1Property > > ( ) ; Holder < List < V1ResetProperty > > v1ResetPropertyList = new Holder < List < V1ResetProperty > > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . getPortletProperties ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , names , v1PropertyList , v1ResetPropertyList , v1Extensions ) ; properties . value = WSRPUtils . transform ( v1PropertyList . value , V1ToV2Converter . PROPERTY ) ; resetProperties . value = WSRPUtils . transform ( v1ResetPropertyList . value , V1ToV2Converter . RESETPROPERTY ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied v1AccessDenied ) { WSRPExceptionFactory . throwWSException ( AccessDenied . class , v1AccessDenied . getMessage ( ) , v1AccessDenied ) ; } catch ( V1InconsistentParameters v1InconsistentParameters ) { WSRPExceptionFactory . throwWSException ( InconsistentParameters . class , v1InconsistentParameters . getMessage ( ) , v1InconsistentParameters ) ; } catch ( V1InvalidHandle v1InvalidHandle ) { WSRPExceptionFactory . throwWSException ( InvalidHandle . class , v1InvalidHandle . getMessage ( ) , v1InvalidHandle ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { WSRPExceptionFactory . throwWSException ( InvalidRegistration . class , v1InvalidRegistration . getMessage ( ) , v1InvalidRegistration ) ; } catch ( V1InvalidUserCategory v1InvalidUserCategory ) { WSRPExceptionFactory . throwWSException ( InvalidUserCategory . class , v1InvalidUserCategory . getMessage ( ) , v1InvalidUserCategory ) ; } catch ( V1MissingParameters v1MissingParameters ) { WSRPExceptionFactory . throwWSException ( MissingParameters . class , v1MissingParameters . getMessage ( ) , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { WSRPExceptionFactory . throwWSException ( OperationFailed . class , v1OperationFailed . getMessage ( ) , v1OperationFailed ) ; } } @ Override public void getPortletPropertyDescription ( RegistrationContext registrationContext , PortletContext portletContext , UserContext userContext , List < String > desiredLocales , Holder < ModelDescription > modelDescription , Holder < ResourceList > resourceList , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidHandle , InvalidRegistration , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < V1ResourceList > v1ResourceListHolder = new Holder < V1ResourceList > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; Holder < V1ModelDescription > v1ModelDescription = new Holder < V1ModelDescription > ( ) ; service . getPortletPropertyDescription ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , desiredLocales , v1ModelDescription , v1ResourceListHolder , v1Extensions ) ; modelDescription . value = V1ToV2Converter . toV2ModelDescription ( v1ModelDescription . value ) ; resourceList . value = V1ToV2Converter . toV2ResourceList ( v1ResourceListHolder . value ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied v1AccessDenied ) { WSRPExceptionFactory . throwWSException ( AccessDenied . class , v1AccessDenied . getMessage ( ) , v1AccessDenied ) ; } catch ( V1InconsistentParameters v1InconsistentParameters ) { WSRPExceptionFactory . throwWSException ( InconsistentParameters . class , v1InconsistentParameters . getMessage ( ) , v1InconsistentParameters ) ; } catch ( V1InvalidHandle v1InvalidHandle ) { WSRPExceptionFactory . throwWSException ( InvalidHandle . class , v1InvalidHandle . getMessage ( ) , v1InvalidHandle ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { WSRPExceptionFactory . throwWSException ( InvalidRegistration . class , v1InvalidRegistration . getMessage ( ) , v1InvalidRegistration ) ; } catch ( V1InvalidUserCategory v1InvalidUserCategory ) { WSRPExceptionFactory . throwWSException ( InvalidUserCategory . class , v1InvalidUserCategory . getMessage ( ) , v1InvalidUserCategory ) ; } catch ( V1MissingParameters v1MissingParameters ) { WSRPExceptionFactory . throwWSException ( MissingParameters . class , v1MissingParameters . getMessage ( ) , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { WSRPExceptionFactory . throwWSException ( OperationFailed . class , v1OperationFailed . getMessage ( ) , v1OperationFailed ) ; } } } </s>
|
<s> package org . gatein . wsrp . services . v1 ; import org . gatein . wsrp . WSRPExceptionFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . services . RegistrationService ; import org . gatein . wsrp . spec . v1 . V1ToV2Converter ; import org . gatein . wsrp . spec . v1 . V2ToV1Converter ; import org . oasis . wsrp . v1 . V1Extension ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1MissingParameters ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . WSRPV1RegistrationPortType ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . GetRegistrationLifetime ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . Lifetime ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . RegistrationData ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . SetRegistrationLifetime ; import org . oasis . wsrp . v2 . UserContext ; import javax . xml . ws . Holder ; import java . util . List ; public class V1RegistrationService extends RegistrationService < WSRPV1RegistrationPortType > { public V1RegistrationService ( WSRPV1RegistrationPortType service ) { super ( service ) ; } @ Override public void register ( RegistrationData registrationData , Lifetime lifetime , UserContext userContext , Holder < byte [ ] > registrationState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions , Holder < String > registrationHandle ) throws MissingParameters , OperationFailed , OperationNotSupported { try { Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . register ( registrationData . getConsumerName ( ) , registrationData . getConsumerAgent ( ) , registrationData . isMethodGetSupported ( ) , registrationData . getConsumerModes ( ) , registrationData . getConsumerWindowStates ( ) , registrationData . getConsumerUserScopes ( ) , null , WSRPUtils . transform ( registrationData . getRegistrationProperties ( ) , V2ToV1Converter . PROPERTY ) , new Holder < List < V1Extension > > ( ) , registrationHandle , registrationState ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1MissingParameters v1MissingParameters ) { throw V1ToV2Converter . toV2Exception ( MissingParameters . class , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , v1OperationFailed ) ; } } @ Override public List < Extension > deregister ( RegistrationContext registrationContext , UserContext userContext ) throws InvalidRegistration , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . deregister ( registrationContext . getRegistrationHandle ( ) , registrationContext . getRegistrationState ( ) , v1Extensions ) ; return WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , v1InvalidRegistration ) ; } catch ( V1OperationFailed v1OperationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , v1OperationFailed ) ; } } @ Override public void modifyRegistration ( RegistrationContext registrationContext , RegistrationData registrationData , UserContext userContext , Holder < byte [ ] > registrationState , Holder < Lifetime > scheduledDestruction , Holder < List < Extension > > extensions ) throws InvalidRegistration , MissingParameters , OperationFailed , OperationNotSupported , ResourceSuspended { try { Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . modifyRegistration ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1RegistrationData ( registrationData ) , registrationState , v1Extensions ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , v1InvalidRegistration ) ; } catch ( V1MissingParameters v1MissingParameters ) { throw V1ToV2Converter . toV2Exception ( MissingParameters . class , v1MissingParameters ) ; } catch ( V1OperationFailed v1OperationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , v1OperationFailed ) ; } } @ Override public Lifetime getRegistrationLifetime ( GetRegistrationLifetime getRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { throw WSRPExceptionFactory . createWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } @ Override public Lifetime setRegistrationLifetime ( SetRegistrationLifetime setRegistrationLifetime ) throws AccessDenied , InvalidHandle , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { throw WSRPExceptionFactory . createWSException ( OperationNotSupported . class , "<STR_LIT>" , null ) ; } } </s>
|
<s> package org . gatein . wsrp . services . v1 ; import org . gatein . wsrp . WSRPExceptionFactory ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . services . MarkupService ; 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 ; import org . oasis . wsrp . v1 . V1InvalidCookie ; import org . oasis . wsrp . v1 . V1InvalidHandle ; import org . oasis . wsrp . v1 . V1InvalidRegistration ; import org . oasis . wsrp . v1 . V1InvalidSession ; import org . oasis . wsrp . v1 . V1InvalidUserCategory ; import org . oasis . wsrp . v1 . V1MarkupContext ; import org . oasis . wsrp . v1 . V1MissingParameters ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1PortletStateChangeRequired ; import org . oasis . wsrp . v1 . V1SessionContext ; import org . oasis . wsrp . v1 . V1UnsupportedLocale ; import org . oasis . wsrp . v1 . V1UnsupportedMimeType ; import org . oasis . wsrp . v1 . V1UnsupportedMode ; import org . oasis . wsrp . v1 . V1UnsupportedWindowState ; import org . oasis . wsrp . v1 . V1UpdateResponse ; import org . oasis . wsrp . v1 . WSRPV1MarkupPortType ; import org . oasis . wsrp . v2 . AccessDenied ; import org . oasis . wsrp . v2 . EventParams ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . HandleEventsFailed ; import org . oasis . wsrp . v2 . InconsistentParameters ; import org . oasis . wsrp . v2 . InteractionParams ; import org . oasis . wsrp . v2 . InvalidCookie ; import org . oasis . wsrp . v2 . InvalidHandle ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . InvalidSession ; import org . oasis . wsrp . v2 . InvalidUserCategory ; import org . oasis . wsrp . v2 . MarkupContext ; import org . oasis . wsrp . v2 . MarkupParams ; import org . oasis . wsrp . v2 . MissingParameters ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . OperationNotSupported ; import org . oasis . wsrp . v2 . PortletContext ; import org . oasis . wsrp . v2 . PortletStateChangeRequired ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceContext ; import org . oasis . wsrp . v2 . ResourceParams ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . RuntimeContext ; import org . oasis . wsrp . v2 . SessionContext ; import org . oasis . wsrp . v2 . UnsupportedLocale ; import org . oasis . wsrp . v2 . UnsupportedMimeType ; import org . oasis . wsrp . v2 . UnsupportedMode ; import org . oasis . wsrp . v2 . UnsupportedWindowState ; import org . oasis . wsrp . v2 . UpdateResponse ; import org . oasis . wsrp . v2 . UserContext ; import javax . xml . ws . Holder ; import java . util . List ; public class V1MarkupService extends MarkupService < WSRPV1MarkupPortType > { public V1MarkupService ( WSRPV1MarkupPortType port ) { super ( port ) ; } @ Override public void getMarkup ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , Holder < MarkupContext > markupContext , Holder < SessionContext > sessionContext , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { try { Holder < V1MarkupContext > v1MarkupContext = new Holder < V1MarkupContext > ( ) ; Holder < V1SessionContext > v1SessionContext = new Holder < V1SessionContext > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . getMarkup ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1RuntimeContext ( runtimeContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , V2ToV1Converter . toV1MarkupParams ( markupParams ) , v1MarkupContext , v1SessionContext , v1Extensions ) ; markupContext . value = V1ToV2Converter . toV2MarkupContext ( v1MarkupContext . value ) ; sessionContext . value = V1ToV2Converter . toV2SessionContext ( v1SessionContext . value ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied accessDenied ) { throw V1ToV2Converter . toV2Exception ( AccessDenied . class , accessDenied ) ; } catch ( V1InconsistentParameters inconsistentParameters ) { throw V1ToV2Converter . toV2Exception ( InconsistentParameters . class , inconsistentParameters ) ; } catch ( V1InvalidCookie invalidCookie ) { throw V1ToV2Converter . toV2Exception ( InvalidCookie . class , invalidCookie ) ; } catch ( V1InvalidHandle invalidHandle ) { throw V1ToV2Converter . toV2Exception ( InvalidHandle . class , invalidHandle ) ; } catch ( V1InvalidRegistration invalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , invalidRegistration ) ; } catch ( V1InvalidSession invalidSession ) { throw V1ToV2Converter . toV2Exception ( InvalidSession . class , invalidSession ) ; } catch ( V1InvalidUserCategory invalidUserCategory ) { throw V1ToV2Converter . toV2Exception ( InvalidUserCategory . class , invalidUserCategory ) ; } catch ( V1MissingParameters missingParameter ) { throw V1ToV2Converter . toV2Exception ( MissingParameters . class , missingParameter ) ; } catch ( V1OperationFailed operationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , operationFailed ) ; } catch ( V1UnsupportedLocale unsupportedLocale ) { throw V1ToV2Converter . toV2Exception ( UnsupportedLocale . class , unsupportedLocale ) ; } catch ( V1UnsupportedMimeType unsupportedMimeType ) { throw V1ToV2Converter . toV2Exception ( UnsupportedMimeType . class , unsupportedMimeType ) ; } catch ( V1UnsupportedMode unsupportedMode ) { throw V1ToV2Converter . toV2Exception ( UnsupportedMode . class , unsupportedMode ) ; } catch ( V1UnsupportedWindowState unsupportedWindowState ) { throw V1ToV2Converter . toV2Exception ( UnsupportedWindowState . class , unsupportedWindowState ) ; } } @ Override public void getResource ( RegistrationContext registrationContext , Holder < PortletContext > portletContext , RuntimeContext runtimeContext , UserContext userContext , ResourceParams resourceParams , Holder < ResourceContext > resourceContext , Holder < SessionContext > sessionContext , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { throw WSRPExceptionFactory . createWSException ( UnsupportedOperationException . class , "<STR_LIT>" , null ) ; } @ Override public void performBlockingInteraction ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , InteractionParams interactionParams , Holder < UpdateResponse > updateResponse , Holder < String > redirectURL , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { try { Holder < V1UpdateResponse > v1UpdateResponse = new Holder < V1UpdateResponse > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . performBlockingInteraction ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , V2ToV1Converter . toV1PortletContext ( portletContext ) , V2ToV1Converter . toV1RuntimeContext ( runtimeContext ) , V2ToV1Converter . toV1UserContext ( userContext ) , V2ToV1Converter . toV1MarkupParams ( markupParams ) , V2ToV1Converter . toV1InteractionParams ( interactionParams ) , v1UpdateResponse , redirectURL , v1Extensions ) ; updateResponse . value = V1ToV2Converter . toV2UpdateResponse ( v1UpdateResponse . value ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied accessDenied ) { throw V1ToV2Converter . toV2Exception ( AccessDenied . class , accessDenied ) ; } catch ( V1InconsistentParameters inconsistentParameters ) { throw V1ToV2Converter . toV2Exception ( InconsistentParameters . class , inconsistentParameters ) ; } catch ( V1InvalidCookie invalidCookie ) { throw V1ToV2Converter . toV2Exception ( InvalidCookie . class , invalidCookie ) ; } catch ( V1InvalidHandle invalidHandle ) { throw V1ToV2Converter . toV2Exception ( InvalidHandle . class , invalidHandle ) ; } catch ( V1InvalidRegistration invalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , invalidRegistration ) ; } catch ( V1InvalidSession invalidSession ) { throw V1ToV2Converter . toV2Exception ( InvalidSession . class , invalidSession ) ; } catch ( V1InvalidUserCategory invalidUserCategory ) { throw V1ToV2Converter . toV2Exception ( InvalidUserCategory . class , invalidUserCategory ) ; } catch ( V1MissingParameters missingParameters ) { throw V1ToV2Converter . toV2Exception ( MissingParameters . class , missingParameters ) ; } catch ( V1OperationFailed operationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , operationFailed ) ; } catch ( V1PortletStateChangeRequired portletStateChangeRequired ) { throw V1ToV2Converter . toV2Exception ( PortletStateChangeRequired . class , portletStateChangeRequired ) ; } catch ( V1UnsupportedLocale unsupportedLocale ) { throw V1ToV2Converter . toV2Exception ( UnsupportedLocale . class , unsupportedLocale ) ; } catch ( V1UnsupportedMimeType unsupportedMimeType ) { throw V1ToV2Converter . toV2Exception ( UnsupportedMimeType . class , unsupportedMimeType ) ; } catch ( V1UnsupportedMode unsupportedMode ) { throw V1ToV2Converter . toV2Exception ( UnsupportedMode . class , unsupportedMode ) ; } catch ( V1UnsupportedWindowState unsupportedWindowState ) { throw V1ToV2Converter . toV2Exception ( UnsupportedWindowState . class , unsupportedWindowState ) ; } } @ Override public void handleEvents ( RegistrationContext registrationContext , PortletContext portletContext , RuntimeContext runtimeContext , UserContext userContext , MarkupParams markupParams , EventParams eventParams , Holder < UpdateResponse > updateResponse , Holder < List < HandleEventsFailed > > failedEvents , Holder < List < Extension > > extensions ) throws AccessDenied , InconsistentParameters , InvalidCookie , InvalidHandle , InvalidRegistration , InvalidSession , InvalidUserCategory , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , PortletStateChangeRequired , ResourceSuspended , UnsupportedLocale , UnsupportedMimeType , UnsupportedMode , UnsupportedWindowState { throw WSRPExceptionFactory . createWSException ( UnsupportedOperationException . class , "<STR_LIT>" , null ) ; } @ Override public List < Extension > releaseSessions ( RegistrationContext registrationContext , List < String > sessionIDs , UserContext userContext ) throws AccessDenied , InvalidRegistration , MissingParameters , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { return WSRPUtils . transform ( service . releaseSessions ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) , sessionIDs ) , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied accessDenied ) { throw V1ToV2Converter . toV2Exception ( AccessDenied . class , accessDenied ) ; } catch ( V1InvalidRegistration invalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , invalidRegistration ) ; } catch ( V1MissingParameters missingParameters ) { throw V1ToV2Converter . toV2Exception ( MissingParameters . class , missingParameters ) ; } catch ( V1OperationFailed operationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , operationFailed ) ; } } @ Override public List < Extension > initCookie ( RegistrationContext registrationContext , UserContext userContext ) throws AccessDenied , InvalidRegistration , ModifyRegistrationRequired , OperationFailed , OperationNotSupported , ResourceSuspended { try { return WSRPUtils . transform ( service . initCookie ( V2ToV1Converter . toV1RegistrationContext ( registrationContext ) ) , V1ToV2Converter . EXTENSION ) ; } catch ( V1AccessDenied accessDenied ) { throw V1ToV2Converter . toV2Exception ( AccessDenied . class , accessDenied ) ; } catch ( V1InvalidRegistration invalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , invalidRegistration ) ; } catch ( V1OperationFailed operationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , operationFailed ) ; } } } </s>
|
<s> package org . gatein . wsrp . services . v1 ; import org . gatein . wsrp . WSRPUtils ; import org . gatein . wsrp . services . ServiceDescriptionService ; 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 ; import org . oasis . wsrp . v1 . V1ItemDescription ; import org . oasis . wsrp . v1 . V1ModelDescription ; import org . oasis . wsrp . v1 . V1OperationFailed ; import org . oasis . wsrp . v1 . V1PortletDescription ; import org . oasis . wsrp . v1 . V1RegistrationContext ; import org . oasis . wsrp . v1 . V1ResourceList ; import org . oasis . wsrp . v1 . WSRPV1ServiceDescriptionPortType ; import org . oasis . wsrp . v2 . CookieProtocol ; import org . oasis . wsrp . v2 . EventDescription ; import org . oasis . wsrp . v2 . ExportDescription ; import org . oasis . wsrp . v2 . Extension ; import org . oasis . wsrp . v2 . ExtensionDescription ; import org . oasis . wsrp . v2 . InvalidRegistration ; import org . oasis . wsrp . v2 . ItemDescription ; import org . oasis . wsrp . v2 . ModelDescription ; import org . oasis . wsrp . v2 . ModelTypes ; import org . oasis . wsrp . v2 . ModifyRegistrationRequired ; import org . oasis . wsrp . v2 . OperationFailed ; import org . oasis . wsrp . v2 . PortletDescription ; import org . oasis . wsrp . v2 . RegistrationContext ; import org . oasis . wsrp . v2 . ResourceList ; import org . oasis . wsrp . v2 . ResourceSuspended ; import org . oasis . wsrp . v2 . UserContext ; import javax . xml . ws . Holder ; import java . util . List ; public class V1ServiceDescriptionService extends ServiceDescriptionService < WSRPV1ServiceDescriptionPortType > { public V1ServiceDescriptionService ( WSRPV1ServiceDescriptionPortType port ) { super ( port ) ; } @ Override public void getServiceDescription ( RegistrationContext registrationContext , List < String > desiredLocales , List < String > portletHandles , UserContext userContext , Holder < Boolean > requiresRegistration , Holder < List < PortletDescription > > offeredPortlets , Holder < List < ItemDescription > > userCategoryDescriptions , Holder < List < ExtensionDescription > > extensionDescriptions , Holder < List < ItemDescription > > customWindowStateDescriptions , Holder < List < ItemDescription > > customModeDescriptions , Holder < CookieProtocol > requiresInitCookie , Holder < ModelDescription > registrationPropertyDescription , Holder < List < String > > locales , Holder < ResourceList > resourceList , Holder < List < EventDescription > > eventDescriptions , Holder < ModelTypes > schemaType , Holder < List < String > > supportedOptions , Holder < ExportDescription > exportDescription , Holder < Boolean > mayReturnRegistrationState , Holder < List < Extension > > extensions ) throws InvalidRegistration , ModifyRegistrationRequired , OperationFailed , ResourceSuspended { try { V1RegistrationContext v1RegistrationContext = V2ToV1Converter . toV1RegistrationContext ( registrationContext ) ; Holder < List < V1PortletDescription > > v1OfferedPortlets = new Holder < List < V1PortletDescription > > ( ) ; Holder < List < V1ItemDescription > > v1UserCategories = new Holder < List < V1ItemDescription > > ( ) ; Holder < List < V1ItemDescription > > v1ProfileITems = new Holder < List < V1ItemDescription > > ( ) ; Holder < List < V1ItemDescription > > v1WindowStates = new Holder < List < V1ItemDescription > > ( ) ; Holder < List < V1ItemDescription > > v1Modes = new Holder < List < V1ItemDescription > > ( ) ; Holder < V1CookieProtocol > v1Cookie = new Holder < V1CookieProtocol > ( ) ; Holder < V1ModelDescription > v1RegistrationProperties = new Holder < V1ModelDescription > ( ) ; Holder < V1ResourceList > v1Resources = new Holder < V1ResourceList > ( ) ; Holder < List < V1Extension > > v1Extensions = new Holder < List < V1Extension > > ( ) ; service . getServiceDescription ( v1RegistrationContext , desiredLocales , requiresRegistration , v1OfferedPortlets , v1UserCategories , v1ProfileITems , v1WindowStates , v1Modes , v1Cookie , v1RegistrationProperties , locales , v1Resources , v1Extensions ) ; offeredPortlets . value = WSRPUtils . transform ( v1OfferedPortlets . value , V1ToV2Converter . PORTLETDESCRIPTION ) ; userCategoryDescriptions . value = WSRPUtils . transform ( v1UserCategories . value , V1ToV2Converter . ITEMDESCRIPTION ) ; customWindowStateDescriptions . value = WSRPUtils . transform ( v1WindowStates . value , V1ToV2Converter . ITEMDESCRIPTION ) ; customModeDescriptions . value = WSRPUtils . transform ( v1Modes . value , V1ToV2Converter . ITEMDESCRIPTION ) ; requiresInitCookie . value = V1ToV2Converter . toV2CookieProtocol ( v1Cookie . value ) ; registrationPropertyDescription . value = V1ToV2Converter . toV2ModelDescription ( v1RegistrationProperties . value ) ; resourceList . value = V1ToV2Converter . toV2ResourceList ( v1Resources . value ) ; extensions . value = WSRPUtils . transform ( v1Extensions . value , V1ToV2Converter . EXTENSION ) ; } catch ( V1InvalidRegistration v1InvalidRegistration ) { throw V1ToV2Converter . toV2Exception ( InvalidRegistration . class , v1InvalidRegistration ) ; } catch ( V1OperationFailed v1OperationFailed ) { throw V1ToV2Converter . toV2Exception ( OperationFailed . class , v1OperationFailed ) ; } } } </s>
|
<s> package org . gatein . wsrp . services ; public class WSRPService < T > { protected T service ; public WSRPService ( T service ) { this . service = service ; } } </s>
|
<s> package org . gatein . wsrp . services ; import org . gatein . common . util . Version ; public interface ServiceFactory { int DEFAULT_TIMEOUT_MS = <NUM_LIT> ; Version WSRP2 = new Version ( "<STR_LIT>" , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> , new Version . Qualifier ( Version . Qualifier . Prefix . GA ) , "<STR_LIT>" ) ; Version WSRP1 = new Version ( "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , new Version . Qualifier ( Version . Qualifier . Prefix . GA ) , "<STR_LIT>" ) ; < T > T getService ( Class < T > clazz ) throws Exception ; boolean isAvailable ( ) ; boolean isFailed ( ) ; void start ( ) throws Exception ; void stop ( ) ; void setWsdlDefinitionURL ( String wsdlDefinitionURL ) ; String getWsdlDefinitionURL ( ) ; void setWSOperationTimeOut ( int msBeforeTimeOut ) ; int getWSOperationTimeOut ( ) ; ServiceDescriptionService getServiceDescriptionService ( ) throws Exception ; MarkupService getMarkupService ( ) throws Exception ; PortletManagementService getPortletManagementService ( ) throws Exception ; RegistrationService getRegistrationService ( ) throws Exception ; Version getWSRPVersion ( ) ; boolean refresh ( boolean force ) throws Exception ; void enableWSS ( boolean enable ) ; boolean isWSSEnabled ( ) ; boolean isWSSAvailable ( ) ; } </s>
|
<s> package org . gatein . wsrp . handler ; import org . apache . commons . httpclient . Cookie ; import org . gatein . wsrp . consumer . handlers . ProducerSessionInformation ; import javax . xml . namespace . QName ; import javax . xml . soap . MimeHeaders ; import javax . xml . soap . SOAPMessage ; import javax . xml . ws . BindingProvider ; import javax . xml . ws . handler . MessageContext ; import javax . xml . ws . handler . soap . SOAPHandler ; import javax . xml . ws . handler . soap . SOAPMessageContext ; import java . net . MalformedURLException ; import java . net . URL ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Set ; public class RequestHeaderClientHandler implements SOAPHandler < SOAPMessageContext > { private static final ThreadLocal < CurrentInfo > local = new ThreadLocal < CurrentInfo > ( ) ; private static final String EMPTY = "<STR_LIT>" ; public Set < QName > getHeaders ( ) { return null ; } public boolean handleMessage ( SOAPMessageContext soapMessageContext ) { if ( Boolean . TRUE . equals ( soapMessageContext . get ( MessageContext . MESSAGE_OUTBOUND_PROPERTY ) ) ) { return handleRequest ( soapMessageContext ) ; } else { return handleResponse ( soapMessageContext ) ; } } public boolean handleFault ( SOAPMessageContext soapMessageContext ) { return true ; } public void close ( MessageContext messageContext ) { } public boolean handleRequest ( SOAPMessageContext msgContext ) { CurrentInfo info = getCurrentInfo ( false ) ; if ( info == null ) { return true ; } ProducerSessionInformation sessionInfo = info . sessionInfo ; if ( sessionInfo == null ) { return true ; } SOAPMessage message = msgContext . getMessage ( ) ; String cookie = createCookie ( info , sessionInfo ) ; if ( cookie . length ( ) != <NUM_LIT:0> ) { MimeHeaders mimeHeaders = message . getMimeHeaders ( ) ; mimeHeaders . setHeader ( CookieUtil . COOKIE , cookie ) ; Map < String , List < String > > httpHeaders = new HashMap < String , List < String > > ( ) ; httpHeaders . put ( CookieUtil . COOKIE , Collections . singletonList ( cookie ) ) ; msgContext . put ( MessageContext . HTTP_REQUEST_HEADERS , httpHeaders ) ; } return true ; } public static String createCookie ( ProducerSessionInformation sessionInformation ) { CurrentInfo currentInfo = getCurrentInfo ( false ) ; if ( currentInfo != null ) { return createCookie ( currentInfo , sessionInformation ) ; } else { return EMPTY ; } } private static String createCookie ( CurrentInfo info , ProducerSessionInformation sessionInfo ) { StringBuilder cookie = new StringBuilder ( <NUM_LIT> ) ; if ( sessionInfo . isPerGroupCookies ( ) ) { if ( info . groupId == null ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } String groupCookie = sessionInfo . getGroupCookieFor ( info . groupId ) ; if ( groupCookie != null ) { cookie . append ( groupCookie ) ; } } String userCookie = sessionInfo . getUserCookie ( ) ; if ( userCookie != null ) { if ( cookie . length ( ) != <NUM_LIT:0> ) { cookie . append ( '<CHAR_LIT:U+002C>' ) ; } cookie . append ( userCookie ) ; } return cookie . toString ( ) ; } public boolean handleResponse ( MessageContext msgContext ) { SOAPMessageContext smc = ( SOAPMessageContext ) msgContext ; SOAPMessage message = smc . getMessage ( ) ; MimeHeaders mimeHeaders = message . getMimeHeaders ( ) ; String [ ] cookieValues = mimeHeaders . getHeader ( CookieUtil . SET_COOKIE ) ; if ( cookieValues == null ) { @ SuppressWarnings ( "<STR_LIT:unchecked>" ) Map < String , List < String > > httpHeaders = ( Map < String , List < String > > ) smc . get ( MessageContext . HTTP_RESPONSE_HEADERS ) ; List < String > l = httpHeaders . get ( CookieUtil . SET_COOKIE ) ; if ( l != null && ! l . isEmpty ( ) ) { cookieValues = l . toArray ( new String [ l . size ( ) ] ) ; } } String endpointAddress = ( String ) msgContext . get ( BindingProvider . ENDPOINT_ADDRESS_PROPERTY ) ; if ( cookieValues != null ) { if ( endpointAddress == null ) { throw new NullPointerException ( "<STR_LIT>" ) ; } URL hostURL ; try { hostURL = new URL ( endpointAddress ) ; } catch ( MalformedURLException e ) { throw new IllegalArgumentException ( endpointAddress + "<STR_LIT>" ) ; } final Cookie [ ] cookies = CookieUtil . extractCookiesFrom ( hostURL , cookieValues ) ; CurrentInfo info = getCurrentInfo ( true ) ; ProducerSessionInformation sessionInfo = info . sessionInfo ; if ( sessionInfo . isPerGroupCookies ( ) ) { if ( info . groupId == null ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } sessionInfo . setGroupCookieFor ( info . groupId , cookies ) ; } else { sessionInfo . setUserCookie ( cookies ) ; } } return true ; } public static void setCurrentInfo ( String groupId , ProducerSessionInformation sessionInformation ) { local . set ( new CurrentInfo ( groupId , sessionInformation ) ) ; } public static void resetCurrentInfo ( ) { local . set ( null ) ; } public static ProducerSessionInformation getCurrentProducerSessionInformation ( ) { CurrentInfo info = getCurrentInfo ( false ) ; if ( info != null ) { return info . sessionInfo ; } return null ; } public static String getCurrentGroupId ( ) { CurrentInfo info = getCurrentInfo ( false ) ; if ( info != null ) { return info . groupId ; } return null ; } public static void setCurrentGroupId ( String groupId ) { CurrentInfo currentInfo = local . get ( ) ; if ( currentInfo == null ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } currentInfo . groupId = groupId ; } private static CurrentInfo getCurrentInfo ( boolean createIfNeeded ) { CurrentInfo info = local . get ( ) ; if ( info == null && createIfNeeded ) { info = new CurrentInfo ( null , new ProducerSessionInformation ( ) ) ; local . set ( info ) ; } return info ; } static class CurrentInfo { public CurrentInfo ( String groupId , ProducerSessionInformation sessionInfo ) { this . groupId = groupId ; this . sessionInfo = sessionInfo ; } String groupId ; ProducerSessionInformation sessionInfo ; } } </s>
|
<s> package org . gatein . wsrp . handler ; import org . apache . commons . httpclient . Cookie ; import org . apache . commons . httpclient . cookie . MalformedCookieException ; import org . apache . commons . httpclient . cookie . RFC2109Spec ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import java . net . URL ; import java . util . Date ; public class CookieUtil { private static final RFC2109Spec cookieParser = new RFC2109Spec ( ) ; private static final Logger log = LoggerFactory . getLogger ( CookieUtil . class ) ; public static final String SET_COOKIE = "<STR_LIT>" ; public static final String COOKIE = "<STR_LIT>" ; public static Cookie [ ] extractCookiesFrom ( URL remoteAddress , String [ ] cookieValues ) { return extractCookies ( remoteAddress , coalesceCookies ( cookieValues ) ) ; } private static String coalesceCookies ( String [ ] cookieValues ) { assert cookieValues != null ; StringBuffer logBuffer = null ; if ( log . isDebugEnabled ( ) ) { logBuffer = new StringBuffer ( <NUM_LIT> ) ; logBuffer . append ( "<STR_LIT>" ) ; } int cookieNumber = cookieValues . length ; StringBuffer cookieBuffer = new StringBuffer ( cookieNumber * <NUM_LIT> ) ; String cookieValue ; for ( int i = <NUM_LIT:0> ; i < cookieNumber ; i ++ ) { cookieValue = cookieValues [ i ] ; cookieBuffer . append ( cookieValue ) ; if ( i < cookieNumber - <NUM_LIT:1> ) { cookieBuffer . append ( '<CHAR_LIT:U+002C>' ) ; } if ( log . isDebugEnabled ( ) ) { logBuffer . append ( "<STR_LIT:t>" ) . append ( i ) . append ( "<STR_LIT>" ) . append ( cookieValue ) . append ( "<STR_LIT:n>" ) ; } } if ( log . isDebugEnabled ( ) ) { log . debug ( logBuffer . toString ( ) ) ; } return cookieBuffer . toString ( ) ; } private static Cookie [ ] extractCookies ( URL hostURL , String cookieValue ) { Cookie [ ] cookies ; try { String host = hostURL . getHost ( ) ; int port = hostURL . getPort ( ) ; if ( port == - <NUM_LIT:1> ) { port = <NUM_LIT> ; } String path = hostURL . getPath ( ) ; boolean secure = hostURL . getProtocol ( ) . endsWith ( "<STR_LIT:s>" ) ; cookies = cookieParser . parse ( host , port , path , secure , cookieValue ) ; for ( Cookie cookie : cookies ) { cookieParser . validate ( host , port , path , secure , cookie ) ; } } catch ( MalformedCookieException e ) { throw new IllegalArgumentException ( "<STR_LIT>" + cookieValue ) ; } return cookies ; } public static javax . servlet . http . Cookie convertFrom ( Cookie cookie ) { if ( cookie == null ) { return null ; } javax . servlet . http . Cookie result = new javax . servlet . http . Cookie ( cookie . getName ( ) , cookie . getValue ( ) ) ; result . setComment ( cookie . getComment ( ) ) ; result . setDomain ( cookie . getDomain ( ) ) ; Date expiryDate = cookie . getExpiryDate ( ) ; int maxAge ; if ( expiryDate != null ) { long maxAgeLong = expiryDate . getTime ( ) - new Date ( ) . getTime ( ) ; if ( maxAgeLong >= Integer . MAX_VALUE ) { maxAge = Integer . MAX_VALUE ; } else { maxAge = ( int ) maxAgeLong ; } } else { maxAge = - <NUM_LIT:1> ; } result . setMaxAge ( maxAge ) ; result . setPath ( cookie . getPath ( ) ) ; result . setSecure ( cookie . getSecure ( ) ) ; result . setVersion ( cookie . getVersion ( ) ) ; return result ; } } </s>
|
<s> package org . gatein . wsrp ; import org . gatein . pc . api . PortletInvoker ; import org . gatein . pc . api . PortletInvokerException ; import org . gatein . pc . api . invocation . PortletInvocation ; import org . gatein . wsrp . api . session . SessionEventListener ; import org . gatein . wsrp . consumer . ProducerInfo ; import org . gatein . wsrp . consumer . RefreshResult ; import org . gatein . wsrp . consumer . handlers . ProducerSessionInformation ; import org . gatein . wsrp . consumer . migration . ExportInfo ; import org . gatein . wsrp . consumer . migration . ImportInfo ; import org . gatein . wsrp . consumer . migration . MigrationService ; import javax . servlet . http . HttpSession ; import java . util . List ; public interface WSRPConsumer extends PortletInvoker , SessionEventListener { String getProducerId ( ) ; ProducerSessionInformation getProducerSessionInformationFrom ( PortletInvocation invocation ) ; ProducerSessionInformation getProducerSessionInformationFrom ( HttpSession session ) ; ProducerInfo getProducerInfo ( ) ; void refreshProducerInfo ( ) throws PortletInvokerException ; void releaseSessions ( ) throws PortletInvokerException ; void activate ( ) throws Exception ; void deactivate ( ) throws Exception ; boolean isRefreshNeeded ( ) ; RefreshResult refresh ( boolean forceRefresh ) throws PortletInvokerException ; void start ( ) throws Exception ; void stop ( ) throws Exception ; ExportInfo exportPortlets ( List < String > portletHandles ) throws PortletInvokerException ; void releaseExport ( ExportInfo exportInfo ) throws PortletInvokerException ; MigrationService getMigrationService ( ) ; boolean isImportExportSupported ( ) ; ImportInfo importPortlets ( ExportInfo exportInfo , List < String > portlets ) throws PortletInvokerException ; boolean isUsingWSRP2 ( ) ; } </s>
|
<s> package org . gatein . wsrp . handler ; import junit . framework . TestCase ; import org . apache . commons . httpclient . Cookie ; import org . gatein . wsrp . consumer . handlers . ProducerSessionInformation ; import org . gatein . wsrp . test . handler . MockSOAPMessage ; import org . gatein . wsrp . test . handler . MockSOAPMessageContext ; import javax . xml . soap . MimeHeaders ; import javax . xml . ws . handler . MessageContext ; import javax . xml . ws . handler . soap . SOAPMessageContext ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class RequestHeaderClientHandlerTestCase extends TestCase { RequestHeaderClientHandler handler ; protected void setUp ( ) throws Exception { handler = new RequestHeaderClientHandler ( ) ; RequestHeaderClientHandler . resetCurrentInfo ( ) ; } public void testSimpleCookieHandleRequest ( ) { MockSOAPMessage message = new MockSOAPMessage ( ) ; SOAPMessageContext msgContext = MockSOAPMessageContext . createMessageContext ( message , getClass ( ) . getClassLoader ( ) ) ; handler . handleRequest ( msgContext ) ; checkCookies ( msgContext , <NUM_LIT:0> , ( String [ ] ) null ) ; ProducerSessionInformation sessionInformation = new ProducerSessionInformation ( ) ; sessionInformation . setUserCookie ( new Cookie [ ] { createCookie ( "<STR_LIT:name>" , "<STR_LIT:value>" , <NUM_LIT:1> ) } ) ; RequestHeaderClientHandler . setCurrentInfo ( null , sessionInformation ) ; handler . handleRequest ( msgContext ) ; checkCookies ( msgContext , <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testGroupCookieHandleRequest ( ) { MockSOAPMessage message = new MockSOAPMessage ( ) ; SOAPMessageContext msgContext = MockSOAPMessageContext . createMessageContext ( message , getClass ( ) . getClassLoader ( ) ) ; ProducerSessionInformation info = new ProducerSessionInformation ( ) ; info . setPerGroupCookies ( true ) ; String groupId = "<STR_LIT>" ; info . setGroupCookieFor ( groupId , new Cookie [ ] { createCookie ( "<STR_LIT:name>" , "<STR_LIT:value>" , <NUM_LIT:1> ) } ) ; RequestHeaderClientHandler . setCurrentInfo ( null , info ) ; try { handler . handleRequest ( msgContext ) ; fail ( "<STR_LIT>" ) ; } catch ( IllegalStateException e ) { } RequestHeaderClientHandler . setCurrentGroupId ( groupId ) ; handler . handleRequest ( msgContext ) ; checkCookies ( msgContext , <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testBothCookiesHandleRequest ( ) { MockSOAPMessage message = new MockSOAPMessage ( ) ; SOAPMessageContext msgContext = MockSOAPMessageContext . createMessageContext ( message , getClass ( ) . getClassLoader ( ) ) ; ProducerSessionInformation info = new ProducerSessionInformation ( ) ; info . setPerGroupCookies ( true ) ; String groupId = "<STR_LIT>" ; info . setGroupCookieFor ( groupId , new Cookie [ ] { createCookie ( "<STR_LIT:name>" , "<STR_LIT:value>" , <NUM_LIT:1> ) } ) ; info . setUserCookie ( new Cookie [ ] { createCookie ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) } ) ; RequestHeaderClientHandler . setCurrentInfo ( groupId , info ) ; handler . handleRequest ( msgContext ) ; checkCookies ( msgContext , <NUM_LIT:1> , "<STR_LIT>" ) ; } public void testCookieWithoutInitHandleResponse ( ) { MockSOAPMessage message = new MockSOAPMessage ( ) ; SOAPMessageContext msgContext = MockSOAPMessageContext . createMessageContext ( message , getClass ( ) . getClassLoader ( ) ) ; setCookies ( msgContext , "<STR_LIT>" ) ; handler . handleResponse ( msgContext ) ; ProducerSessionInformation info = RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ; assertEquals ( "<STR_LIT>" , info . getUserCookie ( ) ) ; assertFalse ( info . isInitCookieDone ( ) ) ; assertFalse ( info . isPerGroupCookies ( ) ) ; } public void testMultipleCookiesInResponse ( ) { MockSOAPMessage message = new MockSOAPMessage ( ) ; SOAPMessageContext msgContext = MockSOAPMessageContext . createMessageContext ( message , getClass ( ) . getClassLoader ( ) ) ; setCookies ( msgContext , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ; handler . handleResponse ( msgContext ) ; ProducerSessionInformation info = RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ; assertEquals ( "<STR_LIT>" , info . getUserCookie ( ) ) ; } public void testCurrentInfo ( ) { assertNull ( RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ) ; assertNull ( RequestHeaderClientHandler . getCurrentGroupId ( ) ) ; try { RequestHeaderClientHandler . setCurrentGroupId ( "<STR_LIT:foo>" ) ; fail ( "<STR_LIT>" ) ; } catch ( IllegalStateException e ) { } ProducerSessionInformation info = new ProducerSessionInformation ( ) ; String groupId = "<STR_LIT>" ; RequestHeaderClientHandler . setCurrentInfo ( groupId , info ) ; assertSame ( info , RequestHeaderClientHandler . getCurrentProducerSessionInformation ( ) ) ; assertEquals ( groupId , RequestHeaderClientHandler . getCurrentGroupId ( ) ) ; } private void setCookies ( SOAPMessageContext context , String ... values ) { Map < String , List < String > > httpHeaders = new HashMap < String , List < String > > ( ) ; final List < String > cookies = new ArrayList < String > ( values . length ) ; for ( String value : values ) { context . getMessage ( ) . getMimeHeaders ( ) . addHeader ( CookieUtil . SET_COOKIE , value ) ; cookies . add ( value ) ; } httpHeaders . put ( CookieUtil . COOKIE , cookies ) ; context . put ( MessageContext . HTTP_REQUEST_HEADERS , httpHeaders ) ; } private void checkCookies ( SOAPMessageContext messageContext , int number , String ... values ) { final MimeHeaders mimeHeaders = messageContext . getMessage ( ) . getMimeHeaders ( ) ; final String [ ] cookies = mimeHeaders . getHeader ( CookieUtil . COOKIE ) ; @ SuppressWarnings ( "<STR_LIT:unchecked>" ) Map < String , List < String > > httpHeaders = ( Map < String , List < String > > ) messageContext . get ( MessageContext . HTTP_REQUEST_HEADERS ) ; List < String > cookiesList = httpHeaders . get ( CookieUtil . COOKIE ) ; if ( number == <NUM_LIT:0> ) { assertNull ( cookies ) ; assertNull ( cookiesList ) ; } else { assertEquals ( number , cookies . length ) ; assertEquals ( number , cookiesList . size ( ) ) ; int i = <NUM_LIT:0> ; for ( String value : values ) { assertEquals ( value , cookies [ i ] ) ; assertEquals ( value , cookiesList . get ( i ) ) ; i ++ ; } } } private Cookie createCookie ( String name , String value , int secondsBeforeExpiration ) { return new Cookie ( "<STR_LIT>" , name , value , "<STR_LIT:path>" , secondsBeforeExpiration , false ) ; } } </s>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.