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.test.wsrp.framework;
023:
024: import org.jboss.portal.jems.as.system.AbstractJBossService;
025: import org.jboss.portal.registration.RegistrationManager;
026: import org.jboss.portal.wsrp.WSRPTypeFactory;
027: import org.jboss.portal.wsrp.core.AccessDeniedFault;
028: import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
029: import org.jboss.portal.wsrp.core.ClonePortlet;
030: import org.jboss.portal.wsrp.core.CookieProtocol;
031: import org.jboss.portal.wsrp.core.DestroyPortlets;
032: import org.jboss.portal.wsrp.core.DestroyPortletsResponse;
033: import org.jboss.portal.wsrp.core.GetMarkup;
034: import org.jboss.portal.wsrp.core.GetPortletDescription;
035: import org.jboss.portal.wsrp.core.GetPortletProperties;
036: import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
037: import org.jboss.portal.wsrp.core.GetServiceDescription;
038: import org.jboss.portal.wsrp.core.InconsistentParametersFault;
039: import org.jboss.portal.wsrp.core.InitCookie;
040: import org.jboss.portal.wsrp.core.InvalidCookieFault;
041: import org.jboss.portal.wsrp.core.InvalidHandleFault;
042: import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
043: import org.jboss.portal.wsrp.core.InvalidSessionFault;
044: import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
045: import org.jboss.portal.wsrp.core.MarkupResponse;
046: import org.jboss.portal.wsrp.core.MissingParametersFault;
047: import org.jboss.portal.wsrp.core.ModifyRegistration;
048: import org.jboss.portal.wsrp.core.OperationFailedFault;
049: import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
050: import org.jboss.portal.wsrp.core.PortletContext;
051: import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
052: import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
053: import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
054: import org.jboss.portal.wsrp.core.PropertyList;
055: import org.jboss.portal.wsrp.core.RegistrationContext;
056: import org.jboss.portal.wsrp.core.RegistrationData;
057: import org.jboss.portal.wsrp.core.RegistrationState;
058: import org.jboss.portal.wsrp.core.ReleaseSessions;
059: import org.jboss.portal.wsrp.core.ReturnAny;
060: import org.jboss.portal.wsrp.core.ServiceDescription;
061: import org.jboss.portal.wsrp.core.SetPortletProperties;
062: import org.jboss.portal.wsrp.core.UnsupportedLocaleFault;
063: import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
064: import org.jboss.portal.wsrp.core.UnsupportedModeFault;
065: import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
066: import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
067: import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
068:
069: import java.rmi.RemoteException;
070:
071: /**
072: * This is dummy clone of org.jboss.portal.wsrp.producer.WSRPProducerImpl customizable from client side. Just for
073: * consumer implementation testing purposes.
074: *
075: * @author <a href="mailto:Boleslaw.Dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
076: * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
077: * @version $Revision: 8784 $
078: * @since 2.4
079: */
080: public class TestWSRPProducerImpl extends AbstractJBossService
081: implements TestWSRPProducer {
082: private int sessionExpirationTime = DEFAULT_SESSION_EXPIRATION_TIME;
083:
084: private CookieProtocol requiresInitCookie = CookieProtocol.none;
085:
086: private BehaviorRegistry behaviorRegistry = new BehaviorRegistry();
087:
088: public static final String USER_COOKIE = "cookie";
089:
090: public TestWSRPProducerImpl() {
091: reset();
092: }
093:
094: public BehaviorRegistry getBehaviorRegistry() {
095: return behaviorRegistry;
096: }
097:
098: public void reset() {
099: requiresInitCookie = null;
100: behaviorRegistry.clear();
101: }
102:
103: private MarkupBehavior getMarkupBehaviorFor(String portletHandle)
104: throws InvalidHandleFault {
105: return behaviorRegistry.getMarkupBehaviorFor(portletHandle);
106: }
107:
108: private ServiceDescriptionBehavior getServiceDescriptionBehavior() {
109: return behaviorRegistry.getServiceDescriptionBehavior();
110: }
111:
112: public PortletManagementBehavior getPortletManagementBehavior() {
113: return behaviorRegistry.getPortletManagementBehavior();
114: }
115:
116: // ServiceDescription implementation ********************************************************************************
117:
118: public ServiceDescription getServiceDescription(
119: GetServiceDescription gs) throws InvalidRegistrationFault,
120: OperationFailedFault, RemoteException {
121: return getServiceDescriptionBehavior()
122: .getServiceDescription(gs);
123: }
124:
125: // MarkupService implementation *************************************************************************************
126:
127: public MarkupResponse getMarkup(GetMarkup getMarkup)
128: throws UnsupportedWindowStateFault, InvalidCookieFault,
129: InvalidSessionFault, AccessDeniedFault,
130: InconsistentParametersFault, InvalidHandleFault,
131: UnsupportedLocaleFault, UnsupportedModeFault,
132: OperationFailedFault, MissingParametersFault,
133: InvalidUserCategoryFault, InvalidRegistrationFault,
134: UnsupportedMimeTypeFault, RemoteException {
135:
136: return getMarkupBehaviorFor(
137: getMarkup.getPortletContext().getPortletHandle())
138: .getMarkup(getMarkup);
139: }
140:
141: public BlockingInteractionResponse performBlockingInteraction(
142: PerformBlockingInteraction performBlockingInteraction)
143: throws InvalidSessionFault, UnsupportedModeFault,
144: UnsupportedMimeTypeFault, OperationFailedFault,
145: UnsupportedWindowStateFault, UnsupportedLocaleFault,
146: AccessDeniedFault, PortletStateChangeRequiredFault,
147: InvalidRegistrationFault, MissingParametersFault,
148: InvalidUserCategoryFault, InconsistentParametersFault,
149: InvalidHandleFault, InvalidCookieFault, RemoteException {
150:
151: return getMarkupBehaviorFor(
152: performBlockingInteraction.getPortletContext()
153: .getPortletHandle())
154: .performBlockingInteraction(performBlockingInteraction);
155: }
156:
157: public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
158: throws InvalidRegistrationFault, OperationFailedFault,
159: MissingParametersFault, AccessDeniedFault, RemoteException {
160: return null;
161: }
162:
163: public ReturnAny initCookie(InitCookie initCookie)
164: throws AccessDeniedFault, OperationFailedFault,
165: InvalidRegistrationFault, RemoteException {
166: // should only be called if we required cookies to be initialized
167: if (requiresInitCookie == null) {
168: throw new OperationFailedFault();
169: }
170:
171: return null;
172: }
173:
174: // Registration implementation **************************************************************************************
175:
176: public RegistrationContext register(RegistrationData register)
177: throws MissingParametersFault, OperationFailedFault,
178: RemoteException {
179: return WSRPTypeFactory
180: .createRegistrationContext("registration");
181: }
182:
183: public ReturnAny deregister(RegistrationContext deregister)
184: throws OperationFailedFault, InvalidRegistrationFault,
185: RemoteException {
186: return null;
187: }
188:
189: public RegistrationState modifyRegistration(
190: ModifyRegistration modifyRegistration)
191: throws MissingParametersFault, OperationFailedFault,
192: InvalidRegistrationFault, RemoteException {
193: return null;
194: }
195:
196: // PortletManagement implementation *********************************************************************************
197:
198: public PortletDescriptionResponse getPortletDescription(
199: GetPortletDescription getPortletDescription)
200: throws AccessDeniedFault, InvalidHandleFault,
201: InvalidUserCategoryFault, InconsistentParametersFault,
202: MissingParametersFault, InvalidRegistrationFault,
203: OperationFailedFault, RemoteException {
204: return getPortletManagementBehavior().getPortletDescription(
205: getPortletDescription);
206: }
207:
208: public PortletContext clonePortlet(ClonePortlet clonePortlet)
209: throws InvalidUserCategoryFault, AccessDeniedFault,
210: OperationFailedFault, InvalidHandleFault,
211: InvalidRegistrationFault, InconsistentParametersFault,
212: MissingParametersFault, RemoteException {
213: return getPortletManagementBehavior()
214: .clonePortlet(clonePortlet);
215: }
216:
217: public DestroyPortletsResponse destroyPortlets(
218: DestroyPortlets destroyPortlets)
219: throws InconsistentParametersFault, MissingParametersFault,
220: InvalidRegistrationFault, OperationFailedFault,
221: RemoteException {
222: return getPortletManagementBehavior().destroyPortlets(
223: destroyPortlets);
224: }
225:
226: public PortletContext setPortletProperties(
227: SetPortletProperties setPortletProperties)
228: throws OperationFailedFault, InvalidHandleFault,
229: MissingParametersFault, InconsistentParametersFault,
230: InvalidUserCategoryFault, AccessDeniedFault,
231: InvalidRegistrationFault, RemoteException {
232: return getPortletManagementBehavior().setPortletProperties(
233: setPortletProperties);
234: }
235:
236: public PropertyList getPortletProperties(
237: GetPortletProperties getPortletProperties)
238: throws InvalidHandleFault, MissingParametersFault,
239: InvalidRegistrationFault, AccessDeniedFault,
240: OperationFailedFault, InconsistentParametersFault,
241: InvalidUserCategoryFault, RemoteException {
242: return getPortletManagementBehavior().getPortletProperties(
243: getPortletProperties);
244: }
245:
246: public PortletPropertyDescriptionResponse getPortletPropertyDescription(
247: GetPortletPropertyDescription getPortletPropertyDescription)
248: throws MissingParametersFault, InconsistentParametersFault,
249: InvalidUserCategoryFault, InvalidRegistrationFault,
250: AccessDeniedFault, InvalidHandleFault,
251: OperationFailedFault, RemoteException {
252: return getPortletManagementBehavior()
253: .getPortletPropertyDescription(
254: getPortletPropertyDescription);
255: }
256:
257: // Producer implementation ******************************************************************************************
258:
259: public CookieProtocol getRequiresInitCookie() {
260: return requiresInitCookie;
261: }
262:
263: public void setRequiresInitCookie(CookieProtocol requiresInitCookie) {
264: this .requiresInitCookie = requiresInitCookie;
265: getServiceDescriptionBehavior().setRequiresInitCookie(
266: requiresInitCookie);
267: }
268:
269: public int getSessionExpirationTime() {
270: return sessionExpirationTime;
271: }
272:
273: public void setSessionExpirationTime(int sessionExpirationTime) {
274: this .sessionExpirationTime = sessionExpirationTime;
275: }
276:
277: public ProducerRegistrationRequirements getProducerRegistrationRequirements() {
278: throw new UnsupportedOperationException(
279: "getProducerRegistrationRequirements not implemented");
280: }
281:
282: public RegistrationManager getRegistrationManager() {
283: throw new UnsupportedOperationException(
284: "getRegistrationManager not implemented");
285: }
286:
287: public ProducerConfiguration getProducerConfiguration() {
288: throw new UnsupportedOperationException(
289: "getProducerConfiguration not implemented");
290: }
291:
292: public void setProducerConfiguration(
293: ProducerConfiguration producerConfiguration) {
294: throw new UnsupportedOperationException(
295: "setProducerConfiguration not implemented");
296: }
297: }
|