Source Code Cross Referenced for PortletDriverImpl.java in  » Portal » liferay-portal-4.4.2 » org » apache » wsrp4j » consumer » driver » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » org.apache.wsrp4j.consumer.driver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000-2001,2004 The Apache Software Foundation.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.wsrp4j.consumer.driver;
018:
019:        import oasis.names.tc.wsrp.v1.intf.WSRP_v1_Markup_PortType;
020:        import oasis.names.tc.wsrp.v1.intf.WSRP_v1_PortletManagement_PortType;
021:        import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
022:        import oasis.names.tc.wsrp.v1.types.ClientData;
023:        import oasis.names.tc.wsrp.v1.types.ClonePortlet;
024:        import oasis.names.tc.wsrp.v1.types.CookieProtocol;
025:        import oasis.names.tc.wsrp.v1.types.DestroyPortlets;
026:        import oasis.names.tc.wsrp.v1.types.DestroyPortletsResponse;
027:        import oasis.names.tc.wsrp.v1.types.GetMarkup;
028:        import oasis.names.tc.wsrp.v1.types.GetPortletDescription;
029:        import oasis.names.tc.wsrp.v1.types.GetPortletProperties;
030:        import oasis.names.tc.wsrp.v1.types.GetPortletPropertyDescription;
031:        import oasis.names.tc.wsrp.v1.types.InitCookie;
032:        import oasis.names.tc.wsrp.v1.types.InteractionParams;
033:        import oasis.names.tc.wsrp.v1.types.InvalidCookieFault;
034:        import oasis.names.tc.wsrp.v1.types.MarkupContext;
035:        import oasis.names.tc.wsrp.v1.types.MarkupParams;
036:        import oasis.names.tc.wsrp.v1.types.MarkupResponse;
037:        import oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction;
038:        import oasis.names.tc.wsrp.v1.types.PortletContext;
039:        import oasis.names.tc.wsrp.v1.types.PortletDescription;
040:        import oasis.names.tc.wsrp.v1.types.PortletDescriptionResponse;
041:        import oasis.names.tc.wsrp.v1.types.PortletPropertyDescriptionResponse;
042:        import oasis.names.tc.wsrp.v1.types.PropertyList;
043:        import oasis.names.tc.wsrp.v1.types.RegistrationContext;
044:        import oasis.names.tc.wsrp.v1.types.ReleaseSessions;
045:        import oasis.names.tc.wsrp.v1.types.ReturnAny;
046:        import oasis.names.tc.wsrp.v1.types.RuntimeContext;
047:        import oasis.names.tc.wsrp.v1.types.ServiceDescription;
048:        import oasis.names.tc.wsrp.v1.types.SetPortletProperties;
049:        import oasis.names.tc.wsrp.v1.types.StateChange;
050:        import oasis.names.tc.wsrp.v1.types.Templates;
051:        import oasis.names.tc.wsrp.v1.types.UserContext;
052:
053:        import org.apache.wsrp4j.consumer.ConsumerEnvironment;
054:        import org.apache.wsrp4j.consumer.GroupSessionMgr;
055:        import org.apache.wsrp4j.consumer.InteractionRequest;
056:        import org.apache.wsrp4j.consumer.MarkupRequest;
057:        import org.apache.wsrp4j.consumer.PortletDriver;
058:        import org.apache.wsrp4j.consumer.Producer;
059:        import org.apache.wsrp4j.consumer.URLRewriter;
060:        import org.apache.wsrp4j.consumer.URLTemplateComposer;
061:        import org.apache.wsrp4j.consumer.User;
062:        import org.apache.wsrp4j.consumer.UserSessionMgr;
063:        import org.apache.wsrp4j.consumer.WSRPBaseRequest;
064:        import org.apache.wsrp4j.consumer.WSRPPortlet;
065:        import org.apache.wsrp4j.exception.WSRPException;
066:        import org.apache.wsrp4j.exception.WSRPXHelper;
067:        import org.apache.wsrp4j.log.LogManager;
068:        import org.apache.wsrp4j.log.Logger;
069:        import org.apache.wsrp4j.util.Constants;
070:        import org.apache.wsrp4j.util.ParameterChecker;
071:
072:        /**
073:         * This class implements a portlet driver
074:         **/
075:        public class PortletDriverImpl implements  PortletDriver {
076:
077:            private WSRPPortlet portlet = null;
078:
079:            private WSRP_v1_Markup_PortType markupPort = null;
080:
081:            private WSRP_v1_PortletManagement_PortType portletPort = null;
082:
083:            private ConsumerEnvironment consumerEnv = null;
084:
085:            private Producer producer = null;
086:
087:            private ParameterChecker parameterChecker = null;
088:
089:            private CookieProtocol initCookie = CookieProtocol.none;
090:
091:            // the logger
092:            private static final Logger logger = LogManager.getLogManager()
093:                    .getLogger(PortletDriverImpl.class);
094:
095:            public PortletDriverImpl(WSRPPortlet portlet,
096:                    ConsumerEnvironment consumerEnv) throws WSRPException {
097:                parameterChecker = new ParameterChecker();
098:
099:                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
110:                            .getRequiresInitCookie();
111:                    if (initCookie == null) {
112:                        initCookie = CookieProtocol.none; // TODO - get from config
113:                    }
114:                }
115:            }
116:
117:            /**
118:             * Get the portlet this driver is bind to.
119:             * 
120:             * @return The enity
121:             **/
122:            public WSRPPortlet getPortlet() {
123:                return this .portlet;
124:            }
125:
126:            private void resetInitCookie(String userID) throws WSRPException {
127:
128:                UserSessionMgr userSession = this .consumerEnv
129:                        .getSessionHandler().getUserSession(
130:                                getPortlet().getPortletKey().getProducerId(),
131:                                userID);
132:
133:                if (initCookie.getValue()
134:                        .equalsIgnoreCase(CookieProtocol._none)) {
135:
136:                    userSession.setInitCookieDone(false);
137:
138:                } else if (initCookie.getValue().equalsIgnoreCase(
139:                        CookieProtocol._perGroup)) {
140:
141:                    PortletDescription portletDescription = null;
142:                    try {
143:
144:                        portletDescription = producer
145:                                .getPortletDescription(getPortlet().getParent());
146:
147:                    } catch (WSRPException e) {
148:
149:                        // do nothing since exception has been logged already
150:
151:                    }
152:
153:                    String groupID = null;
154:                    if (portletDescription != null) {
155:                        groupID = portletDescription.getGroupID();
156:                    }
157:
158:                    if (groupID != null) {
159:                        GroupSessionMgr groupSession = userSession
160:                                .getGroupSession(groupID);
161:                        groupSession.setInitCookieDone(false);
162:                    }
163:                }
164:            }
165:
166:            private void checkInitCookie(String userID) throws WSRPException {
167:                UserSessionMgr userSession = this .consumerEnv
168:                        .getSessionHandler().getUserSession(
169:                                getPortlet().getPortletKey().getProducerId(),
170:                                userID);
171:
172:                if (initCookie.getValue().equalsIgnoreCase(
173:                        CookieProtocol._perUser)) {
174:
175:                    this .markupPort = userSession.getWSRPBaseService();
176:
177:                    if (!userSession.isInitCookieDone()) {
178:
179:                        userSession.setInitCookieRequired(true);
180:                        initCookie();
181:                        userSession.setInitCookieDone(true);
182:                    }
183:
184:                } else if (initCookie.getValue().equalsIgnoreCase(
185:                        CookieProtocol._perGroup)) {
186:
187:                    PortletDescription portletDescription = producer
188:                            .getPortletDescription(getPortlet().getParent());
189:                    String groupID = null;
190:                    if (portletDescription != null) {
191:                        groupID = portletDescription.getGroupID();
192:                    }
193:
194:                    if (groupID != null) {
195:                        GroupSessionMgr groupSession = userSession
196:                                .getGroupSession(groupID);
197:
198:                        this .markupPort = groupSession.getWSRPBaseService();
199:
200:                        if (!groupSession.isInitCookieDone()) {
201:                            groupSession.setInitCookieRequired(true);
202:                            initCookie();
203:                            groupSession.setInitCookieDone(true);
204:                        }
205:
206:                    } else {
207:                        // means either we have no service description from the producer containg the portlet
208:                        // or the producer specified initCookieRequired perGroup but didn't provide
209:                        // a groupID in the portlet description                             
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
234:                        .getNavigationalState());
235:                markupParams.setMarkupCharacterSets(consumerEnv
236:                        .getCharacterEncodingSet());
237:                markupParams.setValidateTag(null); // TODO ValidateTag
238:
239:                // TODO: Set only modes and window states that are supported by the portlet as
240:                //       described in it's portlet description. 
241:                markupParams.setValidNewModes(consumerEnv.getSupportedModes());
242:                markupParams.setValidNewWindowStates(consumerEnv
243:                        .getSupportedWindowStates());
244:
245:                markupParams.setExtensions(null);
246:
247:                return markupParams;
248:            }
249:
250:            private RuntimeContext getRuntimeContext(WSRPBaseRequest request) {
251:                RuntimeContext runtimeContext = new RuntimeContext();
252:                runtimeContext.setUserAuthentication(consumerEnv
253:                        .getUserAuthentication());
254:                runtimeContext.setPortletInstanceKey(request
255:                        .getPortletInstanceKey());
256:
257:                URLTemplateComposer templateComposer = consumerEnv
258:                        .getTemplateComposer();
259:                if (templateComposer != null) {
260:                    runtimeContext.setNamespacePrefix(templateComposer
261:                            .getNamespacePrefix());
262:                }
263:
264:                Boolean doesUrlTemplateProcess = null;
265:                try {
266:
267:                    PortletDescription desc = producer
268:                            .getPortletDescription(getPortlet().getParent());
269:
270:                    if (desc != null) {
271:
272:                        doesUrlTemplateProcess = desc
273:                                .getDoesUrlTemplateProcessing();
274:                    }
275:
276:                } catch (WSRPException e) {
277:
278:                    // do nothing since exception has been logged already
279:                    // continue with assumption that portlet does not support template processing
280:                }
281:
282:                if (doesUrlTemplateProcess != null && templateComposer != null
283:                        && doesUrlTemplateProcess.booleanValue()) {
284:                    Templates templates = new Templates();
285:                    templates.setBlockingActionTemplate(templateComposer
286:                            .createBlockingActionTemplate(true, true, true,
287:                                    true));
288:                    templates.setRenderTemplate(templateComposer
289:                            .createRenderTemplate(true, true, true, true));
290:                    templates.setDefaultTemplate(templateComposer
291:                            .createDefaultTemplate(true, true, true, true));
292:                    templates.setResourceTemplate(templateComposer
293:                            .createResourceTemplate(true, true, true, true));
294:                    templates.setSecureBlockingActionTemplate(templateComposer
295:                            .createSecureBlockingActionTemplate(true, true,
296:                                    true, true));
297:                    templates
298:                            .setSecureRenderTemplate(templateComposer
299:                                    .createSecureRenderTemplate(true, true,
300:                                            true, true));
301:                    templates
302:                            .setSecureDefaultTemplate(templateComposer
303:                                    .createSecureDefaultTemplate(true, true,
304:                                            true, true));
305:                    templates.setSecureResourceTemplate(templateComposer
306:                            .createSecureResourceTemplate(true, true, true,
307:                                    true));
308:                    runtimeContext.setTemplates(templates);
309:                }
310:
311:                runtimeContext.setSessionID(request.getSessionID());
312:                runtimeContext.setExtensions(null);
313:
314:                return runtimeContext;
315:            }
316:
317:            private UserContext getUserContext(String userID) {
318:                UserContext userContext = null;
319:
320:                if (userID != null) {
321:                    User user = consumerEnv.getUserRegistry().getUser(userID);
322:
323:                    if (user != null) {
324:                        userContext = user.getUserContext();
325:                    }
326:                }
327:
328:                // workaround for Oracle bug, always send a userContext with dummy value
329:                // if none was provided
330:
331:                if (userContext == null) {
332:                    userContext = new UserContext();
333:                    userContext.setUserContextKey("dummyUserContextKey");
334:                }
335:
336:                return userContext;
337:            }
338:
339:            private InteractionParams getInteractionParams(
340:                    InteractionRequest actionRequest) {
341:                InteractionParams interactionParams = new InteractionParams();
342:
343:                interactionParams.setPortletStateChange(consumerEnv
344:                        .getPortletStateChange());
345:
346:                // access POPs with cloneBeforeWrite
347:                // however keep the default behaviour from ConsEnv
348:                // this means that if readWrite is set and we access a POP then set to cloneBeforeWrite
349:                if (!portlet.isConsumerConfigured()
350:                        && interactionParams.getPortletStateChange().toString()
351:                                .equalsIgnoreCase(StateChange._readWrite)) {
352:                    interactionParams
353:                            .setPortletStateChange(StateChange.cloneBeforeWrite);
354:                }
355:
356:                interactionParams.setInteractionState(actionRequest
357:                        .getInteractionState());
358:                interactionParams.setFormParameters(actionRequest
359:                        .getFormParameters());
360:                interactionParams.setUploadContexts(actionRequest
361:                        .getUploadContexts());
362:                interactionParams.setExtensions(null);
363:
364:                return interactionParams;
365:            }
366:
367:            /**
368:             * This method is used to retrieve the markup generated by the portlet instance.
369:             * 
370:             * @param markupRequest 
371:             * @param userID
372:             * @return The markup response generated by the portlet
373:             **/
374:            public MarkupResponse getMarkup(MarkupRequest markupRequest,
375:                    String userID) throws WSRPException {
376:                checkInitCookie(userID);
377:
378:                MarkupResponse response = null;
379:
380:                try {
381:
382:                    MarkupContext markupContext = null;
383:                    if ((markupContext = markupRequest.getCachedMarkup()) == null) {
384:
385:                        // getMarkup request
386:                        GetMarkup request = new GetMarkup();
387:
388:                        request.setPortletContext(getPortlet()
389:                                .getPortletContext());
390:                        request.setMarkupParams(getMarkupParams(markupRequest));
391:                        request
392:                                .setRuntimeContext(getRuntimeContext(markupRequest));
393:
394:                        RegistrationContext regCtx = producer
395:                                .getRegistrationContext();
396:                        if (regCtx != null)
397:                            request.setRegistrationContext(regCtx);
398:
399:                        UserContext userCtx = getUserContext(userID);
400:                        if (userCtx != null)
401:                            request.setUserContext(getUserContext(userID));
402:
403:                        response = markupPort.getMarkup(request);
404:
405:                        parameterChecker.check(response);
406:
407:                    } else {
408:
409:                        response = new MarkupResponse();
410:                        response.setMarkupContext(markupContext);
411:                    }
412:
413:                    Boolean requiresRewriting = response.getMarkupContext()
414:                            .getRequiresUrlRewriting();
415:                    requiresRewriting = requiresRewriting == null ? Boolean.FALSE
416:                            : requiresRewriting;
417:
418:                    if (requiresRewriting.booleanValue()) {
419:                        // rewrite url's
420:
421:                        URLRewriter urlRewriter = consumerEnv.getURLRewriter();
422:                        String rewrittenMarkup = urlRewriter
423:                                .rewriteURLs(response.getMarkupContext()
424:                                        .getMarkupString());
425:
426:                        if (rewrittenMarkup != null) {
427:                            response.getMarkupContext().setMarkupString(
428:                                    rewrittenMarkup);
429:                        }
430:                    }
431:
432:                } catch (InvalidCookieFault cookieFault) {
433:
434:                    // lets reset the init cookie settings
435:                    resetInitCookie(userID);
436:
437:                    // and try it again
438:                    getMarkup(markupRequest, userID);
439:
440:                } catch (java.rmi.RemoteException wsrpFault) {
441:
442:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
443:
444:                }
445:
446:                return response;
447:            }
448:
449:            /**
450:             * This method is used to perform a blocking interaction on the portlet instance.
451:             * 
452:             * @param actionRequest 
453:             **/
454:            public BlockingInteractionResponse performBlockingInteraction(
455:                    InteractionRequest actionRequest, String userID)
456:                    throws WSRPException {
457:
458:                checkInitCookie(userID);
459:
460:                BlockingInteractionResponse response = null;
461:
462:                try {
463:                    PerformBlockingInteraction request = new PerformBlockingInteraction();
464:
465:                    request.setPortletContext(getPortlet().getPortletContext());
466:                    request
467:                            .setInteractionParams(getInteractionParams(actionRequest));
468:                    request.setMarkupParams(getMarkupParams(actionRequest));
469:                    request.setRuntimeContext(getRuntimeContext(actionRequest));
470:
471:                    RegistrationContext regCtx = producer
472:                            .getRegistrationContext();
473:                    if (regCtx != null)
474:                        request.setRegistrationContext(regCtx);
475:
476:                    UserContext userCtx = getUserContext(userID);
477:                    if (userCtx != null)
478:                        request.setUserContext(userCtx);
479:
480:                    response = markupPort.performBlockingInteraction(request);
481:
482:                    parameterChecker.check(response);
483:
484:                } catch (InvalidCookieFault cookieFault) {
485:
486:                    // lets reset the init cookie settings
487:                    resetInitCookie(userID);
488:
489:                    // and try it again
490:                    performBlockingInteraction(actionRequest, userID);
491:
492:                } catch (java.rmi.RemoteException wsrpFault) {
493:
494:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
495:                }
496:
497:                return response;
498:            }
499:
500:            /**
501:             * Clone the portlet
502:             * 
503:             * @return The new portlet context
504:             **/
505:            public PortletContext clonePortlet(String userID)
506:                    throws WSRPException {
507:                ClonePortlet request = new ClonePortlet();
508:
509:                request.setPortletContext(getPortlet().getPortletContext());
510:
511:                RegistrationContext regCtx = producer.getRegistrationContext();
512:                if (regCtx != null)
513:                    request.setRegistrationContext(regCtx);
514:
515:                UserContext userCtx = getUserContext(userID);
516:                if (userCtx != null)
517:                    request.setUserContext(userCtx);
518:
519:                PortletContext response = null;
520:
521:                try {
522:
523:                    response = portletPort.clonePortlet(request);
524:                    parameterChecker.check(response, Constants.NILLABLE_FALSE);
525:
526:                } catch (java.rmi.RemoteException wsrpFault) {
527:
528:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
529:                }
530:
531:                return response;
532:            }
533:
534:            /**
535:             * Destroy the producer portlets specified in the entiyHandles array.    
536:             **/
537:            public DestroyPortletsResponse destroyPortlets(
538:                    String[] portletHandles, String userID)
539:                    throws WSRPException {
540:                DestroyPortlets request = new DestroyPortlets();
541:
542:                RegistrationContext regCtx = producer.getRegistrationContext();
543:                if (regCtx != null)
544:                    request.setRegistrationContext(regCtx);
545:
546:                request.setPortletHandles(portletHandles);
547:
548:                DestroyPortletsResponse response = null;
549:                try {
550:
551:                    response = portletPort.destroyPortlets(request);
552:                    parameterChecker.check(response);
553:
554:                } catch (java.rmi.RemoteException wsrpFault) {
555:
556:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
557:                }
558:
559:                return response;
560:            }
561:
562:            /**
563:             * Inform the producer that the sessions specified in the sessionIDs array
564:             * will no longer be used by the consumer and can therefor be released.     
565:             **/
566:            public ReturnAny releaseSessions(String[] sessionIDs, String userID)
567:                    throws WSRPException {
568:
569:                checkInitCookie(userID);
570:
571:                ReleaseSessions request = new ReleaseSessions();
572:
573:                RegistrationContext regCtx = producer.getRegistrationContext();
574:                if (regCtx != null)
575:                    request.setRegistrationContext(regCtx);
576:
577:                request.setSessionIDs(sessionIDs);
578:
579:                ReturnAny response = null;
580:                try {
581:
582:                    response = markupPort.releaseSessions(request);
583:
584:                } catch (java.rmi.RemoteException wsrpFault) {
585:
586:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
587:                }
588:
589:                return response;
590:            }
591:
592:            /**
593:             * Actual WSRP initCookie() call
594:             **/
595:            public void initCookie() throws WSRPException {
596:                InitCookie request = new InitCookie();
597:
598:                RegistrationContext regCtx = producer.getRegistrationContext();
599:                if (regCtx != null)
600:                    request.setRegistrationContext(regCtx);
601:
602:                try {
603:
604:                    markupPort.initCookie(request);
605:
606:                } catch (java.rmi.RemoteException wsrpFault) {
607:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
608:                }
609:            }
610:
611:            /**
612:             * Fetches information about the portlet from the producer. 
613:             * 
614:             * @param userID is used to get the user context of the user from the user registry
615:             * @param desiredLocales Array of locales the description should be provided
616:             * 
617:             * @return The response to the getPortletDescription call.
618:             **/
619:            public PortletDescriptionResponse getPortletDescription(
620:                    String userID, String[] desiredLocales)
621:                    throws WSRPException {
622:                GetPortletDescription request = new GetPortletDescription();
623:
624:                RegistrationContext regCtx = producer.getRegistrationContext();
625:                if (regCtx != null)
626:                    request.setRegistrationContext(regCtx);
627:
628:                request.setPortletContext(getPortlet().getPortletContext());
629:
630:                UserContext userCtx = getUserContext(userID);
631:                if (userCtx != null)
632:                    request.setUserContext(userCtx);
633:
634:                request.setDesiredLocales(desiredLocales);
635:
636:                PortletDescriptionResponse response = null;
637:
638:                try {
639:
640:                    response = portletPort.getPortletDescription(request);
641:                    parameterChecker.check(response);
642:
643:                } catch (java.rmi.RemoteException wsrpFault) {
644:
645:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
646:                }
647:
648:                return response;
649:            }
650:
651:            /**
652:             * Fetches all published properties of an remote portlet.
653:             * 
654:             * @param userID The ID of the user this request is done for
655:             * 
656:             * @return The portlet property description response from the producer
657:             **/
658:            public PortletPropertyDescriptionResponse getPortletPropertyDescription(
659:                    String userID) throws WSRPException {
660:                GetPortletPropertyDescription request = new GetPortletPropertyDescription();
661:                request.setPortletContext(getPortlet().getPortletContext());
662:
663:                RegistrationContext regCtx = producer.getRegistrationContext();
664:                if (regCtx != null)
665:                    request.setRegistrationContext(regCtx);
666:
667:                UserContext userCtx = getUserContext(userID);
668:                if (userCtx != null)
669:                    request.setUserContext(userCtx);
670:
671:                request.setDesiredLocales(consumerEnv.getSupportedLocales());
672:
673:                PortletPropertyDescriptionResponse response = null;
674:
675:                try {
676:
677:                    response = portletPort
678:                            .getPortletPropertyDescription(request);
679:                    parameterChecker.check(response);
680:
681:                } catch (java.rmi.RemoteException wsrpFault) {
682:
683:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
684:                }
685:
686:                return response;
687:            }
688:
689:            /**
690:             * Get the current values of the properties with the given names.
691:             * 
692:             * @param names The names of the properties
693:             * @param userID The ID of the user is used to get the user context
694:             * 
695:             * @return A list of properties containing the values and names of the properties.
696:             **/
697:            public PropertyList getPortletProperties(String[] names,
698:                    String userID) throws WSRPException {
699:                GetPortletProperties request = new GetPortletProperties();
700:                request.setPortletContext(getPortlet().getPortletContext());
701:                request.setNames(names);
702:
703:                RegistrationContext regCtx = producer.getRegistrationContext();
704:                if (regCtx != null)
705:                    request.setRegistrationContext(regCtx);
706:
707:                UserContext userCtx = getUserContext(userID);
708:                if (userCtx != null)
709:                    request.setUserContext(userCtx);
710:
711:                PropertyList response = null;
712:
713:                try {
714:
715:                    response = portletPort.getPortletProperties(request);
716:                    parameterChecker.check(response, Constants.NILLABLE_FALSE);
717:
718:                } catch (java.rmi.RemoteException wsrpFault) {
719:
720:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
721:                }
722:
723:                return response;
724:            }
725:
726:            /**
727:             * Set the portlet properties specified in the property list
728:             * 
729:             * @param properties List of properties to be set.
730:             * @param userID The ID of the user is used to get the user context
731:             **/
732:            public PortletContext setPortletProperties(PropertyList properties,
733:                    String userID) throws WSRPException {
734:                SetPortletProperties request = new SetPortletProperties();
735:                request.setPortletContext(getPortlet().getPortletContext());
736:
737:                RegistrationContext regCtx = producer.getRegistrationContext();
738:                if (regCtx != null)
739:                    request.setRegistrationContext(regCtx);
740:
741:                UserContext userCtx = getUserContext(userID);
742:                if (userCtx != null)
743:                    request.setUserContext(userCtx);
744:                request.setPropertyList(properties);
745:
746:                PortletContext response = null;
747:
748:                try {
749:
750:                    response = portletPort.setPortletProperties(request);
751:                    parameterChecker.check(response, Constants.NILLABLE_FALSE);
752:
753:                } catch (java.rmi.RemoteException wsrpFault) {
754:
755:                    WSRPXHelper.handleWSRPFault(logger, wsrpFault);
756:                }
757:
758:                return response;
759:            }
760:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.