Source Code Cross Referenced for MarkupHandler.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » wsrp » producer » 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 » jboss portal 2.6.4 » org.jboss.portal.wsrp.producer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.wsrp.producer;
023:
024:        import org.jboss.portal.portlet.PortletInvokerException;
025:        import org.jboss.portal.portlet.invocation.response.ErrorResponse;
026:        import org.jboss.portal.portlet.invocation.response.FragmentResponse;
027:        import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
028:        import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
029:        import org.jboss.portal.portlet.invocation.response.RenderResponse;
030:        import org.jboss.portal.portlet.state.producer.PortletStateChangeRequiredException;
031:        import org.jboss.portal.wsrp.WSRPExceptionFactory;
032:        import org.jboss.portal.wsrp.core.AccessDeniedFault;
033:        import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
034:        import org.jboss.portal.wsrp.core.GetMarkup;
035:        import org.jboss.portal.wsrp.core.InconsistentParametersFault;
036:        import org.jboss.portal.wsrp.core.InitCookie;
037:        import org.jboss.portal.wsrp.core.InteractionParams;
038:        import org.jboss.portal.wsrp.core.InvalidCookieFault;
039:        import org.jboss.portal.wsrp.core.InvalidHandleFault;
040:        import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
041:        import org.jboss.portal.wsrp.core.InvalidSessionFault;
042:        import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
043:        import org.jboss.portal.wsrp.core.MarkupResponse;
044:        import org.jboss.portal.wsrp.core.MissingParametersFault;
045:        import org.jboss.portal.wsrp.core.OperationFailedFault;
046:        import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
047:        import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
048:        import org.jboss.portal.wsrp.core.ReleaseSessions;
049:        import org.jboss.portal.wsrp.core.ReturnAny;
050:        import org.jboss.portal.wsrp.core.UnsupportedLocaleFault;
051:        import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
052:        import org.jboss.portal.wsrp.core.UnsupportedModeFault;
053:        import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
054:        import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
055:        import org.jboss.portal.wsrp.servlet.ServletAccess;
056:
057:        import javax.portlet.PortletModeException;
058:        import javax.portlet.WindowStateException;
059:        import java.rmi.RemoteException;
060:
061:        /**
062:         * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
063:         * @version $Revision: 8784 $
064:         * @since 2.4
065:         */
066:        class MarkupHandler extends ServiceHandler implements 
067:                WSRP_v1_Markup_PortType {
068:            static final String PBI = "PerformBlockingInteraction";
069:            static final String GET_MARKUP = "GetMarkup";
070:
071:            MarkupHandler(WSRPProducerImpl producer) {
072:                super (producer);
073:            }
074:
075:            // Markup implementation ********************************************************************************************
076:
077:            public MarkupResponse getMarkup(GetMarkup getMarkup)
078:                    throws UnsupportedWindowStateFault, InvalidCookieFault,
079:                    InvalidSessionFault, AccessDeniedFault,
080:                    InconsistentParametersFault, InvalidHandleFault,
081:                    UnsupportedLocaleFault, UnsupportedModeFault,
082:                    OperationFailedFault, MissingParametersFault,
083:                    InvalidUserCategoryFault, InvalidRegistrationFault,
084:                    UnsupportedMimeTypeFault, RemoteException {
085:                WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(
086:                        getMarkup, GET_MARKUP);
087:
088:                RequestProcessor requestProcessor = new RenderRequestProcessor(
089:                        producer, getMarkup);
090:
091:                String handle = requestProcessor.getPortletContext()
092:                        .getPortletHandle();
093:                PortletInvocationResponse response;
094:                try {
095:                    log.debug("RenderInvocation on portlet '" + handle + "'");
096:                    response = producer.getInvoker().invoke(
097:                            requestProcessor.getInvocation());
098:                    log.debug("RenderInvocation done");
099:                } catch (PortletInvokerException e) {
100:                    throw WSRPExceptionFactory.throwSOAPFaultException(
101:                            WSRPExceptionFactory.OPERATION_FAILED,
102:                            "Could not render portlet '" + handle + "'", e);
103:                }
104:
105:                checkForError(response);
106:
107:                return (MarkupResponse) requestProcessor
108:                        .processResponse(response);
109:            }
110:
111:            public BlockingInteractionResponse performBlockingInteraction(
112:                    PerformBlockingInteraction performBlockingInteraction)
113:                    throws InvalidSessionFault, UnsupportedModeFault,
114:                    UnsupportedMimeTypeFault, OperationFailedFault,
115:                    UnsupportedWindowStateFault, UnsupportedLocaleFault,
116:                    AccessDeniedFault, PortletStateChangeRequiredFault,
117:                    InvalidRegistrationFault, MissingParametersFault,
118:                    InvalidUserCategoryFault, InconsistentParametersFault,
119:                    InvalidHandleFault, InvalidCookieFault, RemoteException {
120:                WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(
121:                        performBlockingInteraction, PBI);
122:                final InteractionParams interactionParams = performBlockingInteraction
123:                        .getInteractionParams();
124:                WSRPExceptionFactory
125:                        .throwMissingParametersFaultIfValueIsMissing(
126:                                interactionParams, "InteractionParams", PBI);
127:
128:                RequestProcessor requestProcessor = new ActionRequestProcessor(
129:                        producer, performBlockingInteraction, interactionParams);
130:
131:                PortletInvocationResponse response;
132:                String handle = requestProcessor.getPortletContext()
133:                        .getPortletHandle();
134:                try {
135:                    log.debug("ActionInvocation on portlet '" + handle + "'");
136:                    response = producer.getInvoker().invoke(
137:                            requestProcessor.getInvocation());
138:                    log.debug("ActionInvocation done");
139:                } catch (PortletStateChangeRequiredException e) {
140:                    throw WSRPExceptionFactory.throwSOAPFaultException(
141:                            WSRPExceptionFactory.PORTLET_STATE_CHANGE_REQUIRED,
142:                            e.getLocalizedMessage(), e);
143:                } catch (PortletInvokerException e) {
144:                    throw WSRPExceptionFactory.throwSOAPFaultException(
145:                            WSRPExceptionFactory.OPERATION_FAILED,
146:                            "Could not perform action on portlet '" + handle
147:                                    + "'", e);
148:                }
149:
150:                checkForError(response);
151:
152:                return (BlockingInteractionResponse) requestProcessor
153:                        .processResponse(response);
154:            }
155:
156:            public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
157:                    throws InvalidRegistrationFault, OperationFailedFault,
158:                    MissingParametersFault, AccessDeniedFault, RemoteException {
159:                // our producer never sends session ids so a Consumer trying to release sessions is an error condition
160:                throwOperationFaultOnSessionOperation();
161:                return null;
162:            }
163:
164:            public ReturnAny initCookie(InitCookie initCookie)
165:                    throws AccessDeniedFault, OperationFailedFault,
166:                    InvalidRegistrationFault, RemoteException {
167:                WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(
168:                        initCookie, "InitCookie");
169:                producer.getRegistrationOrFailIfInvalid(initCookie
170:                        .getRegistrationContext());
171:
172:                // Force HTTP session creation... this is required for BEA Weblogic version < 9.2.
173:                // See http://jira.jboss.com/jira/browse/JBPORTAL-1220
174:                String sessionId = ServletAccess.getRequest().getSession()
175:                        .getId();
176:                log
177:                        .debug("Got init cookie operation, created a session with id "
178:                                + sessionId);
179:
180:                return new ReturnAny();
181:            }
182:
183:            static void throwOperationFaultOnSessionOperation() {
184:                throw WSRPExceptionFactory
185:                        .throwSOAPFaultException(
186:                                WSRPExceptionFactory.OPERATION_FAILED,
187:                                "JBoss Portal's Producer"
188:                                        + " manages sessions completely on the server side, passing or trying to release sessionIDs is therefore an error.",
189:                                null);
190:            }
191:
192:            private void checkForError(PortletInvocationResponse response)
193:                    throws UnsupportedModeFault, OperationFailedFault,
194:                    UnsupportedWindowStateFault {
195:                if (response instanceof  ErrorResponse) {
196:                    ErrorResponse errorResult = (ErrorResponse) response;
197:                    Throwable cause = errorResult.getCause();
198:                    if (cause instanceof  PortletModeException) {
199:                        throw WSRPExceptionFactory.throwSOAPFaultException(
200:                                WSRPExceptionFactory.UNSUPPORTED_MODE,
201:                                "Unsupported mode: "
202:                                        + ((PortletModeException) cause)
203:                                                .getMode(), null);
204:                    }
205:                    if (cause instanceof  WindowStateException) {
206:                        throw WSRPExceptionFactory.throwSOAPFaultException(
207:                                WSRPExceptionFactory.UNSUPPORTED_WINDOW_STATE,
208:                                "Unsupported window state: "
209:                                        + ((WindowStateException) cause)
210:                                                .getState(), null);
211:                    }
212:                    // todo: deal with other exceptions
213:
214:                    // we're not sure what happened so throw an OperationFailedFault
215:                    throw WSRPExceptionFactory.throwSOAPFaultException(
216:                            WSRPExceptionFactory.OPERATION_FAILED, errorResult
217:                                    .getMessage(), cause);
218:
219:                } else if (!(response instanceof  HTTPRedirectionResponse
220:                        || response instanceof  FragmentResponse || response instanceof  RenderResponse)) {
221:                    throw WSRPExceptionFactory.throwSOAPFaultException(
222:                            WSRPExceptionFactory.OPERATION_FAILED,
223:                            "Unsupported result type: "
224:                                    + response.getClass().getName(), null);
225:                }
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.