1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.wsrp4j.consumer.driver;
18  
19  import oasis.names.tc.wsrp.v1.intf.WSRP_v1_Markup_PortType;
20  import oasis.names.tc.wsrp.v1.intf.WSRP_v1_PortletManagement_PortType;
21  import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
22  import oasis.names.tc.wsrp.v1.types.ClientData;
23  import oasis.names.tc.wsrp.v1.types.ClonePortlet;
24  import oasis.names.tc.wsrp.v1.types.CookieProtocol;
25  import oasis.names.tc.wsrp.v1.types.DestroyPortlets;
26  import oasis.names.tc.wsrp.v1.types.DestroyPortletsResponse;
27  import oasis.names.tc.wsrp.v1.types.GetMarkup;
28  import oasis.names.tc.wsrp.v1.types.GetPortletDescription;
29  import oasis.names.tc.wsrp.v1.types.GetPortletProperties;
30  import oasis.names.tc.wsrp.v1.types.GetPortletPropertyDescription;
31  import oasis.names.tc.wsrp.v1.types.InitCookie;
32  import oasis.names.tc.wsrp.v1.types.InteractionParams;
33  import oasis.names.tc.wsrp.v1.types.InvalidCookieFault;
34  import oasis.names.tc.wsrp.v1.types.MarkupContext;
35  import oasis.names.tc.wsrp.v1.types.MarkupParams;
36  import oasis.names.tc.wsrp.v1.types.MarkupResponse;
37  import oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction;
38  import oasis.names.tc.wsrp.v1.types.PortletContext;
39  import oasis.names.tc.wsrp.v1.types.PortletDescription;
40  import oasis.names.tc.wsrp.v1.types.PortletDescriptionResponse;
41  import oasis.names.tc.wsrp.v1.types.PortletPropertyDescriptionResponse;
42  import oasis.names.tc.wsrp.v1.types.PropertyList;
43  import oasis.names.tc.wsrp.v1.types.RegistrationContext;
44  import oasis.names.tc.wsrp.v1.types.ReleaseSessions;
45  import oasis.names.tc.wsrp.v1.types.ReturnAny;
46  import oasis.names.tc.wsrp.v1.types.RuntimeContext;
47  import oasis.names.tc.wsrp.v1.types.ServiceDescription;
48  import oasis.names.tc.wsrp.v1.types.SetPortletProperties;
49  import oasis.names.tc.wsrp.v1.types.StateChange;
50  import oasis.names.tc.wsrp.v1.types.Templates;
51  import oasis.names.tc.wsrp.v1.types.UserContext;
52  
53  import org.apache.wsrp4j.consumer.ConsumerEnvironment;
54  import org.apache.wsrp4j.consumer.GroupSessionMgr;
55  import org.apache.wsrp4j.consumer.InteractionRequest;
56  import org.apache.wsrp4j.consumer.MarkupRequest;
57  import org.apache.wsrp4j.consumer.PortletDriver;
58  import org.apache.wsrp4j.consumer.Producer;
59  import org.apache.wsrp4j.consumer.URLRewriter;
60  import org.apache.wsrp4j.consumer.URLTemplateComposer;
61  import org.apache.wsrp4j.consumer.User;
62  import org.apache.wsrp4j.consumer.UserSessionMgr;
63  import org.apache.wsrp4j.consumer.WSRPBaseRequest;
64  import org.apache.wsrp4j.consumer.WSRPPortlet;
65  import org.apache.wsrp4j.exception.WSRPException;
66  import org.apache.wsrp4j.exception.WSRPXHelper;
67  import org.apache.wsrp4j.log.LogManager;
68  import org.apache.wsrp4j.log.Logger;
69  import org.apache.wsrp4j.util.Constants;
70  import org.apache.wsrp4j.util.ParameterChecker;
71  
72  /**
73   * This class implements a portlet driver
74   **/
75  public class PortletDriverImpl implements PortletDriver {
76  
77      private WSRPPortlet portlet = null;
78  
79      private WSRP_v1_Markup_PortType markupPort = null;
80  
81      private WSRP_v1_PortletManagement_PortType portletPort = null;
82  
83      private ConsumerEnvironment consumerEnv = null;
84  
85      private Producer producer = null;
86  
87      private ParameterChecker parameterChecker = null;
88  
89      private CookieProtocol initCookie = CookieProtocol.none;
90  
91      // the logger
92      private static final Logger logger = LogManager.getLogManager().getLogger(
93              PortletDriverImpl.class);
94  
95      public PortletDriverImpl(WSRPPortlet portlet,
96              ConsumerEnvironment consumerEnv) throws WSRPException {
97          parameterChecker = new ParameterChecker();
98  
99          this.consumerEnv = consumerEnv;
100         this.portlet = portlet;
101         this.producer = consumerEnv.getProducerRegistry().getProducer(
102                 portlet.getPortletKey().getProducerId());
103 
104         portletPort = producer.getPortletManagementInterface();
105 
106         ServiceDescription serviceDescription = producer
107                 .getServiceDescription(false);
108         if (serviceDescription != null) {
109             this.initCookie = serviceDescription.getRequiresInitCookie();
110             if (initCookie == null) {
111                 initCookie = CookieProtocol.none; // TODO - get from config
112             }
113         }
114     }
115 
116     /**
117      * Get the portlet this driver is bind to.
118      * 
119      * @return The enity
120      **/
121     public WSRPPortlet getPortlet() {
122         return this.portlet;
123     }
124 
125     private void resetInitCookie(String userID) throws WSRPException {
126 
127         UserSessionMgr userSession = this.consumerEnv.getSessionHandler()
128                 .getUserSession(getPortlet().getPortletKey().getProducerId(),
129                         userID);
130 
131         if (initCookie.getValue().equalsIgnoreCase(CookieProtocol._none)) {
132 
133             userSession.setInitCookieDone(false);
134 
135         }
136         else if (initCookie.getValue().equalsIgnoreCase(
137                 CookieProtocol._perGroup)) {
138 
139             PortletDescription portletDescription = null;
140             try {
141 
142                 portletDescription = producer
143                         .getPortletDescription(getPortlet().getParent());
144 
145             }
146             catch (WSRPException e) {
147 
148                 // do nothing since exception has been logged already
149 
150             }
151 
152             String groupID = null;
153             if (portletDescription != null) {
154                 groupID = portletDescription.getGroupID();
155             }
156 
157             if (groupID != null) {
158                 GroupSessionMgr groupSession = userSession
159                         .getGroupSession(groupID);
160                 groupSession.setInitCookieDone(false);
161             }
162         }
163     }
164 
165     private void checkInitCookie(String userID) throws WSRPException {
166         UserSessionMgr userSession = this.consumerEnv.getSessionHandler()
167                 .getUserSession(getPortlet().getPortletKey().getProducerId(),
168                         userID);
169 
170         if (initCookie.getValue().equalsIgnoreCase(CookieProtocol._perUser)) {
171 
172             this.markupPort = userSession.getWSRPBaseService();
173 
174             if (!userSession.isInitCookieDone()) {
175 
176                 userSession.setInitCookieRequired(true);
177                 initCookie();
178                 userSession.setInitCookieDone(true);
179             }
180 
181         }
182         else if (initCookie.getValue().equalsIgnoreCase(
183                 CookieProtocol._perGroup)) {
184 
185             PortletDescription portletDescription = producer
186                     .getPortletDescription(getPortlet().getParent());
187             String groupID = null;
188             if (portletDescription != null) {
189                 groupID = portletDescription.getGroupID();
190             }
191 
192             if (groupID != null) {
193                 GroupSessionMgr groupSession = userSession
194                         .getGroupSession(groupID);
195 
196                 this.markupPort = groupSession.getWSRPBaseService();
197 
198                 if (!groupSession.isInitCookieDone()) {
199                     groupSession.setInitCookieRequired(true);
200                     initCookie();
201                     groupSession.setInitCookieDone(true);
202                 }
203 
204             }
205             else {
206                 // means either we have no service description from the producer containg the portlet
207                 // or the producer specified initCookieRequired perGroup but didn't provide
208                 // a groupID in the portlet description                             
209             }
210         }
211         else {
212             this.markupPort = userSession.getWSRPBaseService();
213         }
214 
215     }
216 
217     private MarkupParams getMarkupParams(WSRPBaseRequest request) {
218 
219         MarkupParams markupParams = new MarkupParams();
220         ClientData clientData = new ClientData();
221 
222         // lets just set this to the consumer agent for now
223         clientData.setUserAgent(producer.getRegistrationData()
224                 .getConsumerAgent());
225         markupParams.setClientData(clientData);
226         markupParams.setSecureClientCommunication(false);
227         markupParams.setLocales(consumerEnv.getSupportedLocales());
228 
229         markupParams.setMimeTypes(consumerEnv.getMimeTypes());
230 
231         markupParams.setMode(request.getMode());
232         markupParams.setWindowState(request.getWindowState());
233         markupParams.setNavigationalState(request.getNavigationalState());
234         markupParams.setMarkupCharacterSets(consumerEnv
235                 .getCharacterEncodingSet());
236         markupParams.setValidateTag(null); // TODO ValidateTag
237 
238         // TODO: Set only modes and window states that are supported by the portlet as
239         //       described in it's portlet description. 
240         markupParams.setValidNewModes(consumerEnv.getSupportedModes());
241         markupParams.setValidNewWindowStates(consumerEnv
242                 .getSupportedWindowStates());
243 
244         markupParams.setExtensions(null);
245 
246         return markupParams;
247     }
248 
249     private RuntimeContext getRuntimeContext(WSRPBaseRequest request) {
250         RuntimeContext runtimeContext = new RuntimeContext();
251         runtimeContext.setUserAuthentication(consumerEnv
252                 .getUserAuthentication());
253         runtimeContext.setPortletInstanceKey(request.getPortletInstanceKey());
254 
255         URLTemplateComposer templateComposer = consumerEnv
256                 .getTemplateComposer();
257         if (templateComposer != null) {
258             runtimeContext.setNamespacePrefix(templateComposer
259                     .getNamespacePrefix());
260         }
261 
262         Boolean doesUrlTemplateProcess = null;
263         try {
264 
265             PortletDescription desc = producer
266                     .getPortletDescription(getPortlet().getParent());
267 
268             if (desc != null) {
269 
270                 doesUrlTemplateProcess = desc.getDoesUrlTemplateProcessing();
271             }
272 
273         }
274         catch (WSRPException e) {
275 
276             // do nothing since exception has been logged already
277             // continue with assumption that portlet does not support template processing
278         }
279 
280         if (doesUrlTemplateProcess != null && templateComposer != null
281                 && doesUrlTemplateProcess.booleanValue()) {
282             Templates templates = new Templates();
283             templates.setBlockingActionTemplate(templateComposer
284                     .createBlockingActionTemplate(true, true, true, true));
285             templates.setRenderTemplate(templateComposer.createRenderTemplate(
286                     true, true, true, true));
287             templates.setDefaultTemplate(templateComposer
288                     .createDefaultTemplate(true, true, true, true));
289             templates.setResourceTemplate(templateComposer
290                     .createResourceTemplate(true, true, true, true));
291             templates
292                     .setSecureBlockingActionTemplate(templateComposer
293                             .createSecureBlockingActionTemplate(true, true,
294                                     true, true));
295             templates.setSecureRenderTemplate(templateComposer
296                     .createSecureRenderTemplate(true, true, true, true));
297             templates.setSecureDefaultTemplate(templateComposer
298                     .createSecureDefaultTemplate(true, true, true, true));
299             templates.setSecureResourceTemplate(templateComposer
300                     .createSecureResourceTemplate(true, true, true, true));
301             runtimeContext.setTemplates(templates);
302         }
303 
304         runtimeContext.setSessionID(request.getSessionID());
305         runtimeContext.setExtensions(null);
306 
307         return runtimeContext;
308     }
309 
310     private UserContext getUserContext(String userID) {
311         UserContext userContext = null;
312 
313         if (userID != null) {
314             User user = consumerEnv.getUserRegistry().getUser(userID);
315 
316             if (user != null) {
317                 userContext = user.getUserContext();
318             }
319         }
320 
321         // workaround for Oracle bug, always send a userContext with dummy value
322         // if none was provided
323 
324         if (userContext == null) {
325             userContext = new UserContext();
326             userContext.setUserContextKey("dummyUserContextKey");
327         }
328 
329         return userContext;
330     }
331 
332     private InteractionParams getInteractionParams(
333             InteractionRequest actionRequest) {
334         InteractionParams interactionParams = new InteractionParams();
335 
336         interactionParams.setPortletStateChange(consumerEnv
337                 .getPortletStateChange());
338 
339         // access POPs with cloneBeforeWrite
340         // however keep the default behaviour from ConsEnv
341         // this means that if readWrite is set and we access a POP then set to cloneBeforeWrite
342         if (!portlet.isConsumerConfigured()
343                 && interactionParams.getPortletStateChange().toString()
344                         .equalsIgnoreCase(StateChange._readWrite)) {
345             interactionParams
346                     .setPortletStateChange(StateChange.cloneBeforeWrite);
347         }
348 
349         interactionParams.setInteractionState(actionRequest
350                 .getInteractionState());
351         interactionParams.setFormParameters(actionRequest.getFormParameters());
352         interactionParams.setUploadContexts(actionRequest.getUploadContexts());
353         interactionParams.setExtensions(null);
354 
355         return interactionParams;
356     }
357 
358     /**
359      * This method is used to retrieve the markup generated by the portlet instance.
360      * 
361      * @param markupRequest 
362      * @param userID
363      * @return The markup response generated by the portlet
364      **/
365     public MarkupResponse getMarkup(MarkupRequest markupRequest, String userID)
366             throws WSRPException {
367         checkInitCookie(userID);
368 
369         MarkupResponse response = null;
370 
371         try {
372 
373             MarkupContext markupContext = null;
374             if ((markupContext = markupRequest.getCachedMarkup()) == null) {
375 
376                 // getMarkup request
377                 GetMarkup request = new GetMarkup();
378 
379                 request.setPortletContext(getPortlet().getPortletContext());
380                 request.setMarkupParams(getMarkupParams(markupRequest));
381                 request.setRuntimeContext(getRuntimeContext(markupRequest));
382 
383                 RegistrationContext regCtx = producer.getRegistrationContext();
384                 if (regCtx != null)
385                     request.setRegistrationContext(regCtx);
386 
387                 UserContext userCtx = getUserContext(userID);
388                 if (userCtx != null)
389                     request.setUserContext(getUserContext(userID));
390 
391                 response = markupPort.getMarkup(request);
392 
393                 parameterChecker.check(response);
394 
395             }
396             else {
397 
398                 response = new MarkupResponse();
399                 response.setMarkupContext(markupContext);
400             }
401 
402             Boolean requiresRewriting = response.getMarkupContext()
403                     .getRequiresUrlRewriting();
404             requiresRewriting = requiresRewriting == null ? Boolean.FALSE
405                     : requiresRewriting;
406 
407             if (requiresRewriting.booleanValue()) {
408                 // rewrite url's
409 
410                 URLRewriter urlRewriter = consumerEnv.getURLRewriter();
411                 String rewrittenMarkup = urlRewriter.rewriteURLs(response
412                         .getMarkupContext().getMarkupString());
413 
414                 if (rewrittenMarkup != null) {
415                     response.getMarkupContext()
416                             .setMarkupString(rewrittenMarkup);
417                 }
418             }
419 
420         }
421         catch (InvalidCookieFault cookieFault) {
422 
423             // lets reset the init cookie settings
424             resetInitCookie(userID);
425 
426             // and try it again
427             getMarkup(markupRequest, userID);
428 
429         }
430         catch (java.rmi.RemoteException wsrpFault) {
431 
432             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
433 
434         }
435 
436         return response;
437     }
438 
439     /**
440      * This method is used to perform a blocking interaction on the portlet instance.
441      * 
442      * @param actionRequest 
443      **/
444     public BlockingInteractionResponse performBlockingInteraction(
445             InteractionRequest actionRequest, String userID)
446             throws WSRPException {
447 
448         checkInitCookie(userID);
449 
450         BlockingInteractionResponse response = null;
451 
452         try {
453             PerformBlockingInteraction request = new PerformBlockingInteraction();
454 
455             request.setPortletContext(getPortlet().getPortletContext());
456             request.setInteractionParams(getInteractionParams(actionRequest));
457             request.setMarkupParams(getMarkupParams(actionRequest));
458             request.setRuntimeContext(getRuntimeContext(actionRequest));
459 
460             RegistrationContext regCtx = producer.getRegistrationContext();
461             if (regCtx != null)
462                 request.setRegistrationContext(regCtx);
463 
464             UserContext userCtx = getUserContext(userID);
465             if (userCtx != null)
466                 request.setUserContext(userCtx);
467 
468             response = markupPort.performBlockingInteraction(request);
469 
470             parameterChecker.check(response);
471 
472         }
473         catch (InvalidCookieFault cookieFault) {
474 
475             // lets reset the init cookie settings
476             resetInitCookie(userID);
477 
478             // and try it again
479             performBlockingInteraction(actionRequest, userID);
480 
481         }
482         catch (java.rmi.RemoteException wsrpFault) {
483 
484             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
485         }
486 
487         return response;
488     }
489 
490     /**
491      * Clone the portlet
492      * 
493      * @return The new portlet context
494      **/
495     public PortletContext clonePortlet(String userID) throws WSRPException {
496         ClonePortlet request = new ClonePortlet();
497 
498         request.setPortletContext(getPortlet().getPortletContext());
499 
500         RegistrationContext regCtx = producer.getRegistrationContext();
501         if (regCtx != null)
502             request.setRegistrationContext(regCtx);
503 
504         UserContext userCtx = getUserContext(userID);
505         if (userCtx != null)
506             request.setUserContext(userCtx);
507 
508         PortletContext response = null;
509 
510         try {
511 
512             response = portletPort.clonePortlet(request);
513             parameterChecker.check(response, Constants.NILLABLE_FALSE);
514 
515         }
516         catch (java.rmi.RemoteException wsrpFault) {
517 
518             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
519         }
520 
521         return response;
522     }
523 
524     /**
525      * Destroy the producer portlets specified in the entiyHandles array.    
526      **/
527     public DestroyPortletsResponse destroyPortlets(String[] portletHandles,
528             String userID) throws WSRPException {
529         DestroyPortlets request = new DestroyPortlets();
530 
531         RegistrationContext regCtx = producer.getRegistrationContext();
532         if (regCtx != null)
533             request.setRegistrationContext(regCtx);
534 
535         request.setPortletHandles(portletHandles);
536 
537         DestroyPortletsResponse response = null;
538         try {
539 
540             response = portletPort.destroyPortlets(request);
541             parameterChecker.check(response);
542 
543         }
544         catch (java.rmi.RemoteException wsrpFault) {
545 
546             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
547         }
548 
549         return response;
550     }
551 
552     /**
553      * Inform the producer that the sessions specified in the sessionIDs array
554      * will no longer be used by the consumer and can therefor be released.     
555      **/
556     public ReturnAny releaseSessions(String[] sessionIDs, String userID)
557             throws WSRPException {
558 
559         checkInitCookie(userID);
560 
561         ReleaseSessions request = new ReleaseSessions();
562 
563         RegistrationContext regCtx = producer.getRegistrationContext();
564         if (regCtx != null)
565             request.setRegistrationContext(regCtx);
566 
567         request.setSessionIDs(sessionIDs);
568 
569         ReturnAny response = null;
570         try {
571 
572             response = markupPort.releaseSessions(request);
573 
574         }
575         catch (java.rmi.RemoteException wsrpFault) {
576 
577             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
578         }
579 
580         return response;
581     }
582 
583     /**
584      * Actual WSRP initCookie() call
585      **/
586     public void initCookie() throws WSRPException {
587         InitCookie request = new InitCookie();
588 
589         RegistrationContext regCtx = producer.getRegistrationContext();
590         if (regCtx != null)
591             request.setRegistrationContext(regCtx);
592 
593         try {
594 
595             markupPort.initCookie(request);
596 
597         }
598         catch (java.rmi.RemoteException wsrpFault) {
599             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
600         }
601     }
602 
603     /**
604      * Fetches information about the portlet from the producer. 
605      * 
606      * @param userID is used to get the user context of the user from the user registry
607      * @param desiredLocales Array of locales the description should be provided
608      * 
609      * @return The response to the getPortletDescription call.
610      **/
611     public PortletDescriptionResponse getPortletDescription(String userID,
612             String[] desiredLocales) throws WSRPException {
613         GetPortletDescription request = new GetPortletDescription();
614 
615         RegistrationContext regCtx = producer.getRegistrationContext();
616         if (regCtx != null)
617             request.setRegistrationContext(regCtx);
618 
619         request.setPortletContext(getPortlet().getPortletContext());
620 
621         UserContext userCtx = getUserContext(userID);
622         if (userCtx != null)
623             request.setUserContext(userCtx);
624 
625         request.setDesiredLocales(desiredLocales);
626 
627         PortletDescriptionResponse response = null;
628 
629         try {
630 
631             response = portletPort.getPortletDescription(request);
632             parameterChecker.check(response);
633 
634         }
635         catch (java.rmi.RemoteException wsrpFault) {
636 
637             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
638         }
639 
640         return response;
641     }
642 
643     /**
644      * Fetches all published properties of an remote portlet.
645      * 
646      * @param userID The ID of the user this request is done for
647      * 
648      * @return The portlet property description response from the producer
649      **/
650     public PortletPropertyDescriptionResponse getPortletPropertyDescription(
651             String userID) throws WSRPException {
652         GetPortletPropertyDescription request = new GetPortletPropertyDescription();
653         request.setPortletContext(getPortlet().getPortletContext());
654 
655         RegistrationContext regCtx = producer.getRegistrationContext();
656         if (regCtx != null)
657             request.setRegistrationContext(regCtx);
658 
659         UserContext userCtx = getUserContext(userID);
660         if (userCtx != null)
661             request.setUserContext(userCtx);
662 
663         request.setDesiredLocales(consumerEnv.getSupportedLocales());
664 
665         PortletPropertyDescriptionResponse response = null;
666 
667         try {
668 
669             response = portletPort.getPortletPropertyDescription(request);
670             parameterChecker.check(response);
671 
672         }
673         catch (java.rmi.RemoteException wsrpFault) {
674 
675             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
676         }
677 
678         return response;
679     }
680 
681     /**
682      * Get the current values of the properties with the given names.
683      * 
684      * @param names The names of the properties
685      * @param userID The ID of the user is used to get the user context
686      * 
687      * @return A list of properties containing the values and names of the properties.
688      **/
689     public PropertyList getPortletProperties(String[] names, String userID)
690             throws WSRPException {
691         GetPortletProperties request = new GetPortletProperties();
692         request.setPortletContext(getPortlet().getPortletContext());
693         request.setNames(names);
694 
695         RegistrationContext regCtx = producer.getRegistrationContext();
696         if (regCtx != null)
697             request.setRegistrationContext(regCtx);
698 
699         UserContext userCtx = getUserContext(userID);
700         if (userCtx != null)
701             request.setUserContext(userCtx);
702 
703         PropertyList response = null;
704 
705         try {
706 
707             response = portletPort.getPortletProperties(request);
708             parameterChecker.check(response, Constants.NILLABLE_FALSE);
709 
710         }
711         catch (java.rmi.RemoteException wsrpFault) {
712 
713             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
714         }
715 
716         return response;
717     }
718 
719     /**
720      * Set the portlet properties specified in the property list
721      * 
722      * @param properties List of properties to be set.
723      * @param userID The ID of the user is used to get the user context
724      **/
725     public PortletContext setPortletProperties(PropertyList properties,
726             String userID) throws WSRPException {
727         SetPortletProperties request = new SetPortletProperties();
728         request.setPortletContext(getPortlet().getPortletContext());
729 
730         RegistrationContext regCtx = producer.getRegistrationContext();
731         if (regCtx != null)
732             request.setRegistrationContext(regCtx);
733 
734         UserContext userCtx = getUserContext(userID);
735         if (userCtx != null)
736             request.setUserContext(userCtx);
737         request.setPropertyList(properties);
738 
739         PortletContext response = null;
740 
741         try {
742 
743             response = portletPort.setPortletProperties(request);
744             parameterChecker.check(response, Constants.NILLABLE_FALSE);
745 
746         }
747         catch (java.rmi.RemoteException wsrpFault) {
748 
749             WSRPXHelper.handleWSRPFault(logger, wsrpFault);
750         }
751 
752         return response;
753     }
754 }