Source Code Cross Referenced for WSRPEngine.java in  » Portal » liferay-portal-4.4.2 » org » apache » wsrp4j » producer » 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.producer.driver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2000-2001,2004 The Apache Software Foundation.
0003:         * 
0004:         * Licensed under the Apache License, Version 2.0 (the "License");
0005:         * you may not use this file except in compliance with the License.
0006:         * You may obtain a copy of the License at
0007:         * 
0008:         *      http://www.apache.org/licenses/LICENSE-2.0
0009:         * 
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.
0015:         */
0016:
0017:        package org.apache.wsrp4j.producer.driver;
0018:
0019:        import java.rmi.RemoteException;
0020:        import java.util.ArrayList;
0021:        import java.util.Arrays;
0022:        import java.util.Iterator;
0023:
0024:        import javax.servlet.http.HttpServletRequest;
0025:        import javax.servlet.http.HttpSession;
0026:
0027:        import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
0028:        import oasis.names.tc.wsrp.v1.types.ClonePortlet;
0029:        import oasis.names.tc.wsrp.v1.types.DestroyFailed;
0030:        import oasis.names.tc.wsrp.v1.types.DestroyPortlets;
0031:        import oasis.names.tc.wsrp.v1.types.DestroyPortletsResponse;
0032:        import oasis.names.tc.wsrp.v1.types.GetMarkup;
0033:        import oasis.names.tc.wsrp.v1.types.GetPortletDescription;
0034:        import oasis.names.tc.wsrp.v1.types.GetPortletProperties;
0035:        import oasis.names.tc.wsrp.v1.types.GetPortletPropertyDescription;
0036:        import oasis.names.tc.wsrp.v1.types.GetServiceDescription;
0037:        import oasis.names.tc.wsrp.v1.types.InitCookie;
0038:        import oasis.names.tc.wsrp.v1.types.MarkupParams;
0039:        import oasis.names.tc.wsrp.v1.types.MarkupResponse;
0040:        import oasis.names.tc.wsrp.v1.types.MarkupType;
0041:        import oasis.names.tc.wsrp.v1.types.MissingParametersFault;
0042:        import oasis.names.tc.wsrp.v1.types.ModifyRegistration;
0043:        import oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction;
0044:        import oasis.names.tc.wsrp.v1.types.PortletContext;
0045:        import oasis.names.tc.wsrp.v1.types.PortletDescription;
0046:        import oasis.names.tc.wsrp.v1.types.PortletDescriptionResponse;
0047:        import oasis.names.tc.wsrp.v1.types.PortletPropertyDescriptionResponse;
0048:        import oasis.names.tc.wsrp.v1.types.PropertyList;
0049:        import oasis.names.tc.wsrp.v1.types.RegistrationContext;
0050:        import oasis.names.tc.wsrp.v1.types.RegistrationData;
0051:        import oasis.names.tc.wsrp.v1.types.RegistrationState;
0052:        import oasis.names.tc.wsrp.v1.types.ReleaseSessions;
0053:        import oasis.names.tc.wsrp.v1.types.ReturnAny;
0054:        import oasis.names.tc.wsrp.v1.types.ServiceDescription;
0055:        import oasis.names.tc.wsrp.v1.types.SetPortletProperties;
0056:        import oasis.names.tc.wsrp.v1.types.StateChange;
0057:
0058:        import org.apache.axis.AxisEngine;
0059:        import org.apache.axis.MessageContext;
0060:        import org.apache.axis.transport.http.HTTPConstants;
0061:        import org.apache.wsrp4j.exception.ErrorCodes;
0062:        import org.apache.wsrp4j.exception.WSRPException;
0063:        import org.apache.wsrp4j.exception.WSRPXHelper;
0064:        import org.apache.wsrp4j.log.LogManager;
0065:        import org.apache.wsrp4j.log.Logger;
0066:        import org.apache.wsrp4j.producer.ConsumerRegistry;
0067:        import org.apache.wsrp4j.producer.ConsumerRegistryAccess;
0068:        import org.apache.wsrp4j.producer.ProviderAccess;
0069:        import org.apache.wsrp4j.producer.Registration;
0070:        import org.apache.wsrp4j.producer.provider.ConsumerConfiguredPortlet;
0071:        import org.apache.wsrp4j.producer.provider.DescriptionHandler;
0072:        import org.apache.wsrp4j.producer.provider.Portlet;
0073:        import org.apache.wsrp4j.producer.provider.PortletStateManager;
0074:        import org.apache.wsrp4j.producer.provider.ProducerOfferedPortlet;
0075:        import org.apache.wsrp4j.producer.provider.Provider;
0076:        import org.apache.wsrp4j.util.Constants;
0077:        import org.apache.wsrp4j.util.LocaleHelper;
0078:        import org.apache.wsrp4j.util.ParameterChecker;
0079:
0080:        /**
0081:         * <p>Implements the WSRP-interfaces:
0082:         * <ul>
0083:         *   <li>Service Description Interface (required): Defines an operation for
0084:         *   acquiring the Producer's metadata.</li>
0085:         *   <li>Markup Interface (required): Defines operations for getting markup
0086:         *   from a portlet as well as processing user interactions with that markup.
0087:         *   Contains also the operation for Consumer assistance in pre-initializing
0088:         *   HTTP-cookies.</li>
0089:         *   <li>Registration Interface (optional): Defines operations for establishing,
0090:         *   updating and destroying a regisration. Each registration reflects a particular
0091:         *   relationship between a Consumer and a Producer.</li>
0092:         *   <li>Portlet Management Interface (optional): Defines operations for getting
0093:         *   portlet metadata, cloning portlets for further customization and interacting
0094:         *   with the property interface.</li>
0095:         * </li>
0096:         * </p>
0097:         * <p>All methods are implemented by calling the corresponding sub-components
0098:         * (Producer- and Provider-side components). Additionally each method implementation
0099:         * performs high level checks (e.g. a parameter validation to ensure that all required
0100:         * input parameters are available) and maps internal exceptions to exceptions defined
0101:         * vy WSRP.</p> 
0102:         * <p>Involves additional servlet related objects -> no mapping of the interfaces
0103:         * possible</p>
0104:         */
0105:
0106:        public class WSRPEngine implements 
0107:                oasis.names.tc.wsrp.v1.intf.WSRP_v1_PortletManagement_PortType,
0108:                oasis.names.tc.wsrp.v1.intf.WSRP_v1_Markup_PortType,
0109:                oasis.names.tc.wsrp.v1.intf.WSRP_v1_Registration_PortType,
0110:                oasis.names.tc.wsrp.v1.intf.WSRP_v1_ServiceDescription_PortType {
0111:
0112:            private boolean registrationRequired;
0113:
0114:            // provider
0115:            private Provider provider = null;
0116:
0117:            // consumer registry
0118:            private ConsumerRegistry consumerRegistry = null;
0119:
0120:            //holds an instance of the WSRPEngine
0121:            private static WSRPEngine instance = null;
0122:
0123:            // helper instance for WSRP parameter validation
0124:            private ParameterChecker paramCheck = new ParameterChecker();
0125:
0126:            // log and trace support
0127:            private Logger logger = LogManager.getLogManager().getLogger(
0128:                    this .getClass());
0129:
0130:            /**
0131:             * Constructor reading the config from the properties file
0132:             */
0133:            private WSRPEngine() throws java.rmi.RemoteException {
0134:                String MN = "Constructor";
0135:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0136:                    logger.entry(Logger.TRACE_HIGH, MN);
0137:                }
0138:
0139:                try {
0140:                    provider = ProviderAccess.getProvider();
0141:                    consumerRegistry = ConsumerRegistryAccess
0142:                            .getConsumerRegistry();
0143:
0144:                    registrationRequired = consumerRegistry
0145:                            .isRegistrationRequired();
0146:
0147:                } catch (WSRPException e) {
0148:
0149:                    WSRPXHelper.handleWSRPException(e);
0150:
0151:                }
0152:
0153:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0154:                    logger.exit(Logger.TRACE_HIGH, MN);
0155:                }
0156:
0157:            }
0158:
0159:            /**
0160:             * Internal method.
0161:             * Creates a new session and initializes it
0162:             */
0163:            private void createSession() throws WSRPException {
0164:                MessageContext msgContext = AxisEngine
0165:                        .getCurrentMessageContext();
0166:
0167:                HttpServletRequest servletRequest = (HttpServletRequest) msgContext
0168:                        .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
0169:                HttpSession session = servletRequest.getSession(true);
0170:
0171:                if (session == null) {
0172:                    throw new WSRPException(ErrorCodes.OPERATION_FAILED);
0173:                }
0174:            }
0175:
0176:            /**
0177:             Internal method.
0178:             Returns an instance of the WSRPEngine
0179:             @return WSRPEngine 
0180:             */
0181:            public synchronized static WSRPEngine getInstance()
0182:                    throws java.rmi.RemoteException {
0183:                if (instance == null) {
0184:                    instance = new WSRPEngine();
0185:                }
0186:
0187:                return instance;
0188:            }
0189:
0190:            /**
0191:             * Service Description Interface
0192:             */
0193:
0194:            /**
0195:             * <p>Allows a Producer to provide information about its capabilities. Producers
0196:             * may choose to restrict the information returned in ServiceDescription based on
0197:             * the supplied RegistrationContext.</p>
0198:             * <p>Checks registration (if required) by querying the ConsumerRegistry and calls
0199:             * the DescriptionHandler to get the service description.</p> 
0200:             *
0201:             * @param request a generated wrapper containing all input arguments for this method
0202:             *
0203:             * @return ServiceDescription
0204:             * 
0205:             * @exception java.rmi.RemoteException
0206:             */
0207:            public ServiceDescription getServiceDescription(
0208:                    GetServiceDescription request)
0209:                    throws java.rmi.RemoteException {
0210:
0211:                String MN = "getServiceDescription";
0212:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0213:                    logger.entry(Logger.TRACE_HIGH, MN);
0214:                }
0215:
0216:                ServiceDescription description = null;
0217:
0218:                try {
0219:                    // perform parameter check
0220:                    paramCheck.check(request);
0221:
0222:                    DescriptionHandler descrHandler = provider
0223:                            .getDescriptionHandler();
0224:                    RegistrationContext regContext = request
0225:                            .getRegistrationContext();
0226:
0227:                    boolean registered = false;
0228:
0229:                    if (regContext != null) {
0230:                        registered = consumerRegistry.check(regContext
0231:                                .getRegistrationHandle());
0232:                    }
0233:
0234:                    // check registration aspects, then fetch corresponding service description
0235:                    // TODO: also check if regHandle==null?
0236:                    if (!registrationRequired
0237:                            || ((regContext != null) && (registered))) {
0238:                        description = descrHandler.getServiceDescription(
0239:                                regContext, request.getDesiredLocales());
0240:                    } else {
0241:                        if (regContext == null && !registered) {
0242:
0243:                            description = descrHandler.getServiceDescription(
0244:                                    null, request.getDesiredLocales());
0245:                        } else {
0246:
0247:                            throw new WSRPException(
0248:                                    ErrorCodes.INVALID_REGISTRATION);
0249:                        }
0250:                    }
0251:
0252:                } catch (WSRPException e) {
0253:
0254:                    WSRPXHelper.handleWSRPException(e);
0255:
0256:                } catch (Throwable t) {
0257:                    t.printStackTrace();
0258:                }
0259:
0260:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0261:                    logger.exit(Logger.TRACE_HIGH, MN);
0262:                }
0263:
0264:                return description;
0265:            }
0266:
0267:            /**
0268:             * Registration Interface
0269:             */
0270:
0271:            /**
0272:             * Calls the ConsumerRegistry to register a certain consumer.
0273:             * Returns a registration context including a new registration handle. 
0274:             *
0275:             * @param request a generated wrapper containing all input arguments for this method
0276:             * 
0277:             * @return RegistrationContext
0278:             * 
0279:             * @exception java.rmi.RemoteException
0280:             */
0281:            public RegistrationContext register(RegistrationData request)
0282:                    throws java.rmi.RemoteException {
0283:
0284:                String MN = "register";
0285:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0286:                    logger.entry(Logger.TRACE_HIGH, MN);
0287:                }
0288:
0289:                RegistrationContext regContext = null;
0290:
0291:                try {
0292:
0293:                    // perform parameter check
0294:                    paramCheck.check(request, Constants.NILLABLE_FALSE);
0295:
0296:                    // add consumer to consumer registry
0297:                    Registration consumerRegistration = consumerRegistry
0298:                            .register(request);
0299:
0300:                    // return registration context (containing a regHandle)
0301:                    regContext = consumerRegistration.getRegistrationContext();
0302:
0303:                } catch (WSRPException e) {
0304:
0305:                    WSRPXHelper.handleWSRPException(e);
0306:
0307:                }
0308:
0309:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0310:                    logger.exit(Logger.TRACE_HIGH, MN);
0311:                }
0312:
0313:                return regContext;
0314:            }
0315:
0316:            /**
0317:             * Deregisters a certain consumer identified by a registration handle
0318:             * within the ConsumerRegistry. Throws an InvalidRegistration if
0319:             * there is no consumer registered with the given registration handle.  
0320:             * 
0321:             * @param request a generated wrapper containing all input arguments for this method
0322:             * 
0323:             * @exception java.rmi.RemoteException
0324:             * 
0325:             * @throws InvalidRegistration
0326:             *         The given registrationhandle is invalid / not yet registered
0327:             */
0328:            public ReturnAny deregister(RegistrationContext request)
0329:                    throws java.rmi.RemoteException {
0330:
0331:                String MN = "deregister";
0332:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0333:                    logger.entry(Logger.TRACE_HIGH, MN);
0334:                }
0335:
0336:                // perform parameter check
0337:                paramCheck.check(request, Constants.NILLABLE_FALSE);
0338:
0339:                try {
0340:
0341:                    checkRegistration(request);
0342:
0343:                } catch (WSRPException e) {
0344:
0345:                    WSRPXHelper.handleWSRPException(e);
0346:                }
0347:
0348:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0349:                    logger.exit(Logger.TRACE_HIGH, MN);
0350:                }
0351:
0352:                return new ReturnAny();
0353:            }
0354:
0355:            /**
0356:             * Modifies the registration of a certain consumer. Throws an InvalidRegistration
0357:             * if there is no consumer registered with the given registration handle.
0358:             * 
0359:             * @param request a generated wrapper containing all input arguments for this method
0360:             *
0361:             * @return A RegistrationState-object if the Producer chooses to have the Consumer provide
0362:             *         persistent storage for those registration states, else null.
0363:             * 
0364:             * @exception java.rmi.RemoteException
0365:             */
0366:            public RegistrationState modifyRegistration(
0367:                    ModifyRegistration request) throws java.rmi.RemoteException {
0368:
0369:                String MN = "modifyRegistration";
0370:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0371:                    logger.entry(Logger.TRACE_HIGH, MN);
0372:                }
0373:
0374:                // perform parameter check
0375:                paramCheck.check(request);
0376:
0377:                // TODO: what behaviour is there required=
0378:                // just set the new stuff
0379:                // or merge it in?
0380:
0381:                RegistrationState regState = null;
0382:
0383:                try {
0384:
0385:                    checkRegistration(request.getRegistrationContext());
0386:
0387:                } catch (WSRPException e) {
0388:
0389:                    WSRPXHelper.handleWSRPException(e);
0390:                }
0391:
0392:                Registration registration = consumerRegistry.get(request
0393:                        .getRegistrationContext().getRegistrationHandle());
0394:
0395:                // set new attributes
0396:                registration.setRegistrationData(request.getRegistrationData());
0397:                registration.setRegistrationContext(request
0398:                        .getRegistrationContext());
0399:
0400:                // return changed registration state
0401:                // -> case Producer chooses to have Consumer provide persistent storage
0402:                regState = new RegistrationState();
0403:                regState.setRegistrationState(registration
0404:                        .getRegistrationContext().getRegistrationState());
0405:                regState.setExtensions(null);
0406:
0407:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0408:                    logger.exit(Logger.TRACE_HIGH, MN);
0409:                }
0410:
0411:                return regState;
0412:
0413:            }
0414:
0415:            /**
0416:             * check if the registration handle is valid
0417:             * if not throw some RuntimeException
0418:             * 
0419:             * @param registrationContext
0420:             *               the registration handle of the consumer
0421:             * 
0422:             * @throws InvalidRegistration
0423:             * @throws MissingParameterFault
0424:             */
0425:            private void checkRegistration(
0426:                    RegistrationContext registrationContext)
0427:                    throws java.rmi.RemoteException, WSRPException {
0428:
0429:                String MN = "checkRegistration";
0430:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0431:                    logger.entry(Logger.TRACE_HIGH, MN);
0432:                }
0433:
0434:                paramCheck.check(registrationContext, Constants.NILLABLE_FALSE);
0435:
0436:                if (!consumerRegistry.check(registrationContext
0437:                        .getRegistrationHandle())) {
0438:                    throw new WSRPException(ErrorCodes.INVALID_REGISTRATION);
0439:
0440:                }
0441:
0442:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0443:                    logger.exit(Logger.TRACE_HIGH, MN);
0444:                }
0445:
0446:            }
0447:
0448:            /**
0449:             * Get the required portlet AND check for the registration.
0450:             * If the producer is enabled for registration the
0451:             * portlet's registration policy is being checked.
0452:             * 
0453:             * @param registrationContext
0454:             * @param portletHandle
0455:             * @return 
0456:             * @exception java.rmi.RemoteException
0457:             */
0458:            private Portlet getPortlet(RegistrationContext registrationContext,
0459:                    String portletHandle) throws java.rmi.RemoteException {
0460:
0461:                String MN = "getPortlet";
0462:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0463:                    logger.entry(Logger.TRACE_HIGH, MN);
0464:                }
0465:
0466:                Portlet portlet = null;
0467:
0468:                try {
0469:
0470:                    portlet = provider.getPortletPool().get(portletHandle);
0471:
0472:                    if (registrationRequired) {
0473:                        ProducerOfferedPortlet parent = null;
0474:
0475:                        if (portlet instanceof  ProducerOfferedPortlet) {
0476:                            parent = (ProducerOfferedPortlet) portlet;
0477:                        } else {
0478:                            //validate the consumers registration for the requested clone portlet
0479:                            String regHandle = registrationContext
0480:                                    .getRegistrationHandle();
0481:                            if (!provider.getPortletRegistrationFilter()
0482:                                    .isAvailable(regHandle, portletHandle)) {
0483:                                throw new WSRPException(
0484:                                        ErrorCodes.ACCESS_DENIED);
0485:                            }
0486:
0487:                            // get parent
0488:                            String parentHandle = ((ConsumerConfiguredPortlet) portlet)
0489:                                    .getParentHandle();
0490:
0491:                            parent = (ProducerOfferedPortlet) provider
0492:                                    .getPortletPool().get(parentHandle);
0493:
0494:                        }
0495:
0496:                        if ((parent != null) && parent.isRegistrationRequired()) {
0497:                            checkRegistration(registrationContext);
0498:                        }
0499:
0500:                    }
0501:
0502:                } catch (WSRPException e) {
0503:                    WSRPXHelper.handleWSRPException(e);
0504:                }
0505:
0506:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0507:                    logger.exit(Logger.TRACE_HIGH, MN);
0508:                }
0509:
0510:                return portlet;
0511:            }
0512:
0513:            /**
0514:             Internal method.
0515:             Validates if a cookie/the session value has been expired. If the cookie/session is expired an invalid
0516:             cookie fault will be thrown.
0517:             */
0518:            private void checkCookie() throws java.rmi.RemoteException,
0519:                    WSRPException {
0520:                // check if http-session has expired; if so throw InvalidCookie-Exception.
0521:                MessageContext msgContext = AxisEngine
0522:                        .getCurrentMessageContext();
0523:
0524:                HttpServletRequest servletRequest = (HttpServletRequest) msgContext
0525:                        .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
0526:                HttpSession session = servletRequest.getSession(false);
0527:
0528:                if (session == null) {
0529:                    throw new WSRPException(ErrorCodes.INVALID_COOKIE);
0530:                }
0531:
0532:            }
0533:
0534:            /**
0535:             * This method checks the MarkupParams from the consumer request and tries to
0536:             * find a match between the mimeType, mode, windowState and locale of the
0537:             * portlet description and the requested values. The first match which is found
0538:             * is returned in a <code>MarkupType</code> object where the arrays
0539:             * for modes and windowStates and locales have a length of one.  
0540:             *  
0541:             * @param portletDescription The description of the portlet.
0542:             * @param markupParams The markup params from the consumer request
0543:             * @return The <code>MarkupType</code> object which should be used to call the portlet.
0544:             * @throws WSRPException In case no match was found
0545:             **/
0546:            private MarkupType checkMarkupParams(
0547:                    PortletDescription portletDescription,
0548:                    MarkupParams markupParams) throws WSRPException {
0549:
0550:                String MN = "checkMarkupParams";
0551:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0552:                    logger.entry(Logger.TRACE_HIGH, MN);
0553:                }
0554:
0555:                MarkupType match = new MarkupType();
0556:
0557:                String[] reqMimeTypes = markupParams.getMimeTypes();
0558:                String reqMode = markupParams.getMode();
0559:                String reqWindowState = markupParams.getWindowState();
0560:                String[] reqLocales = markupParams.getLocales();
0561:                boolean foundMime, foundWindow, foundMode;
0562:                foundMime = foundWindow = foundMode = false;
0563:
0564:                MarkupType[] markupTypes = portletDescription.getMarkupTypes();
0565:                for (int i = 0; i < markupTypes.length; i++) {
0566:
0567:                    // check if mime type is supported by portlet
0568:                    String mimeType = markupTypes[i].getMimeType();
0569:                    for (int j = 0; j < reqMimeTypes.length; j++) {
0570:
0571:                        // TODO: Checking of mime types that are
0572:                        //        not fully qualified e.g. 'text/*'
0573:                        if (mimeType.equalsIgnoreCase(reqMimeTypes[j])) {
0574:                            foundMime = true;
0575:                            match.setMimeType(mimeType);
0576:
0577:                            // check if the mode is supported for this mime type
0578:                            String[] modes = markupTypes[i].getModes();
0579:                            for (int k = 0; k < modes.length; k++) {
0580:
0581:                                if (modes[k].equalsIgnoreCase(reqMode)) {
0582:                                    foundMode = true;
0583:                                    match.setModes(new String[] { reqMode });
0584:
0585:                                    //check window state
0586:                                    String[] windowStates = markupTypes[i]
0587:                                            .getWindowStates();
0588:                                    for (int l = 0; l < windowStates.length; l++) {
0589:
0590:                                        if (windowStates[l]
0591:                                                .equalsIgnoreCase(reqWindowState)) {
0592:                                            foundWindow = true;
0593:                                            match
0594:                                                    .setWindowStates(new String[] { reqWindowState });
0595:
0596:                                            // check locales
0597:                                            String[] locales = markupTypes[i]
0598:                                                    .getLocales();
0599:                                            if (locales == null) {
0600:                                                if (logger
0601:                                                        .isLogging(Logger.TRACE_HIGH)) {
0602:                                                    logger.exit(
0603:                                                            Logger.TRACE_HIGH,
0604:                                                            MN);
0605:                                                }
0606:                                                return match;
0607:                                            }
0608:
0609:                                            for (int m = 0; m < locales.length; m++) {
0610:                                                for (int n = 0; n < reqLocales.length; n++) {
0611:                                                    if (locales[m]
0612:                                                            .equalsIgnoreCase(reqLocales[n])) {
0613:                                                        match
0614:                                                                .setLocales(new String[] { locales[m] });
0615:
0616:                                                        if (logger
0617:                                                                .isLogging(Logger.TRACE_HIGH)) {
0618:                                                            logger
0619:                                                                    .exit(
0620:                                                                            Logger.TRACE_HIGH,
0621:                                                                            MN);
0622:                                                        }
0623:                                                        return match;
0624:                                                    } else {
0625:                                                        // lets see if at least a the language can be done
0626:                                                        if (LocaleHelper
0627:                                                                .getLanguageCode(
0628:                                                                        locales[m])
0629:                                                                .equalsIgnoreCase(
0630:                                                                        LocaleHelper
0631:                                                                                .getLanguageCode(reqLocales[n]))) {
0632:                                                            match
0633:                                                                    .setLocales(new String[] { LocaleHelper
0634:                                                                            .getLanguageCode(locales[m]) });
0635:
0636:                                                            if (logger
0637:                                                                    .isLogging(Logger.TRACE_HIGH)) {
0638:                                                                logger
0639:                                                                        .exit(
0640:                                                                                Logger.TRACE_HIGH,
0641:                                                                                MN);
0642:                                                            }
0643:
0644:                                                            return match;
0645:                                                        }
0646:
0647:                                                    }
0648:                                                }
0649:                                            }
0650:                                        }
0651:                                    }
0652:                                }
0653:                            }
0654:                        }
0655:                    }
0656:                }
0657:
0658:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0659:                    logger.exit(Logger.TRACE_HIGH, MN);
0660:                }
0661:
0662:                if (!foundMime)
0663:                    throw new WSRPException(ErrorCodes.UNSUPPORTED_MIME_TYPE);
0664:                if (!foundMode)
0665:                    throw new WSRPException(ErrorCodes.UNSUPPORTED_MODE);
0666:                if (!foundWindow)
0667:                    throw new WSRPException(ErrorCodes.UNSUPPORTED_WINDOW_STATE);
0668:
0669:                throw new WSRPException(ErrorCodes.UNSUPPORTED_LOCALE);
0670:            }
0671:
0672:            /**
0673:             * Markup Interface
0674:             */
0675:
0676:            /**
0677:             * <p>Requests the markup for rendering the current state of a portlet by calling
0678:             * the PortletInvoker.</p>
0679:             * <p>Throws InvalidHandleFault if there is no portlet in the PortletPool that
0680:             * corresponds to the provided portlet handle. Throws InvalidRegistration
0681:             * if there is no registration with the given registration handle available within
0682:             * the ConsumerRegistry (case registration is required).</p>
0683:             * <p>Fetches the portlet description from the DescriptionHandler to figure out
0684:             * whether the portlet supports template processing or not. If so, it checks whether
0685:             * templates are provided or not.</p>
0686:             *  
0687:             * @param request a generated wrapper containing all input arguments for this method
0688:             *
0689:             * @return MarkupResponse
0690:             *
0691:             * @exception java.rmi.RemoteException
0692:             */
0693:            public MarkupResponse getMarkup(GetMarkup request)
0694:                    throws java.rmi.RemoteException {
0695:
0696:                String MN = "getMarkup";
0697:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0698:                    logger.entry(Logger.TRACE_HIGH, MN);
0699:                }
0700:
0701:                MarkupResponse markupResponse = null;
0702:
0703:                try {
0704:
0705:                    // perform parameter check
0706:                    paramCheck.check(request);
0707:
0708:                    this .checkCookie();
0709:
0710:                    RegistrationContext regContext = request
0711:                            .getRegistrationContext();
0712:
0713:                    PortletDescription portletDescription = null;
0714:
0715:                    portletDescription = provider.getDescriptionHandler()
0716:                            .getPortletDescription(
0717:                                    request.getPortletContext()
0718:                                            .getPortletHandle(), regContext,
0719:                                    null,
0720:                                    request.getMarkupParams().getLocales());
0721:
0722:                    // check the markup params and find the locale, mimetype, mode, state whcih is used
0723:                    // for render
0724:                    MarkupType markupType = this .checkMarkupParams(
0725:                            portletDescription, request.getMarkupParams());
0726:
0727:                    //replace with markup types from the request
0728:                    request.getMarkupParams().setLocales(
0729:                            markupType.getLocales());
0730:                    request.getMarkupParams().setMimeTypes(
0731:                            new String[] { markupType.getMimeType() });
0732:                    request.getMarkupParams().setMode(markupType.getModes()[0]);
0733:                    request.getMarkupParams().setWindowState(
0734:                            markupType.getWindowStates()[0]);
0735:                    request.getMarkupParams().setWindowState(
0736:                            markupType.getWindowStates()[0]);
0737:
0738:                    // check if template processing is supported
0739:                    Boolean templateProcessing = portletDescription
0740:                            .getDoesUrlTemplateProcessing();
0741:                    if (templateProcessing == null) {
0742:                        // TODO get default
0743:                        templateProcessing = Boolean.FALSE;
0744:                    }
0745:
0746:                    if (templateProcessing.booleanValue()) {
0747:                        // consumer has to provide templates
0748:                        try {
0749:                            paramCheck.check(request.getRuntimeContext()
0750:                                    .getTemplates());
0751:                        } catch (MissingParametersFault e) {
0752:                            templateProcessing = Boolean.FALSE;
0753:                        }
0754:                    }
0755:
0756:                    // invoke the portlet service
0757:                    markupResponse = provider.getPortletInvoker()
0758:                            .invokeGetMarkup(request);
0759:
0760:                    // TODO: Check if markup requires rewriting.
0761:                    //        For now: If no template processing supported set requiresRewriting=true
0762:                    if (!templateProcessing.booleanValue()) {
0763:                        markupResponse.getMarkupContext()
0764:                                .setRequiresUrlRewriting(Boolean.TRUE);
0765:                    } else {
0766:                        markupResponse.getMarkupContext()
0767:                                .setRequiresUrlRewriting(Boolean.FALSE);
0768:                    }
0769:
0770:                } catch (WSRPException e) {
0771:                    WSRPXHelper.handleWSRPException(e);
0772:                }
0773:
0774:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0775:                    logger.exit(Logger.TRACE_HIGH, MN);
0776:                }
0777:
0778:                return markupResponse;
0779:            }
0780:
0781:            /**
0782:             * <p>Invokes a blocking interaction with the adressed portlet by calling
0783:             * the PortletInvoker</p>
0784:             * <p>Throws InvalidHandleFault if there is no portlet in the PortletPool that
0785:             * corresponds to the provided portlet handle. Throws InvalidRegistration
0786:             * if there is no registration with the given registration handle available within
0787:             * the ConsumerRegistry (case registration is required).</p>
0788:             *
0789:             * @param request a generated wrapper containing all input arguments for this method
0790:             *
0791:             * @return BlockingInteractionResponse
0792:             *
0793:             * @exception java.rmi.RemoteException
0794:             */
0795:            public BlockingInteractionResponse performBlockingInteraction(
0796:                    PerformBlockingInteraction request)
0797:                    throws java.rmi.RemoteException {
0798:                String MN = "performBlockingInteraction";
0799:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0800:                    logger.entry(Logger.TRACE_HIGH, MN);
0801:                }
0802:
0803:                BlockingInteractionResponse interactionResponse = null;
0804:
0805:                try {
0806:
0807:                    // perform parameter validation
0808:                    paramCheck.check(request);
0809:
0810:                    checkCookie();
0811:
0812:                    // check PortletStateChange setting
0813:                    // might clone before write
0814:                    PortletContext newPortletContext = null;
0815:                    newPortletContext = handlePortletStateChange(request);
0816:
0817:                    // check the markup params and find the locale, mimetype, mode, state whcih is used
0818:                    // for render
0819:                    PortletDescription portletDescription = null;
0820:
0821:                    portletDescription = provider.getDescriptionHandler()
0822:                            .getPortletDescription(
0823:                                    request.getPortletContext()
0824:                                            .getPortletHandle(),
0825:                                    request.getRegistrationContext(), null,
0826:                                    request.getMarkupParams().getLocales());
0827:
0828:                    MarkupType markupType = this .checkMarkupParams(
0829:                            portletDescription, request.getMarkupParams());
0830:
0831:                    //replace with markup types from the request
0832:                    request.getMarkupParams().setLocales(
0833:                            markupType.getLocales());
0834:                    request.getMarkupParams().setMimeTypes(
0835:                            new String[] { markupType.getMimeType() });
0836:                    request.getMarkupParams().setMode(markupType.getModes()[0]);
0837:                    request.getMarkupParams().setWindowState(
0838:                            markupType.getWindowStates()[0]);
0839:
0840:                    // invoke the service
0841:                    interactionResponse = provider.getPortletInvoker()
0842:                            .invokePerformBlockingInteraction(request);
0843:                    if (newPortletContext != null) {
0844:                        interactionResponse.getUpdateResponse()
0845:                                .setPortletContext(newPortletContext);
0846:                    }
0847:                } catch (WSRPException e) {
0848:                    WSRPXHelper.handleWSRPException(e);
0849:                }
0850:
0851:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0852:                    logger.exit(Logger.TRACE_HIGH, MN);
0853:                }
0854:
0855:                return interactionResponse;
0856:            }
0857:
0858:            /**
0859:             * checks if portlet may be accessed according to the PortletStateChange setting
0860:             * throws the appropriate exceptions
0861:             * or clones before write
0862:             * @param request
0863:             */
0864:            private PortletContext handlePortletStateChange(
0865:                    PerformBlockingInteraction request) throws RemoteException,
0866:                    WSRPException {
0867:
0868:                final String MN = "handlePortletStateChange";
0869:
0870:                PortletContext portletContext = null;
0871:                Portlet portlet = null;
0872:                try {
0873:                    portlet = provider.getPortletPool().get(
0874:                            request.getPortletContext().getPortletHandle());
0875:                } catch (WSRPException e) {
0876:                    if (e.getErrorCode() == ErrorCodes.GET_PORTLET_FAILED) {
0877:                        // portlet not in pool, must be an invalid handle
0878:                        WSRPXHelper.throwX(logger, Logger.ERROR, MN,
0879:                                ErrorCodes.INVALID_HANDLE);
0880:                    } else {
0881:                        WSRPXHelper.throwX(e.getErrorCode());
0882:                    }
0883:                }
0884:
0885:                // use the bad way to distinguish the portlet type
0886:                // TODO: need to refine that
0887:                StateChange stateChange = null;
0888:                stateChange = request.getInteractionParams()
0889:                        .getPortletStateChange();
0890:                if (portlet instanceof  ProducerOfferedPortlet) {
0891:                    if (stateChange.toString().equals(StateChange._readOnly)) {
0892:                        // force the consumer to clone since we can't make sure the portlet won't change state
0893:                        // in JSR168 case
0894:                        WSRPXHelper
0895:                                .throwX(ErrorCodes.PORTLET_STATE_CHANGE_REQUIRED);
0896:                    } else if (stateChange.toString().equals(
0897:                            StateChange._cloneBeforeWrite)) {
0898:                        // need to clone the portlet
0899:                        portletContext = handleCloneBeforeWrite(request);
0900:                    } else {
0901:                        // must be readWrite, can't access a POP in readWrite mode
0902:                        WSRPXHelper.throwX(ErrorCodes.OPERATION_FAILED);
0903:                    }
0904:                } else if (portlet instanceof  ConsumerConfiguredPortlet) {
0905:                    if (stateChange.toString().equals(StateChange._readOnly)) {
0906:                        // does it make sense to access a CCP in readOnly?
0907:                        // force consumer to clone if he access a CCP in readOnly
0908:                        WSRPXHelper
0909:                                .throwX(ErrorCodes.PORTLET_STATE_CHANGE_REQUIRED);
0910:                    } else if (stateChange.toString().equals(
0911:                            StateChange._cloneBeforeWrite)) {
0912:                        // need to clone the portlet
0913:                        portletContext = handleCloneBeforeWrite(request);
0914:                    } else {
0915:                        // must be readWrite, readWrite is fine, continue
0916:                    }
0917:                } else {
0918:                    // what is it then :-)
0919:                    WSRPXHelper.throwX(logger, Logger.ERROR, MN,
0920:                            ErrorCodes.OPERATION_FAILED);
0921:                }
0922:
0923:                return portletContext;
0924:            }
0925:
0926:            /**
0927:             * clone portlet and its session before performBlockingInteraction continues
0928:             * @param request
0929:             */
0930:            private PortletContext handleCloneBeforeWrite(
0931:                    PerformBlockingInteraction request) throws WSRPException,
0932:                    java.rmi.RemoteException {
0933:
0934:                // clone the portlet
0935:                PortletContext portletContext = null;
0936:                ClonePortlet cloneRequest = new ClonePortlet();
0937:                cloneRequest.setPortletContext(request.getPortletContext());
0938:                cloneRequest.setRegistrationContext(request
0939:                        .getRegistrationContext());
0940:                cloneRequest.setUserContext(request.getUserContext());
0941:
0942:                portletContext = clonePortlet(cloneRequest);
0943:
0944:                // change the portletContext in the original request
0945:                // thus we continue with the new cloned portlet
0946:                request.setPortletContext(portletContext);
0947:
0948:                // TODO: copy session        
0949:
0950:                return portletContext;
0951:            }
0952:
0953:            /**                                                                          
0954:             * Creates a new HTTP session and initializes it
0955:             * <p>Throws InvalidRegistration if there is no registration with the given
0956:             * registration handle available within the ConsumerRegistry (if registration is
0957:             * required).</p>
0958:             *
0959:             * @param request a generated wrapper containing all input arguments for this method
0960:             * 
0961:             * @exception java.rmi.RemoteException
0962:             *
0963:             * @return null
0964:             * 
0965:             * @throws MissingParameterFault
0966:             * @throws InvalidRegistration
0967:             */
0968:            public ReturnAny initCookie(InitCookie request)
0969:                    throws java.rmi.RemoteException {
0970:
0971:                String MN = "initCookie";
0972:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0973:                    logger.entry(Logger.TRACE_HIGH, MN);
0974:                }
0975:                try {
0976:
0977:                    // perform parameter check
0978:                    paramCheck.check(request);
0979:
0980:                    // if registration is required, a valid registration must exist
0981:                    // for the given registration handle
0982:                    if (registrationRequired) {
0983:                        checkRegistration(request.getRegistrationContext());
0984:                    }
0985:
0986:                    // create the HTTP session
0987:                    createSession();
0988:
0989:                } catch (WSRPException e) {
0990:
0991:                    WSRPXHelper.handleWSRPException(e);
0992:                }
0993:
0994:                if (logger.isLogging(Logger.TRACE_HIGH)) {
0995:                    logger.exit(Logger.TRACE_HIGH, MN);
0996:                }
0997:
0998:                return new ReturnAny();
0999:            }
1000:
1001:            /**
1002:             * <p>Destroys the sessions adressed by the delivered sessionIDs.
1003:             * Returns null by default.</p>
1004:             * <p>Throws InvalidRegistration if there is no registration with the given
1005:             * registration handle available within the ConsumerRegistry (case registration is
1006:             * required).</p>
1007:             *
1008:             * @param request a generated wrapper containing all input arguments for this method
1009:             * 
1010:             * @return null
1011:             */
1012:            public ReturnAny releaseSessions(ReleaseSessions request)
1013:                    throws java.rmi.RemoteException {
1014:
1015:                String MN = "releaseSession";
1016:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1017:                    logger.entry(Logger.TRACE_HIGH, MN);
1018:                }
1019:
1020:                // since we don't use the WSRP sessions
1021:                // we always report success
1022:
1023:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1024:                    logger.exit(Logger.TRACE_HIGH, MN);
1025:                }
1026:                return new ReturnAny();
1027:            }
1028:
1029:            /**
1030:             * Portlet Management Interface
1031:             */
1032:
1033:            /**
1034:             * <p>Fetches a PortletDescription from the DescriptionHandler.</p>
1035:             * <p>Throws InvalidHandleFault if there is no portlet in the PortletPool that
1036:             * corresponds to the provided portlet handle. Throws InvalidRegistration
1037:             * if there is no registration with the given registration handle available within
1038:             * the ConsumerRegistry (case registration is required).</p>
1039:             * 
1040:             * @param request a generated wrapper containing all input arguments for this method
1041:             *
1042:             * @return 
1043:             *
1044:             * @exception java.rmi.RemoteException
1045:             */
1046:            public PortletDescriptionResponse getPortletDescription(
1047:                    GetPortletDescription request)
1048:                    throws java.rmi.RemoteException {
1049:
1050:                String MN = "getPortletDescription";
1051:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1052:                    logger.entry(Logger.TRACE_HIGH, MN);
1053:                }
1054:
1055:                PortletDescription portletDescription = null;
1056:                PortletDescriptionResponse response = null;
1057:
1058:                try {
1059:
1060:                    // perform parameter check
1061:                    paramCheck.check(request);
1062:
1063:                    RegistrationContext regContext = request
1064:                            .getRegistrationContext();
1065:
1066:                    portletDescription = provider.getDescriptionHandler()
1067:                            .getPortletDescription(
1068:                                    request.getPortletContext()
1069:                                            .getPortletHandle(), regContext,
1070:                                    null, request.getDesiredLocales());
1071:
1072:                    response = new PortletDescriptionResponse();
1073:                    response.setPortletDescription(portletDescription);
1074:                    response.setResourceList(null);
1075:                    response.setExtensions(null);
1076:
1077:                } catch (WSRPException e) {
1078:
1079:                    WSRPXHelper.handleWSRPException(e);
1080:
1081:                }
1082:
1083:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1084:                    logger.exit(Logger.TRACE_HIGH, MN);
1085:                }
1086:
1087:                return response;
1088:            }
1089:
1090:            /**
1091:             * <p>Calls the PortletPool to clone a portlet.</p>
1092:             * <p>Throws InvalidHandleFault if there is no portlet to be cloned in the PortletPool
1093:             * that corresponds to the provided portlet handle. Throws InvalidRegistration
1094:             * if there is no registration with the given registration handle available within
1095:             * the ConsumerRegistry (case registration is required).</p>
1096:             * 
1097:             * @param request a generated wrapper containing all input arguments for this method
1098:             * @return 
1099:             * @exception java.rmi.RemoteException
1100:             */
1101:            public PortletContext clonePortlet(ClonePortlet request)
1102:                    throws java.rmi.RemoteException {
1103:
1104:                String MN = "clonePortlet";
1105:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1106:                    logger.entry(Logger.TRACE_HIGH, MN);
1107:                }
1108:
1109:                PortletContext portletContext = null;
1110:
1111:                try {
1112:                    // parameter validation
1113:                    paramCheck.check(request);
1114:
1115:                    PortletStateManager portletStateManager = null;
1116:
1117:                    portletStateManager = provider.getPortletStateManager();
1118:
1119:                    String orgPortletHandle = request.getPortletContext()
1120:                            .getPortletHandle();
1121:
1122:                    Portlet portletClone = null;
1123:
1124:                    // clone portlet
1125:                    portletClone = provider.getPortletPool().clone(
1126:                            orgPortletHandle);
1127:
1128:                    if (portletClone != null) {
1129:
1130:                        String newPortletHandle = portletClone
1131:                                .getPortletHandle();
1132:
1133:                        // create portlet context
1134:                        portletContext = new PortletContext();
1135:                        portletContext.setPortletHandle(newPortletHandle);
1136:                        portletContext.setPortletState(portletStateManager
1137:                                .getAsString(newPortletHandle).getBytes());
1138:                        portletContext.setExtensions(null);
1139:
1140:                        // remember clone handle for this registration
1141:                        RegistrationContext regContext = request
1142:                                .getRegistrationContext();
1143:                        if (regContext != null) {
1144:                            String regHandle = regContext
1145:                                    .getRegistrationHandle();
1146:                            if (regHandle != null
1147:                                    && consumerRegistry.check(regHandle) == true) {
1148:                                provider.getPortletRegistrationFilterWriter()
1149:                                        .makeAvailable(regHandle,
1150:                                                newPortletHandle);
1151:                            }
1152:                        }
1153:
1154:                    } else {
1155:                        throw new WSRPException(ErrorCodes.OPERATION_FAILED);
1156:                    }
1157:
1158:                } catch (WSRPException e) {
1159:                    WSRPXHelper.handleWSRPException(e);
1160:                }
1161:
1162:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1163:                    logger.exit(Logger.TRACE_HIGH, MN);
1164:                }
1165:
1166:                return portletContext;
1167:            }
1168:
1169:            /**
1170:             * <p>Removes all portlets corresponding to the provided portlet handles from the
1171:             * PortletPool. All portlet handles refering to portlets that cannot be destroyed
1172:             * (e.g. portlet handles from Producer Offered Portlets) will be returned within the
1173:             * DestroyPortletResponse as DestroyFailed-objects.</p>
1174:             * <p>Throws InvalidRegistration if there is no registration with the given
1175:             * registration handle available within the ConsumerRegistry (case registration
1176:             * is required).</p>
1177:             *
1178:             * @param request a generated wrapper containing all input arguments for this method
1179:             *
1180:             * @exception java.rmi.RemoteException
1181:             */
1182:            public DestroyPortletsResponse destroyPortlets(
1183:                    DestroyPortlets request) throws java.rmi.RemoteException {
1184:
1185:                String MN = "destroyPortlets";
1186:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1187:                    logger.entry(Logger.TRACE_HIGH, MN);
1188:                }
1189:
1190:                // perform paramCheck.check
1191:                paramCheck.check(request);
1192:
1193:                try {
1194:
1195:                    checkRegistration(request.getRegistrationContext());
1196:
1197:                    // remove ConsumerPortletRegistrations
1198:                    RegistrationContext regContext = request
1199:                            .getRegistrationContext();
1200:                    if (regContext != null) {
1201:                        String regHandle = regContext.getRegistrationHandle();
1202:                        if (regHandle != null
1203:                                && consumerRegistry.check(regHandle) == true) {
1204:                            provider
1205:                                    .getPortletRegistrationFilterWriter()
1206:                                    .remove(
1207:                                            regHandle,
1208:                                            Arrays
1209:                                                    .asList(
1210:                                                            request
1211:                                                                    .getPortletHandles())
1212:                                                    .iterator());
1213:                        }
1214:                    }
1215:
1216:                } catch (WSRPException e) {
1217:
1218:                    WSRPXHelper.handleWSRPException(e);
1219:                }
1220:
1221:                Iterator handles = Arrays.asList(request.getPortletHandles())
1222:                        .iterator();
1223:
1224:                // result iterator contains portlet handles refering to those portlets
1225:                // that could not be deleted (e.g. producer offered portlets)
1226:                Iterator result = provider.getPortletPool().destroySeveral(
1227:                        handles);
1228:
1229:                ArrayList failedHandles = new ArrayList();
1230:
1231:                while (result.hasNext()) {
1232:
1233:                    DestroyFailed failed = new DestroyFailed();
1234:                    failed.setPortletHandle(result.next().toString());
1235:                    failed
1236:                            .setReason("Portlet handle refers to a producer offered portlet!");
1237:                    failedHandles.add(failed);
1238:
1239:                }
1240:
1241:                DestroyFailed[] destroyFailedArray = new DestroyFailed[failedHandles
1242:                        .size()];
1243:                failedHandles.toArray(destroyFailedArray);
1244:
1245:                DestroyPortletsResponse response = new DestroyPortletsResponse();
1246:                response.setDestroyFailed(destroyFailedArray);
1247:                response.setExtensions(null);
1248:
1249:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1250:                    logger.exit(Logger.TRACE_HIGH, MN);
1251:                }
1252:
1253:                return response;
1254:            }
1255:
1256:            /**
1257:             * <p>Sets the properties of a portlet.</p>
1258:             * <p>Throws InvalidHandleFault if there is no portlet in the PortletPool
1259:             * that corresponds to the provided portlet handle. Throws InvalidRegistration
1260:             * if there is no registration with the given registration handle available within
1261:             * the ConsumerRegistry (case registration is required).</p>
1262:             *
1263:             * @param request a generated wrapper containing all input arguments for this method
1264:             *
1265:             * @return 
1266:             * @exception java.rmi.RemoteException
1267:             */
1268:            public PortletContext setPortletProperties(
1269:                    SetPortletProperties request)
1270:                    throws java.rmi.RemoteException {
1271:
1272:                String MN = "setPortletProperties";
1273:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1274:                    logger.entry(Logger.TRACE_HIGH, MN);
1275:                }
1276:
1277:                PortletContext portletContext = null;
1278:
1279:                try {
1280:
1281:                    // perform parameter check
1282:                    paramCheck.check(request);
1283:
1284:                    String portletHandle = request.getPortletContext()
1285:                            .getPortletHandle();
1286:                    Portlet portlet = getPortlet(request
1287:                            .getRegistrationContext(), portletHandle);
1288:
1289:                    // check if portlet is a consumer configured portlet //TODO? 
1290:                    if (portlet instanceof  ConsumerConfiguredPortlet) {
1291:
1292:                        provider.getPortletStateManager().setAsPropertyList(
1293:                                portletHandle, request.getPropertyList());
1294:                        portletContext = request.getPortletContext();
1295:
1296:                    } else {
1297:                        throw new WSRPException(
1298:                                ErrorCodes.INCONSISTENT_PARAMETERS);
1299:                    }
1300:
1301:                } catch (WSRPException e) {
1302:
1303:                    WSRPXHelper.handleWSRPException(e);
1304:
1305:                }
1306:
1307:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1308:                    logger.exit(Logger.TRACE_HIGH, MN);
1309:                }
1310:
1311:                return portletContext;
1312:
1313:            }
1314:
1315:            /**
1316:             * <p>Fetches the current property values of a portlet and returns them.</p> 
1317:             * <p>Throws InvalidHandleFault if there is no portlet in the PortletPool
1318:             * that corresponds to the provided portlet handle. Throws InvalidRegistration
1319:             * if there is no registration with the given registration handle available within
1320:             * the ConsumerRegistry (case registration is required).</p>
1321:             * 
1322:             * @param request a generated wrapper containing all input arguments for this method
1323:             *
1324:             * @return PropertyList containing all properties of the adressed portlet
1325:             *
1326:             * @exception java.rmi.RemoteException
1327:             */
1328:            public PropertyList getPortletProperties(
1329:                    GetPortletProperties request)
1330:                    throws java.rmi.RemoteException {
1331:
1332:                String MN = "getPortletProperties";
1333:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1334:                    logger.entry(Logger.TRACE_HIGH, MN);
1335:                }
1336:
1337:                PropertyList propertyList = null;
1338:
1339:                try {
1340:                    // perform parameter check
1341:                    paramCheck.check(request);
1342:
1343:                    String portletHandle = request.getPortletContext()
1344:                            .getPortletHandle();
1345:                    getPortlet(request.getRegistrationContext(), portletHandle);
1346:
1347:                    PortletStateManager portletStateManager = provider
1348:                            .getPortletStateManager();
1349:                    propertyList = portletStateManager
1350:                            .getAsPropertyList(portletHandle);
1351:
1352:                } catch (WSRPException e) {
1353:
1354:                    WSRPXHelper.handleWSRPException(e);
1355:
1356:                }
1357:
1358:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1359:                    logger.exit(Logger.TRACE_HIGH, MN);
1360:                }
1361:
1362:                return propertyList;
1363:            }
1364:
1365:            /**
1366:             * <p>Returns a model description containing the property descriptions of all properties
1367:             * of a portlet.</p>
1368:             * <p>Throws InvalidHandleFault if there is no portlet in the PortletPool
1369:             * that corresponds to the provided portlet handle. Throws InvalidRegistration
1370:             * if there is no registration with the given registration handle available within
1371:             * the ConsumerRegistry (case registration is required).</p>
1372:             * 
1373:             * @param request a generated wrapper containing all input arguments for this method
1374:             *
1375:             * @return 
1376:             *
1377:             * @exception java.rmi.RemoteException
1378:             */
1379:            public PortletPropertyDescriptionResponse getPortletPropertyDescription(
1380:                    GetPortletPropertyDescription request)
1381:                    throws java.rmi.RemoteException {
1382:
1383:                String MN = "getPortletPropertyDescription";
1384:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1385:                    logger.entry(Logger.TRACE_HIGH, MN);
1386:                }
1387:
1388:                PortletPropertyDescriptionResponse response = null;
1389:
1390:                try {
1391:
1392:                    // perform parameter check
1393:                    paramCheck.check(request);
1394:
1395:                    String portletHandle = request.getPortletContext()
1396:                            .getPortletHandle();
1397:                    getPortlet(request.getRegistrationContext(), portletHandle);
1398:
1399:                    response = new PortletPropertyDescriptionResponse();
1400:                    response.setModelDescription(provider
1401:                            .getPortletStateManager().getModelDescription(
1402:                                    portletHandle, request.getDesiredLocales(),
1403:                                    false));
1404:                    response.setResourceList(null);
1405:                    response.setExtensions(null);
1406:
1407:                } catch (WSRPException e) {
1408:
1409:                    WSRPXHelper.handleWSRPException(e);
1410:
1411:                }
1412:
1413:                if (logger.isLogging(Logger.TRACE_HIGH)) {
1414:                    logger.exit(Logger.TRACE_HIGH, MN);
1415:                }
1416:
1417:                return response;
1418:            }
1419:
1420:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.