JBoss Portal SVN: r5974 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/v1/consumer and 4 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-09 23:44:22 -0500 (Tue, 09 Jan 2007)
New Revision: 5974
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- Now initializing the ProducerInfo when we start the Consumer instead of trying to protect each methods.
- Added implicit cloning support but needs testing.
- Use PortletContext where it should be used instead of generating one from portlet handle.
- Renamed refreshIfNeeded to refresh on ProducerInfo and added option to force refresh. Cleaned up code.
- Consumer will now refresh the Producer Info on InitCookieFault to account for possible changes in producer cookie policy.
- Fixed incorrect behavior of initCookie tests.
- TestWSRPProducerImpl now forces an error if initCookie is called when it shouldn't have.
- Proper re-init of producer info in tests setUp.
- Removed ServiceDescriptionUnavailbleException.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -29,6 +29,7 @@
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicPortletManagementBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicServiceDescriptionBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.WSRPConstants;
@@ -153,6 +154,7 @@
registerMarkupBehavior(new SessionMarkupBehavior());
registerMarkupBehavior(new NullMarkupBehavior());
registerMarkupBehavior(new EmptyMarkupBehavior());
+ registerMarkupBehavior(new InitCookieMarkupBehavior());
sequence = new SingleBehaviorSequence(new TestBehaviorSequence.TestBehaviorSet(new BasicServiceDescriptionBehavior()));
sequenceOrder = 0;
@@ -206,7 +208,9 @@
{
if (sequence != null)
{
- return sequence.getMarkupBehaviorFor(sequenceOrder);
+ MarkupBehavior markupBehavior = sequence.getMarkupBehaviorFor(sequenceOrder);
+ System.out.println("Using markup behavior for " + markupBehavior.getPortletHandle() + " portlet handle.");
+ return markupBehavior;
}
throw new IllegalStateException("Don't have a MarkupBehavior to return!");
}
@@ -276,6 +280,12 @@
public ReturnAny initCookie(InitCookie initCookie)
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
{
+ // should only be called if we required cookies to be initialized
+ if (requiresInitCookie == null)
+ {
+ throw new OperationFailedFault();
+ }
+
response.addCookie(new Cookie("cookieName", USER_COOKIE));
incrementBehaviorCallCount();
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -42,6 +42,7 @@
import org.jboss.portal.test.wsrp.framework.support.TestPortletInvocationContext;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
@@ -56,8 +57,7 @@
*/
public class MarkupTestCase extends V1ConsumerBaseTest
{
- public MarkupTestCase()
- throws Exception
+ public MarkupTestCase() throws Exception
{
super();
}
@@ -131,7 +131,7 @@
public void testInitCookie() throws Exception
{
// first test that we don't initialize cookies if we don't need it
- RenderInvocation render = createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
+ RenderInvocation render = createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE);
TestPortletInvocationContext invocationContext = (TestPortletInvocationContext)render.getContext();
HttpSession session = invocationContext.getClientRequest().getSession();
producer.setResponse(invocationContext.getClientResponse());
@@ -144,7 +144,7 @@
// now require cookie initialization and check that everything went well
producer.setRequiresInitCookie(CookieProtocol.perUser);
- render = createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
+ render = createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE);
invocationContext = (TestPortletInvocationContext)render.getContext();
session = invocationContext.getClientRequest().getSession();
producer.setResponse(invocationContext.getClientResponse());
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -49,9 +49,12 @@
ExtendedAssert.assertEquals(ServiceObjectFactory.SAMPLE_KEYWORD + suffix, ServiceObjectFactory.extractString(meta.getMetaValue(MetaInfo.KEYWORDS)));
}
- public void tearDown() throws Exception
+
+ public void setUp() throws Exception
{
+ super.setUp();
producer.reset();
- super.tearDown();
+ // make sure we use clean producer info for each test
+ consumer.refreshProducerInfo();
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -83,7 +83,8 @@
String suffix;
if (handle.startsWith(BasicMarkupBehavior.PORTLET_HANDLE)
|| NullMarkupBehavior.PORTLET_HANDLE.equals(handle)
- || EmptyMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ || EmptyMarkupBehavior.PORTLET_HANDLE.equals(handle)
+ || InitCookieMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
suffix = "";
}
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.wsrp.v1.consumer.behaviors;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
+import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.InvalidCookieFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class InitCookieMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "initcookiehandle";
+
+
+ public InitCookieMarkupBehavior()
+ {
+ portletHandle = PORTLET_HANDLE;
+ }
+
+ protected String getMarkupString(Mode mode, WindowState windowState, String navigationalState, GetMarkup getMarkup) throws InvalidCookieFault, OperationFailedFault
+ {
+ System.out.println("InitCookieMarkupBehavior getMarkupString call count: " + callCount);
+ String markup = "markup";
+ switch (callCount++)
+ {
+ case 0:
+ return markup;
+
+ case 1:
+ // simulate change of configuration between calls: upon receiving this, the consumer should invoke initCookie
+ throw new InvalidCookieFault();
+
+ case 2:
+ return markup;
+
+ default:
+ // shouldn't be called more than 3 times
+ throw new OperationFailedFault();
+ }
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -65,15 +65,17 @@
public void testClonePortlet() throws Exception
{
String handle = getDefaultHandle();
+ PortletContext initialContext = WSRPTypeFactory.createPortletContext(handle);
+
// first check that we get a new PortletContext
- PortletContext portletContext = clonePortlet(handle);
- ExtendedAssert.assertNotNull(portletContext);
- ExtendedAssert.assertFalse(WSRPTypeFactory.createPortletContext(handle).equals(portletContext));
+ PortletContext cloneContext = clonePortlet(handle);
+ ExtendedAssert.assertNotNull(cloneContext);
+ ExtendedAssert.assertFalse(initialContext.equals(cloneContext));
// then check that the initial state is identical
- GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, portletContext.getPortletHandle());
+ GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, cloneContext);
Property[] result = portletManagementService.getPortletProperties(getPortletProperties).getProperties();
- getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, handle);
+ getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, initialContext);
checkGetPropertiesResponse(portletManagementService.getPortletProperties(getPortletProperties), result);
// check that new clone is not listed in service description
@@ -127,7 +129,8 @@
public void testGetPortletPropertiesNoRegistration() throws Exception
{
String handle = getDefaultHandle();
- GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, handle);
+ PortletContext initialContext = WSRPTypeFactory.createPortletContext(handle);
+ GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, initialContext);
getPortletProperties.setNames(new String[]{"prefName1", "prefName2"});
PropertyList response = portletManagementService.getPortletProperties(getPortletProperties);
@@ -184,7 +187,7 @@
SetPortletProperties setPortletProperties = WSRPTypeFactory.createSetPortletProperties(portletContext, propertyList);
PortletContext response = portletManagementService.setPortletProperties(setPortletProperties);
- GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, portletContext.getPortletHandle());
+ GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(null, response);
checkGetPropertiesResponse(portletManagementService.getPortletProperties(getPortletProperties), properties);
portletContext = WSRPTypeFactory.createPortletContext(handle);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp;
import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
@@ -89,4 +90,10 @@
* @since 2.6
*/
void setProducerInfo(ProducerInfo producerInfo);
+
+ /**
+ * @throws PortletInvokerException
+ * @since 2.6
+ */
+ void refreshProducerInfo() throws PortletInvokerException;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -104,25 +104,26 @@
*/
public static GetMarkup createDefaultMarkupRequest(String handle)
{
- return createMarkupRequest(handle, createDefaultRuntimeContext(), createDefaultMarkupParams());
+ return createMarkupRequest(createPortletContext(handle), createDefaultRuntimeContext(), createDefaultMarkupParams());
}
/**
* registrationContext(RegistrationContext)?, portletContext(PortletContext), runtimeContext(RuntimeContext),
* userContext(UserContext)?, markupParams(MarkupParams)
*
- * @param handle
+ * @param portletContext
* @param runtimeContext
* @param markupParams
* @return
* @throws IllegalArgumentException if one of the required parameters is <code>null</code>
*/
- public static GetMarkup createMarkupRequest(String handle, RuntimeContext runtimeContext, MarkupParams markupParams)
+ public static GetMarkup createMarkupRequest(PortletContext portletContext, RuntimeContext runtimeContext, MarkupParams markupParams)
{
ParameterValidation.throwIllegalArgExceptionIfNull(runtimeContext, "RuntimeContext");
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNull(markupParams, "MarkupParams");
- return new GetMarkup(null, createPortletContext(handle), runtimeContext, null, markupParams);
+ return new GetMarkup(null, portletContext, runtimeContext, null, markupParams);
}
/**
@@ -134,7 +135,7 @@
*/
public static PerformBlockingInteraction createDefaultPerformBlockingInteraction(String portletHandle)
{
- return createPerformBlockingInteraction(portletHandle, createDefaultRuntimeContext(), createDefaultMarkupParams(),
+ return createPerformBlockingInteraction(createPortletContext(portletHandle), createDefaultRuntimeContext(), createDefaultMarkupParams(),
createDefaultInteractionParams());
}
@@ -142,22 +143,24 @@
* {@link org.jboss.portal.wsrp.core.RegistrationContext}?, {@link PortletContext}, {@link RuntimeContext}, {@link
* org.jboss.portal.wsrp.core.UserContext}?, {@link MarkupParams}, {@link InteractionParams}
*
- * @param portletHandle
+ * @param portletContext
* @param runtimeContext
* @param markupParams
* @param interactionParams
* @return
*/
- public static PerformBlockingInteraction createPerformBlockingInteraction(String portletHandle,
- RuntimeContext runtimeContext,
- MarkupParams markupParams,
- InteractionParams interactionParams)
+ public static PerformBlockingInteraction createPerformBlockingInteraction(
+ PortletContext portletContext, RuntimeContext runtimeContext,
+ MarkupParams markupParams,
+ InteractionParams interactionParams)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletContext.getPortletHandle(), "portlet handle", "PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNull(runtimeContext, "RuntimeContext");
ParameterValidation.throwIllegalArgExceptionIfNull(markupParams, "MarkupParams");
ParameterValidation.throwIllegalArgExceptionIfNull(interactionParams, "InteractionParams");
- return new PerformBlockingInteraction(null, createPortletContext(portletHandle), runtimeContext, null,
+ return new PerformBlockingInteraction(null, portletContext, runtimeContext, null,
markupParams, interactionParams);
}
@@ -180,13 +183,14 @@
* desiredLocales(xsd:string)*
*
* @param registrationContext
- * @param portletHandle
+ * @param portletContext
* @return
* @since 2.4.1
*/
- public static GetPortletProperties createGetPortletProperties(RegistrationContext registrationContext, String portletHandle)
+ public static GetPortletProperties createGetPortletProperties(RegistrationContext registrationContext, PortletContext portletContext)
{
- return new GetPortletProperties(registrationContext, createPortletContext(portletHandle), null, null);
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
+ return new GetPortletProperties(registrationContext, portletContext, null, null);
}
/** ====== WSRP Response objects ====== **/
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -27,6 +27,7 @@
import org.jboss.portal.portlet.Parameters;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
@@ -48,6 +49,7 @@
import org.jboss.portal.wsrp.core.UserContext;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -66,7 +68,8 @@
protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation invocation)
{
- log.debug("Consumer about to attempt rendering portlet '" + requestPrecursor.portletHandle + "'");
+ PortletContext portletContext = requestPrecursor.getPortletContext();
+ log.debug("Consumer about to attempt rendering portlet '" + portletContext.getPortletHandle() + "'");
// access mode
InstanceContext instanceContext = invocation.getInstanceContext();
@@ -110,9 +113,8 @@
// todo: need to deal with GET method in forms
// Create the blocking action request
- return WSRPTypeFactory.createPerformBlockingInteraction(
- requestPrecursor.portletHandle, requestPrecursor.runtimeContext, requestPrecursor.markupParams,
- interactionParams);
+ return WSRPTypeFactory.createPerformBlockingInteraction(portletContext, requestPrecursor.runtimeContext,
+ requestPrecursor.markupParams, interactionParams);
}
protected PortletInvocationResponse processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor) throws PortletInvokerException
@@ -156,14 +158,34 @@
result.setNavigationalState(StateString.createFrom(navigationalState));
}
- // todo: deal with new portlet handle and portlet state
+ // check if the portlet was cloned
PortletContext portletContext = updateResponse.getPortletContext();
- if (portletContext != null && !requestPrecursor.portletHandle.equals(portletContext.getPortletHandle()))
+ if (portletContext != null)
{
- throw new UnsupportedOperationException("Portlet cloning not currently supported: producer '" + consumer.getProducerId()
- + "' updated the portlet handle.");
+ PortletContext originalContext = requestPrecursor.getPortletContext();
+ InstanceContext context = invocation.getInstanceContext();
+
+ if (!originalContext.getPortletHandle().equals(portletContext.getPortletHandle()))
+ {
+ log.debug("Portlet '" + requestPrecursor.getPortletHandle() + "' was implicitely cloned. New handle is '"
+ + portletContext.getPortletHandle() + "'");
+ StateEvent event = new StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext), StateEvent.PORTLET_CLONED_EVENT);
+ context.onStateEvent(event);
+ }
+ else
+ {
+ // check if the state was modified
+ byte[] originalState = originalContext.getPortletState();
+ byte[] newState = portletContext.getPortletState();
+ if (!Arrays.equals(originalState, newState))
+ {
+ StateEvent event = new StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext), StateEvent.PORTLET_MODIFIED_EVENT);
+ context.onStateEvent(event);
+ }
+ }
}
+
return result;
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -24,7 +24,6 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.logging.Logger;
-import org.jboss.portal.portlet.InvokerUnavailableException;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
@@ -76,15 +75,7 @@
Object request = prepareRequest(requestPrecursor, invocation);
// Perform the request
- Object response;
- try
- {
- response = performRequest(request, invocation);
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new InvokerUnavailableException(e.getMessage(), e);
- }
+ Object response = performRequest(request, invocation);
if (response instanceof ErrorResponse)
{
return unwrapWSRPError((ErrorResponse)response);
@@ -93,8 +84,7 @@
return processResponse(response, invocation, requestPrecursor);
}
- protected Object performRequest(Object request, PortletInvocation invocation)
- throws ServiceDescriptionUnavailableException, PortletInvokerException
+ protected Object performRequest(Object request, PortletInvocation invocation) throws PortletInvokerException
{
int retryCount = 0;
Object response = null;
@@ -160,7 +150,7 @@
* handled
*/
private ErrorResponse dealWithError(Exception error, PortletInvocation invocation, RuntimeContext runtimeContext)
- throws ServiceDescriptionUnavailableException, PortletInvokerException
+ throws PortletInvokerException
{
log.error("The portlet threw an exception", error);
@@ -169,8 +159,10 @@
// recoverable errors
if (error instanceof InvalidCookieFault)
{
- log.debug("Re-initializing cookies after InvalidCookieFault.");
// we need to re-init the cookies
+ log.debug("Re-initializing cookies after InvalidCookieFault.");
+ // force a producer info refresh because the invalid cookie might be due to a change of cookie policy on the producer
+ consumer.refreshProducerInfo();
try
{
sessionHandler.initCookieIfNeeded(invocation);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -130,18 +130,23 @@
return requiresInitCookie;
}
-
public boolean isInitialized()
{
return isInitialized;
}
- public boolean refreshIfNeeded() throws PortletInvokerException, ServiceDescriptionUnavailableException
+ public void start() throws Exception
{
+ refresh(true);
+ endpointConfigurationInfo.getServiceFactory().start();
+ }
+
+ public boolean refresh(boolean forceRefresh) throws PortletInvokerException
+ {
ServiceDescription serviceDescription;
// might neeed a different cache value: right now, we cache the whole producer info but we might want to cache
// POPs and rest of producer info separetely...
- if (isCacheExpired() || !isInitialized())
+ if (forceRefresh || isCacheExpired() || !isInitialized())
{
log.debug("ProducerInfo refresh needed for producer '" + producerId + "'");
serviceDescription = getServiceDescription();
@@ -181,7 +186,7 @@
}
catch (Exception e)
{
- registrationInfo.resetRegistration();
+ resetRegistration(false);
throw new PortletInvokerException("Couldn't register with producer '" + producerId + "'", e);
}
@@ -321,24 +326,12 @@
public Portlet getPortlet(String portletId) throws PortletInvokerException
{
- try
- {
- if (!refreshIfNeeded())
- {
- throw new PortletInvokerException("Couldn't initialize producer '" + producerId + "'");
- }
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new PortletInvokerException("Couldn't initialize producer '" + producerId + "'", e);
- }
-
// if cache is still valid, use information from cached service description
if (useCache() && !isCacheExpired())
{
log.debug("getPortlet from cached service description");
- return (Portlet)popsMap.get(portletId);
+ return (Portlet)getPortletMap().get(portletId);
}
else // otherwise, retrieve just the information for the appropriate portlet
{
@@ -363,14 +356,13 @@
}
}
- public Map getPortletGroupMap() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ public Map getPortletGroupMap() throws PortletInvokerException
{
refreshPOPsIfNeeded();
-
return portletGroups;
}
- public Map getPortletMap() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ public Map getPortletMap() throws PortletInvokerException
{
refreshPOPsIfNeeded();
return popsMap;
@@ -383,9 +375,9 @@
return expirationCacheSeconds != null && expirationCacheSeconds.intValue() > 0;
}
- private void refreshPOPsIfNeeded() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ private void refreshPOPsIfNeeded() throws PortletInvokerException
{
- refreshIfNeeded();
+ refresh(false);
if (isCacheExpired())
{
extractOfferedPortlets(getServiceDescription());
@@ -422,7 +414,7 @@
this.expirationCacheSeconds = expirationCacheSeconds;
}
- private ServiceDescription getServiceDescription() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ private ServiceDescription getServiceDescription() throws PortletInvokerException
{
GetServiceDescription request = getServiceDescriptionRequest();
request.setRegistrationContext(getRegistrationContext());
@@ -449,7 +441,7 @@
{
log.debug("Caught Exception in getServiceDescription:\n", e);
Throwable cause = e.getCause();
- throw new ServiceDescriptionUnavailableException("Problem getting service description for producer "
+ throw new InvokerUnavailableException("Problem getting service description for producer "
+ producerId, cause == null ? e : cause);
}
}
@@ -492,4 +484,15 @@
{
return registrationInfo.getRegistrationContext();
}
+
+ public void resetRegistration() throws PortletInvokerException
+ {
+ resetRegistration(true);
+ }
+
+ private void resetRegistration(boolean refresh) throws PortletInvokerException
+ {
+ registrationInfo.resetRegistration();
+ refresh(refresh);
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -39,6 +39,7 @@
import org.jboss.portal.wsrp.core.GetMarkup;
import org.jboss.portal.wsrp.core.MarkupContext;
import org.jboss.portal.wsrp.core.MarkupResponse;
+import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.UserContext;
@@ -81,9 +82,9 @@
protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation invocation)
{
// Create the markup request
- log.debug("Consumer about to attempt rendering portlet '" + requestPrecursor.portletHandle + "'");
- return WSRPTypeFactory.createMarkupRequest(requestPrecursor.portletHandle,
- requestPrecursor.runtimeContext, requestPrecursor.markupParams);
+ PortletContext portletContext = requestPrecursor.getPortletContext();
+ log.debug("Consumer about to attempt rendering portlet '" + portletContext.getPortletHandle() + "'");
+ return WSRPTypeFactory.createMarkupRequest(portletContext, requestPrecursor.runtimeContext, requestPrecursor.markupParams);
}
protected PortletInvocationResponse processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RequestPrecursor.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -37,6 +37,7 @@
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.MarkupParams;
+import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.RuntimeContext;
/**
@@ -49,7 +50,7 @@
class RequestPrecursor
{
Logger log = Logger.getLogger(getClass());
- String portletHandle;
+ private PortletContext portletContext;
RuntimeContext runtimeContext;
MarkupParams markupParams;
private static final String PORTLET_HANDLE = "portlet handle";
@@ -62,9 +63,9 @@
public RequestPrecursor(WSRPConsumerImpl wsrpConsumer, PortletInvocation invocation) throws PortletInvokerException
{
// retrieve handle
- portletHandle = WSRPConsumerImpl.getPortletHandle(invocation);
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle, PORTLET_HANDLE, null);
- log.debug("About to invoke on portlet: " + portletHandle);
+ portletContext = WSRPUtils.convertToWSRPPortletContext(WSRPConsumerImpl.getPortletContext(invocation));
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(getPortletHandle(), PORTLET_HANDLE, null);
+ log.debug("About to invoke on portlet: " + getPortletHandle());
// create runtime context
SecurityContext securityContext = invocation.getSecurityContext();
@@ -122,4 +123,15 @@
}
}
}
+
+ public String getPortletHandle()
+ {
+ return portletContext.getPortletHandle();
+ }
+
+
+ public PortletContext getPortletContext()
+ {
+ return portletContext;
+ }
}
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ServiceDescriptionUnavailableException.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -1,37 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.wsrp.consumer;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.4 (May 12, 2006)
- */
-public class ServiceDescriptionUnavailableException extends Exception
-{
- public ServiceDescriptionUnavailableException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -112,20 +112,12 @@
RequestHeaderClientHandler.resetCurrentInfo();
}
- public void initCookieIfNeeded(PortletInvocation invocation) throws Exception
+ public void initCookieIfNeeded(PortletInvocation invocation) throws PortletInvokerException
{
- try
- {
- initCookieIfNeeded(invocation, true);
- }
- catch (InvokerUnavailableException e)
- {
- throw new ServiceDescriptionUnavailableException(e.getLocalizedMessage(), e);
- }
+ initCookieIfNeeded(invocation, true);
}
- private void initCookieIfNeeded(PortletInvocation invocation, boolean retryIfFails)
- throws Exception, InvokerUnavailableException
+ private void initCookieIfNeeded(PortletInvocation invocation, boolean retryIfFails) throws PortletInvokerException
{
// check if the cookie protocol requires cookie initialization
if (!requiresInitCookie())
@@ -175,8 +167,7 @@
sessionInformation.setInitCookieDone(true);
}
- private void initCookie(InitCookie initCookie, PortletInvocation invocation, boolean retryIfFails)
- throws Exception, InvokerUnavailableException
+ private void initCookie(InitCookie initCookie, PortletInvocation invocation, boolean retryIfFails) throws PortletInvokerException
{
try
{
@@ -192,8 +183,7 @@
}
catch (Exception e)
{
- log.fatal("initCookie failed!", e);
- throw e;
+ throw new InvokerUnavailableException("Couldn't init cookies!", e);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-01-10 02:28:08 UTC (rev 5973)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-01-10 04:44:22 UTC (rev 5974)
@@ -167,7 +167,6 @@
// the portlet is not cloned, so try POP ones...
if (portlet == null)
{
- refreshProducerInfo();
portlet = producerInfo.getPortlet(portletId);
}
@@ -184,7 +183,6 @@
public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
{
InvocationHandler handler;
- refreshProducerInfo();
if (invocation instanceof RenderInvocation)
{
@@ -212,8 +210,6 @@
throw new PortletInvokerException("No portlet '" + portletContext.getId() + "' to clone!");
}
- refreshProducerInfo();
-
// todo: deal with user context
ClonePortlet clonePortlet = WSRPTypeFactory.createClonePortlet(getRegistrationContext(),
WSRPUtils.convertToWSRPPortletContext(portletContext), null);
@@ -256,8 +252,6 @@
handles.add(id);
}
- refreshProducerInfo();
-
DestroyPortlets destroyPortlets = WSRPTypeFactory.createDestroyPortlets(getRegistrationContext(),
(String[])handles.toArray(new String[0]));
@@ -307,10 +301,8 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
- refreshProducerInfo();
-
GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(getRegistrationContext(),
- portletContext.getId());
+ WSRPUtils.convertToWSRPPortletContext(portletContext));
getPortletProperties.setNames(keys);
try
@@ -362,8 +354,6 @@
+ "' because there is no such portlet.");
}
- refreshProducerInfo();
-
PropertyList propertyList = WSRPTypeFactory.createPropertyList();
int changesNumber = changes.length;
List updates = new ArrayList(changesNumber);
@@ -424,16 +414,26 @@
// Portlet-related methods ******************************************************************************************
- public Map getPortletGroupMap() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ public Map getPortletGroupMap() throws PortletInvokerException
{
return producerInfo.getPortletGroupMap();
}
static String getPortletHandle(PortletInvocation invocation)
{
- return ((PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE)).getId();
+ return getPortletContext(invocation).getId();
}
+ /**
+ * @param invocation
+ * @return
+ * @since 2.6
+ */
+ static PortletContext getPortletContext(PortletInvocation invocation)
+ {
+ return (PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ }
+
WSRPPortletInfo getPortletInfo(PortletInvocation invocation) throws PortletInvokerException
{
return (WSRPPortletInfo)getWSRPPortlet(getPortletHandle(invocation)).getInfo();
@@ -444,16 +444,16 @@
return (WSRPPortlet)getPortlet(portletId);
}
- private Map getPortletMap() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ private Map getPortletMap() throws PortletInvokerException
{
- refreshProducerInfo();
+ Map portletMap = producerInfo.getPortletMap();
if (ccpsMap.isEmpty())
{
- return producerInfo.getPortletMap();
+ return portletMap;
}
else
{
- Map all = new HashMap(producerInfo.getPortletMap());
+ Map all = new HashMap(portletMap);
all.putAll(ccpsMap);
return all;
}
@@ -477,11 +477,10 @@
// Registration *****************************************************************************************************
- void handleInvalidRegistrationFault() throws ServiceDescriptionUnavailableException, PortletInvokerException
+ void handleInvalidRegistrationFault() throws PortletInvokerException
{
// reset registration data and try again
- producerInfo.getRegistrationInfo().resetRegistration();
- refreshProducerInfo();
+ producerInfo.resetRegistration();
}
RegistrationContext getRegistrationContext()
@@ -505,7 +504,7 @@
protected void startService() throws Exception
{
- getServiceFactory().start();
+ producerInfo.start();
}
// Web services access **********************************************************************************************
@@ -540,23 +539,9 @@
return producerInfo.getEndpointConfigurationInfo().getRegistrationService();
}
- /**
- * Refreshes the producer information if needed
- *
- * @throws org.jboss.portal.portlet.PortletInvokerException
- *
- * @since 2.6
- */
- private void refreshProducerInfo() throws PortletInvokerException
+ public void refreshProducerInfo() throws PortletInvokerException
{
- try
- {
- producerInfo.refreshIfNeeded();
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new PortletInvokerException("Unable to initialize producer '" + producerInfo.getId() + "'", e);
- }
+ producerInfo.refresh(true);
sessionHandler.setRequiresInitCookie(producerInfo.getRequiresInitCookie());
}
17 years, 5 months
JBoss Portal SVN: r5973 - trunk/core/src/resources/portal-core-sar/conf/bundles.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-09 21:28:08 -0500 (Tue, 09 Jan 2007)
New Revision: 5973
Modified:
trunk/core/src/resources/portal-core-sar/conf/bundles/Resource_fr.properties
Log:
- native2ascii on french accent of the "News" i18n value
Modified: trunk/core/src/resources/portal-core-sar/conf/bundles/Resource_fr.properties
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/bundles/Resource_fr.properties 2007-01-10 02:17:27 UTC (rev 5972)
+++ trunk/core/src/resources/portal-core-sar/conf/bundles/Resource_fr.properties 2007-01-10 02:28:08 UTC (rev 5973)
@@ -25,4 +25,4 @@
PAGENAME_default=Accueil
PAGENAME_Admin=Admin
PAGENAME_Test=Test
-PAGENAME_News=Actualit�s
\ No newline at end of file
+PAGENAME_News=Actualit\u00E9s
\ No newline at end of file
17 years, 5 months
JBoss Portal SVN: r5972 - in trunk: core/src/main/org/jboss/portal/core/aspects/controller and 15 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-09 21:17:27 -0500 (Tue, 09 Jan 2007)
New Revision: 5972
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java
Modified:
trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java
trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
- JBPORTAL-1181 : bug fix in send redirect with non idempotent commands
- JBPORTAL-1182 : Add "Add to dashboard" command displayed on shared pages
Modified: trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -96,4 +96,58 @@
String[] valuesR = (String[])right;
return Arrays.equals(valuesL, valuesR);
}
+
+ /**
+ * Return the parameter value or null if it does not exist.
+ *
+ * @param name the parameter name
+ * @return the parameter value or null if it does not exist
+ * @throws NullPointerException if the name is null
+ */
+ public String getValue(String name) throws IllegalArgumentException
+ {
+ String[] value = (String[])get(name);
+ return value == null ? null : value[0];
+ }
+
+ /**
+ * Return the parameter values or null if it does not exist.
+ *
+ * @param name the value to get
+ * @return the parameter values
+ * @throws NullPointerException if the name is null
+ */
+ public String[] getValues(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name");
+ }
+ return (String[])get(name);
+ }
+
+ /**
+ * Set the a parameter value.
+ *
+ * @param name the parameter name
+ * @param value the parameter value
+ * @throws NullPointerException if the name or the value is null
+ */
+ public void setValue(String name, String value)
+ {
+ put(name, new String[]{value});
+ }
+
+ /**
+ * Set the parameter values. This method does not make a defensive copy of the values.
+ *
+ * @param name the parameter name
+ * @param values the parameter values
+ * @throws NullPointerException if the name or the value is null
+ * @throws IllegalArgumentException if the values length is zero or contains a null element
+ */
+ public void setValues(String name, String[] values) throws NullPointerException, IllegalArgumentException
+ {
+ put(name, values);
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -27,6 +27,8 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.command.SignOutCommand;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.core.model.instance.command.InvokePortletInstanceRenderCommand;
@@ -39,6 +41,8 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
+import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
+import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.portlet.ParametersStateString;
@@ -146,49 +150,72 @@
public StringBuffer injectDashboardNav(ControllerCommand cc)
{
StringBuffer sb = new StringBuffer();
- if (cc.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser() == null)
+ ControllerContext controllerCtx = cc.getControllerContext();
+ Controller controller = controllerCtx.getController();
+ User user = controllerCtx.getUser();
+
+ //
+ if (controllerCtx.getServerInvocation().getServerContext().getClientRequest().getRemoteUser() == null)
{
- URLContext ctx = cc.getControllerContext().getServerInvocation().getServerContext().getURLContext();
+ URLContext ctx = controllerCtx.getServerInvocation().getServerContext().getURLContext();
ctx = URLContext.newInstance(ctx.getSecure(), true);
- String loginURL = cc.getControllerContext().renderURL(cc, ctx, null);
+ String loginURL = controllerCtx.renderURL(cc, ctx, null);
sb.append("<a href=\"").append(loginURL).append("\">Login</a>");
}
else
{
- String configureURL = null;
+ String dashboardActionURL = null;
+ String dashboardActionLabel = null;
- boolean dashboard = false;
+ boolean isDashboard = false;
if (cc instanceof RenderPageCommand)
{
RenderPageCommand rpc = (RenderPageCommand)cc;
- dashboard = rpc.isDashboard();
+ Page page = rpc.getPage();
+ String pageName = page.getName();
+ isDashboard = rpc.isDashboard();
//
- if (dashboard)
+ if (isDashboard)
{
// Edit page
ParametersStateString navState = new ParametersStateString();
- navState.setValue("editPageSelect", rpc.getPage().getName());
+ navState.setValue("editPageSelect", pageName);
InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("ConfiguratorPortletInstance", navState);
- configureURL = cc.getControllerContext().renderURL(command, null, null);
+ dashboardActionURL = controllerCtx.renderURL(command, null, null);
+ dashboardActionLabel = "Edit Content";
}
+ else
+ {
+ //
+ CustomizationManager cm = controller.getCustomizationManager();
+ Portal dashboard = cm.getDashboard(user);
+ if (dashboard.getChild(pageName) == null)
+ {
+ ImportPageToDashboardCommand iptdc = new ImportPageToDashboardCommand(page.getId());
+ dashboardActionURL = controllerCtx.renderURL(iptdc, null, null);
+ dashboardActionLabel = "Add to dashboard";
+ }
+ }
}
+
+ // Compute label
String pageURL;
String label;
- if (dashboard)
+ if (isDashboard)
{
RenderPageCommand _rpc = new RenderPageCommand(new PortalObjectId(new String[]{"default", "default"}));
- pageURL = cc.getControllerContext().renderURL(_rpc, null, null);
+ pageURL = controllerCtx.renderURL(_rpc, null, null);
label = "Portal";
}
else
{
- ViewDashboardCommand vdc = new ViewDashboardCommand(new PortalObjectId(new String[]{"dashboard"}));
- pageURL = cc.getControllerContext().renderURL(vdc, null, null);
+ //
+ ViewDashboardCommand vdc = new ViewDashboardCommand();
+ pageURL = controllerCtx.renderURL(vdc, null, null);
label = "My Dashboard";
+
}
-
- //
// Link to admin/default portal
@@ -207,17 +234,17 @@
if (admin)
{
RenderPageCommand showDefault = new RenderPageCommand(new PortalObjectId(new String[]{"default"}));
- showDefaultURL = cc.getControllerContext().renderURL(showDefault, null, null);
+ showDefaultURL = controllerCtx.renderURL(showDefault, null, null);
}
else
{
PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
try
{
- if (cc.getControllerContext().getController().getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
+ if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
{
RenderPageCommand showadmin = new RenderPageCommand(new PortalObjectId(new String[]{"admin"}));
- showadminURL = cc.getControllerContext().renderURL(showadmin, null, null);
+ showadminURL = controllerCtx.renderURL(showadmin, null, null);
}
}
catch (PortalSecurityException e)
@@ -227,9 +254,9 @@
}
SignOutCommand cmd = new SignOutCommand();
- String logoutURL = cc.getControllerContext().renderURL(cmd, null, null);
+ String logoutURL = controllerCtx.renderURL(cmd, null, null);
- User user = (User)cc.getControllerContext().getServerInvocation().getRequest().getUser();
+ //
if (user != null)
{
sb.append("Logged in as: ").append(user.getUserName());
@@ -249,26 +276,25 @@
sb.append(" | ");
sb.append("<a href=\"").append(showadminURL).append("\">Admin</a>");
}
- else
+ else if (!isDashboard)
{
- if (!dashboard)
- {
- sb.append(" | ");
- sb.append("<a href=\"").append(showDefaultURL).append("\">Main</a>");
- }
+ sb.append(" | ");
+ sb.append("<a href=\"").append(showDefaultURL).append("\">Main</a>");
}
- //
- if (configureURL != null)
+ // Dashboard action
+ if (dashboardActionURL != null)
{
sb.append(" | ");
- sb.append("<a href=\"").append(configureURL).append("\">Edit Content</a>");
+ sb.append("<a href=\"").append(dashboardActionURL).append("\">").append(dashboardActionLabel).append("</a>");
}
//
sb.append(" | ");
sb.append("<a href=\"").append(logoutURL).append("\">Logout</a>");
}
+
+ //
return sb;
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -29,6 +29,7 @@
import org.jboss.portal.server.ServerURL;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.identity.User;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -111,4 +112,9 @@
{
return controller;
}
+
+ public User getUser()
+ {
+ return (User)serverInvocation.getRequest().getUser();
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -103,7 +103,7 @@
}
// Find out if we can execute in the same server invocation
- if (requiresRedirect(urlContext, forward))
+ if (requiresRedirect(cmd, urlContext, forward))
{
String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(), null);
if (url == null)
@@ -172,16 +172,27 @@
return null;
}
- public boolean requiresRedirect(URLContext currentURLCtx, CommandForward forward)
+ /**
+ * Return true if the execution of the next command requires a redirect.
+ *
+ * @param currentCmd the current command which has been executed
+ * @param currentURLCtx the request URL context
+ * @param forward the forward
+ * @return
+ */
+ public boolean requiresRedirect(
+ ControllerCommand currentCmd,
+ URLContext currentURLCtx,
+ CommandForward forward)
{
- CommandInfo cmdInfo = forward.getCommand().getInfo();
- URLContext nextURLCtx = forward.getURLContext();
- if (cmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)cmdInfo).isIdempotent())
+ CommandInfo currentCmdInfo = currentCmd.getInfo();
+ if (currentCmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)currentCmdInfo).isIdempotent())
{
return true;
}
else
{
+ URLContext nextURLCtx = forward.getURLContext();
boolean currentAuthenticated = currentURLCtx.isAuthenticated();
if (nextURLCtx != null && currentAuthenticated != nextURLCtx.isAuthenticated())
{
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -25,13 +25,12 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserProfileModule;
-import org.jboss.portal.identity.UserModule;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.core.controller.ControllerContext;
import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import java.util.List;
import java.util.Locale;
@@ -49,15 +48,19 @@
/** . */
private final ServerInvocation invocation;
- public ControllerUserContext(ServerInvocation invocation)
+ /** . */
+ private final User user;
+
+ public ControllerUserContext(ControllerContext controllerContext)
{
- this.invocation = invocation;
+ this.invocation = controllerContext.getServerInvocation();
+ this.user = controllerContext.getUser();
}
/** This implementation returns the remote user value from the underlying http request. */
public String getId()
{
- return invocation.getServerContext().getClientRequest().getRemoteUser();
+ return user != null ? user.getUserName() : null;
}
public Map getInformations()
@@ -78,7 +81,6 @@
if (user != null && userProfileModule != null)
{
- //return user.getProfile();
try
{
return userProfileModule.getProperties(user);
@@ -97,7 +99,7 @@
public User getUser()
{
- return (User)invocation.getRequest().getUser();
+ return user;
}
public Locale getLocale()
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -66,7 +66,7 @@
{
this.requestContext = new AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(), controllerContext.getServerInvocation().getServerContext().getClientResponse());
this.securityContext = new AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
- this.userContext = new ControllerUserContext(controllerContext.getServerInvocation());
+ this.userContext = new ControllerUserContext(controllerContext);
this.portalContext = new org.jboss.portal.core.model.portal.portlet.PortalContextImpl(portal);
this.windowContext = new org.jboss.portal.core.model.portal.portlet.WindowContextImpl(window);
}
@@ -75,7 +75,7 @@
{
this.requestContext = new AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(), controllerContext.getServerInvocation().getServerContext().getClientResponse());
this.securityContext = new AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
- this.userContext = new ControllerUserContext(controllerContext.getServerInvocation());
+ this.userContext = new ControllerUserContext(controllerContext);
this.portalContext = portalContextImpl;
this.windowContext = new WindowContextImpl("abc"); // Well ????
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -29,6 +29,11 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.identity.UserModule;
@@ -47,6 +52,12 @@
private static final Logger log = Logger.getLogger(CustomizationManager.class);
/** . */
+ private String dashboardContextId;
+
+ /** . */
+ private PortalObjectId dashboardContextObjectId;
+
+ /** . */
private InstanceContainer instanceContainer;
/** . */
@@ -58,6 +69,29 @@
/** . */
private RoleModule roleModule;
+ /** . */
+ private PortalObjectContainer portalObjectContainer;
+
+ public PortalObjectContainer getPortalObjectContainer()
+ {
+ return portalObjectContainer;
+ }
+
+ public void setPortalObjectContainer(PortalObjectContainer portalObjectContainer)
+ {
+ this.portalObjectContainer = portalObjectContainer;
+ }
+
+ public String getDashboardContextId()
+ {
+ return dashboardContextId;
+ }
+
+ public void setDashboardContextId(String dashboardContextId)
+ {
+ this.dashboardContextId = dashboardContextId;
+ }
+
public InstanceContainer getInstanceContainer()
{
return instanceContainer;
@@ -98,6 +132,23 @@
this.roleModule = roleModule;
}
+ protected void createService() throws Exception
+ {
+ super.createService();
+
+ //
+ dashboardContextObjectId = PortalObjectId.parse(dashboardContextId, PortalObjectId.LEGACY_FORMAT);
+ }
+
+
+ protected void destroyService() throws Exception
+ {
+ dashboardContextObjectId = null;
+
+ //
+ super.destroyService();
+ }
+
public Instance getInstance(Window window) throws IllegalArgumentException
{
return getInstance(window, null);
@@ -124,7 +175,7 @@
// If we are in the context of an existing user we get a customization for that user
if (user != null)
{
- String userId = user.getId().toString();
+ String userId = getUserId(user);
// And if it is in a dashboard context we get the per window customization
if (isDashboard(window, user))
@@ -183,4 +234,45 @@
return false;
}
}
+
+ public Portal getDashboard(User user) throws IllegalArgumentException
+ {
+ //
+ Portal dashboardPortal = null;
+
+ if (user != null)
+ {
+ String userId = getUserId(user);
+
+ //
+ try
+ {
+ PortalContainer dashboardContext = (PortalContainer)portalObjectContainer.getObject(dashboardContextObjectId);
+
+ //
+ dashboardPortal = dashboardContext.getPortal(userId);
+
+ // Create if not exist
+ if (dashboardPortal == null)
+ {
+ Portal templatePortal = (Portal)portalObjectContainer.getObject(new PortalObjectId("/template", PortalObjectId.CANONICAL_FORMAT));
+
+ // Copy the template portal
+ dashboardPortal = (Portal)templatePortal.copy(dashboardContext, userId, true);
+ }
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ log.error("", e);
+ }
+ }
+
+ //
+ return dashboardPortal;
+ }
+
+ private String getUserId(User user)
+ {
+ return user.getUserName();
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -38,8 +38,6 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-import java.util.List;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -256,7 +254,7 @@
private ObjectNode getObjectNodeNoCache(Session session, String path)
{
- List results;
+ Object result;
if (path.length() == 0)
{
// For oracle where an empty path is treated as null so we need to add that here
@@ -264,20 +262,16 @@
Query query = session.createQuery(LOOKUP_QUERY_FOR_NULL_PATH);
query.setParameter("path", path);
query.setCacheable(true);
- results = query.list();
+ result = query.uniqueResult();
}
else
{
Criteria criteria = session.createCriteria(ObjectNode.class);
criteria.add(Restrictions.naturalId().set("path", path));
criteria.setCacheable(true);
- results = criteria.list();
+ result = criteria.uniqueResult();
}
- if (results.isEmpty())
- {
- return null;
- }
- return (ObjectNode)results.get(0);
+ return (ObjectNode)result;
}
private ObjectNode getObjectNode(Session session, String path)
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -124,7 +124,7 @@
}
- public PortalObject copy(PortalObject parent, String name) throws DuplicatePortalObjectException, IllegalArgumentException
+ public PortalObject copy(PortalObject parent, String name, boolean deep) throws DuplicatePortalObjectException, IllegalArgumentException
{
if (parent == null)
{
@@ -134,10 +134,10 @@
{
throw new IllegalArgumentException("No null name accepted");
}
- return copy((PortalObjectImpl)parent, name);
+ return copy((PortalObjectImpl)parent, name, deep);
}
- private PortalObjectImpl copy(PortalObjectImpl parent, String name) throws DuplicatePortalObjectException
+ private PortalObjectImpl copy(PortalObjectImpl parent, String name, boolean deep) throws DuplicatePortalObjectException
{
// Clone this node
PortalObjectImpl clone = cloneObject();
@@ -145,13 +145,16 @@
// Add the clone to the specified parent
parent.addChild(name, clone);
- // Clone children reccursively
- for (Iterator i = getChildren().iterator();i.hasNext();)
+ // Clone children recursively
+ if (deep)
{
- PortalObjectImpl child = (PortalObjectImpl)i.next();
+ for (Iterator i = getChildren().iterator();i.hasNext();)
+ {
+ PortalObjectImpl child = (PortalObjectImpl)i.next();
- //
- child.copy(clone, child.getName());
+ //
+ child.copy(clone, child.getName(), true);
+ }
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -25,10 +25,11 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.identity.User;
/**
- * Encapsulate portlet customization semantics.
+ * Integration logic between portal objects, instances and users.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -56,6 +57,15 @@
Instance getInstance(Window window, User user) throws IllegalArgumentException;
/**
+ * Returns the dashboard of a specific user.
+ *
+ * @param user
+ * @return
+ * @throws IllegalArgumentException
+ */
+ Portal getDashboard(User user) throws IllegalArgumentException;
+
+ /**
* Return true if the portal object is in a dashboard context for the specified user.
*
* @param object
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -33,43 +33,8 @@
*/
public class DashboardCommandFactory extends AbstractCommandFactory
{
-
- /** . */
- private String dashboardId;
-
- /** . */
- private PortalObjectId objectId;
-
- public String getDashboardId()
- {
- return dashboardId;
- }
-
- public void setDashboardId(String dashboardId)
- {
- this.dashboardId = dashboardId;
- }
-
-
- protected void createService() throws Exception
- {
- super.createService();
-
- //
- objectId = PortalObjectId.parse(dashboardId, PortalObjectId.LEGACY_FORMAT);
- }
-
-
- protected void destroyService() throws Exception
- {
- objectId = null;
-
- //
- super.destroyService();
- }
-
public ControllerCommand doMapping(ServerInvocation invocation, String portalContextPath, String portalRequestPath)
{
- return new ViewDashboardCommand(objectId);
+ return new ViewDashboardCommand();
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -122,11 +122,12 @@
*
* @param parent the parent of the copy
* @param name the name of the child
+ * @param deep true copies recursively children
* @return the newly created node child of the specified parent
* @throws DuplicatePortalObjectException if the specified parent has already a node with such a name
* @throws IllegalArgumentException if the specified parent is null
*/
- PortalObject copy(PortalObject parent, String name) throws DuplicatePortalObjectException, IllegalArgumentException;
+ PortalObject copy(PortalObject parent, String name, boolean deep) throws DuplicatePortalObjectException, IllegalArgumentException;
/**
* Return a property of that object.
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -24,10 +24,12 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.server.ServerInvocation;
@@ -36,6 +38,8 @@
import org.jboss.portal.server.servlet.PathParser;
import org.jboss.portal.theme.navigation.WindowNavigationalState;
+import java.util.Map;
+
/**
* This command mapper is used to map portal objects living in a container to <code>org.jboss.portal.core.command.RenderPageCommand</code>
*
@@ -104,13 +108,16 @@
ControllerCommand cmd = null;
//
+ ParameterMap queryParams = invocation.getServerContext().getQueryParameterMap();
+
+ //
if (target instanceof Window)
{
Window window = (Window)target;
//
PortletRequestDecoder decoder = new PortletRequestDecoder();
- decoder.decode(invocation.getServerContext().getQueryParameterMap(), invocation.getServerContext().getBodyParameterMap());
+ decoder.decode(queryParams, invocation.getServerContext().getBodyParameterMap());
// Get the window navigational state
WindowNavigationalState windowNavState = (WindowNavigationalState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window");
@@ -164,7 +171,19 @@
{
Page page = (Page)target;
PortalObjectId id = page.getId();
- cmd = new RenderPageCommand(id);
+
+ //
+ String action = queryParams.getValue("action");
+
+ //
+ if ("import".equals(action))
+ {
+ cmd = new ImportPageToDashboardCommand(id);
+ }
+ else
+ {
+ cmd = new RenderPageCommand(id);
+ }
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
+import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
import org.jboss.portal.core.controller.command.mapper.URLFactoryDelegate;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.impl.PortletRequestEncoder;
@@ -73,19 +74,20 @@
//
if (cmd instanceof PortalObjectCommand)
{
+ PortalObjectCommand poc = (PortalObjectCommand)cmd;
+
+ // Get base URL
+ ServerURL url = getBaseURL(poc.getTargetId());
+
+ // Customize further more
if (cmd instanceof RenderPageCommand)
{
- RenderPageCommand rpCmd = (RenderPageCommand)cmd;
- PortalObjectId pageId = rpCmd.getTargetId();
- return getBaseURL(pageId);
+ // Nothing for now, we let the statement just to show that it handles page rendering commands
}
else if (cmd instanceof InvokeWindowCommand)
{
InvokeWindowCommand iwaCmd = (InvokeWindowCommand)cmd;
- // The base URL
- AbstractServerURL serverURL = getBaseURL(iwaCmd.getTargetId());
-
Mode mode = iwaCmd.getMode();
WindowState windowState = iwaCmd.getWindowState();
@@ -94,17 +96,21 @@
{
StateString interactionState = ((InvokePortletWindowActionCommand)iwaCmd).getInteractionState();
StateString navigationalState = ((InvokePortletWindowActionCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder.encodeAction(serverURL, navigationalState, interactionState, mode, windowState);
+ PortletRequestEncoder.encodeAction(url, navigationalState, interactionState, mode, windowState);
}
else
{
StateString navigationalState = ((InvokePortletWindowRenderCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder.encodeRender(serverURL, navigationalState, mode, windowState);
+ PortletRequestEncoder.encodeRender(url, navigationalState, mode, windowState);
}
+ }
+ else if (cmd instanceof ImportPageToDashboardCommand)
+ {
+ url.setParameterValue("action", "import");
+ }
- //
- return serverURL;
- }
+ //
+ return url;
}
//
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DashboardCommand extends ControllerCommand
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.portal.command;
+
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.command.response.UpdateViewResponse;
+import org.jboss.portal.core.model.CustomizationManager;
+import org.jboss.portal.identity.User;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ImportPageToDashboardCommand extends PageCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ActionCommandInfo(true, "view", false);
+
+ /** . */
+ private Portal dashboardPortal;
+
+ public ImportPageToDashboardCommand(PortalObjectId pageId)
+ {
+ super(pageId);
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ //
+ CustomizationManager manager = getControllerContext().getController().getCustomizationManager();
+
+ //
+ User user = getControllerContext().getUser();
+
+ //
+ dashboardPortal = manager.getDashboard(user);
+ }
+
+ public Object execute() throws ControllerException
+ {
+ String name = target.getName();
+
+ //
+ PortalObject dashboardPage = dashboardPortal.getChild(name);
+
+ //
+ if (dashboardPage == null)
+ {
+ try
+ {
+ // Copy page
+ dashboardPage = target.copy(dashboardPortal, name, false);
+
+ // Copy children windows only
+ for (Iterator i = target.getChildren().iterator();i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ if (child.getType() == PortalObject.TYPE_WINDOW)
+ {
+ child.copy(dashboardPage, child.getName(), false);
+ }
+ }
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ log.error("Unexpected exception during the copy of a page to a dashboard page", e);
+
+ //
+ throw new ControllerException(e);
+ }
+ }
+
+ return new UpdateViewResponse(dashboardPage.getId());
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -110,7 +110,7 @@
{
if (dashboard == null)
{
- User user = (User)getControllerContext().getServerInvocation().getRequest().getUser();
+ User user = getControllerContext().getUser();
boolean tmp = context.getController().getCustomizationManager().isDashboard(target, user);
dashboard = Boolean.valueOf(tmp);
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -228,7 +228,7 @@
if (personalizable)
{
ControllerContext controllerCtx = (ControllerContext)getContext();
- User user = (User)controllerCtx.getServerInvocation().getRequest().getUser();
+ User user = controllerCtx.getUser();
if (user != null)
{
UserProfileModule userProfileModule = null;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -27,19 +27,18 @@
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.command.response.UpdateViewResponse;
-import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.identity.User;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ViewDashboardCommand extends PortalObjectCommand
+public class ViewDashboardCommand extends DashboardCommand
{
/** . */
@@ -52,14 +51,10 @@
private Page dashboardPage;
/** . */
- private PortalContainer dashboardContext;
+ private User user;
- /** . */
- private String userId;
-
- public ViewDashboardCommand(PortalObjectId portalId)
+ public ViewDashboardCommand()
{
- super(portalId);
}
public CommandInfo getInfo()
@@ -67,11 +62,6 @@
return info;
}
- public PortalContainer getDashboardContext()
- {
- return dashboardContext;
- }
-
public Portal getDashboardPortal()
{
return dashboardPortal;
@@ -93,37 +83,21 @@
super.create();
//
- dashboardContext = (PortalContainer)getTarget();
+ CustomizationManager manager = getControllerContext().getController().getCustomizationManager();
//
- userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ user = getControllerContext().getUser();
- try
- {
- //
- dashboardPortal = dashboardContext.getPortal(userId);
+ //
+ dashboardPortal = manager.getDashboard(user);
- // Create if not exist
- if (dashboardPortal == null)
- {
- Portal templatePortal = (Portal)context.getController().getPortalObjectContainer().getObject(new PortalObjectId("/template", PortalObjectId.CANONICAL_FORMAT));
-
- // Copy the template portal
- dashboardPortal = (Portal)templatePortal.copy(dashboardContext, userId);
- }
-
- //
- dashboardPage = dashboardPortal.getDefaultPage();
- }
- catch (DuplicatePortalObjectException e)
- {
- throw new ControllerException(e);
- }
+ //
+ dashboardPage = dashboardPortal.getDefaultPage();
}
public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
{
- if (userId == null)
+ if (user == null)
{
throw new ControllerSecurityException("User needs to be authenticated to view a dashboard");
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -102,7 +102,7 @@
}
// We need the user id
- User user = (User)getControllerContext().getServerInvocation().getRequest().getUser();
+ User user = getControllerContext().getUser();
// Get instance
instance = context.getController().getCustomizationManager().getInstance(window, user);
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -279,7 +279,7 @@
hibernate.openSession();
ctx = (PortalContainer)container.getRootObject();
portal = (Portal)container.getObject(defaultId);
- portal = (Portal)portal.copy(ctx, "copy");
+ portal = (Portal)portal.copy(ctx, "copy", true);
assertNotNull(portal);
assertEquals("copy", portal.getName());
assertEquals(Collections.singleton(WindowState.NORMAL), portal.getSupportedWindowStates());
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-01-10 02:17:27 UTC (rev 5972)
@@ -612,7 +612,11 @@
<depends
optional-attribute-name="InstanceContainer"
proxy-type="attribute">portal:container=Instance</depends>
+ <depends
+ optional-attribute-name="PortalObjectContainer"
+ proxy-type="attribute">portal:container=PortalObject</depends>
<depends>portal:service=Module,type=IdentityServiceController</depends>
+ <attribute name="DashboardContextId">dashboard</attribute>
</mbean>
<!-- Command factories -->
@@ -688,7 +692,6 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <attribute name="DashboardId">dashboard</attribute>
</mbean>
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -97,60 +97,6 @@
}
/**
- * Return the parameter value or null if it does not exist.
- *
- * @param name the parameter name
- * @return the parameter value or null if it does not exist
- * @throws NullPointerException if the name is null
- */
- public String getValue(String name) throws IllegalArgumentException
- {
- String[] value = (String[])get(name);
- return value == null ? null : value[0];
- }
-
- /**
- * Return the parameter values or null if it does not exist.
- *
- * @param name the value to get
- * @return the parameter values
- * @throws NullPointerException if the name is null
- */
- public String[] getValues(String name) throws IllegalArgumentException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null name");
- }
- return (String[])get(name);
- }
-
- /**
- * Set the a parameter value.
- *
- * @param name the parameter name
- * @param value the parameter value
- * @throws NullPointerException if the name or the value is null
- */
- public void setValue(String name, String value)
- {
- put(name, new String[]{value});
- }
-
- /**
- * Set the parameter values. This method does not make a defensive copy of the values.
- *
- * @param name the parameter name
- * @param values the parameter values
- * @throws NullPointerException if the name or the value is null
- * @throws IllegalArgumentException if the values length is zero or contains a null element
- */
- public void setValues(String name, String[] values) throws NullPointerException, IllegalArgumentException
- {
- put(name, values);
- }
-
- /**
* Append the content of the argument map to that map. If both maps contains an entry sharing the same key, then the
* string arrays or the two entries will be concatenated into a single array. Each entry present on the argument map
* and not in the current map will be kept as is. The argument validation is performed before the state is updated.
Modified: trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -148,6 +148,9 @@
//
Principal[] principals;
+ // Always check the unckeded permission container
+ checkRoleConfig(contextID, SecurityConstants.UNCHECKED_ROLE_NAME);
+
//
if (currentSubject != null)
{
@@ -177,8 +180,6 @@
}
else
{
- // Lazy check the unckeded permission container
- checkRoleConfig(contextID, SecurityConstants.UNCHECKED_ROLE_NAME);
principals = new Principal[0];
}
Modified: trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -83,7 +83,7 @@
else
{
// New config
- log.debug("No existing delegating policy in place, adding one configured with the PortalPermission clas");
+ log.debug("No existing delegating policy in place, adding one configured with the PortalPermission class");
DelegatingPolicy dp = DelegatingPolicy.getInstance();
dp.setExternalPermissionTypes(new Class[]{PortalPermission.class});
Policy.setPolicy(dp);
Modified: trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -23,12 +23,12 @@
package org.jboss.portal.server;
import org.jboss.portal.common.invocation.InvocationContext;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -36,26 +36,38 @@
*/
public interface ServerInvocationContext extends InvocationContext
{
- /** Return the request that made the connection to the server. */
+ /**
+ * Return the request that made the connection to the server.
+ *
+ * @return the http request.
+ */
HttpServletRequest getClientRequest();
/**
- * The original servlet response.
+ * Return the response that will be used by the server.
*
* @return the http response
*/
HttpServletResponse getClientResponse();
- /** Return the parameter map decoded form the query string. */
- Map getQueryParameterMap();
+ /**
+ * Return the parameter map decoded form the query string.
+ *
+ * @returns the query parameter map
+ */
+ ParameterMap getQueryParameterMap();
/**
* Return the parameter map for the body if the request was a POST with the content type x-www-formurlencoded
* otherwise return null.
*/
- Map getBodyParameterMap();
+ ParameterMap getBodyParameterMap();
- /** Return the normalized media type of the request or null if none has been provided by the client. */
+ /**
+ * Return the normalized media type of the request or null if none has been provided by the client.
+ *
+ * @return the media type
+ */
String getMediaType();
/**
@@ -63,13 +75,25 @@
*/
// Charset getCharset();
- /** Return the url context of this request. */
+ /**
+ * Return the url context of this request.
+ *
+ * @return the url context
+ */
URLContext getURLContext();
- /** Return the value of the portal request path for this request. */
+ /**
+ * Return the value of the portal request path for this request.
+ *
+ * @return the portal request path
+ */
String getPortalRequestPath();
- /** Return the value of the portal context path for this request. */
+ /**
+ * Return the value of the portal context path for this request.
+ *
+ * @return the portal context path
+ */
String getPortalContextPath();
/**
Modified: trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.invocation.AbstractInvocationContext;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
@@ -63,10 +64,10 @@
private String mediaType;
/** The query parameter map. */
- private Map queryParameterMap;
+ private ParameterMap queryParameterMap;
/** The body parameter map or null. */
- private Map bodyParameterMap;
+ private ParameterMap bodyParameterMap;
/** The url context. */
private URLContext urlContext;
@@ -104,8 +105,8 @@
this.resp = resp;
this.portalRequestPath = portalRequestPath;
this.portalContextPath = portalContextPath;
- this.queryParameterMap = queryParameterMap;
- this.bodyParameterMap = bodyParameterMap;
+ this.queryParameterMap = new InternalParameterMap(queryParameterMap);
+ this.bodyParameterMap = bodyParameterMap != null ? new InternalParameterMap(bodyParameterMap) : null;
this.urlContext = urlContext;
this.mediaType = mediaType;
this.buffers = new Buffer[16];
@@ -157,12 +158,12 @@
return urlContext;
}
- public Map getQueryParameterMap()
+ public ParameterMap getQueryParameterMap()
{
return queryParameterMap;
}
- public Map getBodyParameterMap()
+ public ParameterMap getBodyParameterMap()
{
return bodyParameterMap;
}
@@ -272,4 +273,21 @@
return s;
}
}
+
+ private static class InternalParameterMap extends ParameterMap
+ {
+
+ /** . */
+ private Map delegate;
+
+ public InternalParameterMap(Map delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ protected Map getDelegate()
+ {
+ return delegate;
+ }
+ }
}
Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-01-09 14:43:56 UTC (rev 5971)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-01-10 02:17:27 UTC (rev 5972)
@@ -29,6 +29,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.Exceptions;
import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.RequestControllerDispatcher;
17 years, 5 months
JBoss Portal SVN: r5971 - trunk/portlet/src/main/org/jboss/portal/portlet/impl
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-09 09:43:56 -0500 (Tue, 09 Jan 2007)
New Revision: 5971
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
Log:
minor reformat
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2007-01-09 14:34:07 UTC (rev 5970)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2007-01-09 14:43:56 UTC (rev 5971)
@@ -39,7 +39,12 @@
public class PortletRequestEncoder
{
- public static void encodeAction(ServerURL url, StateString navigationalState, StateString interactionState, Mode mode, WindowState windowState)
+ public static void encodeAction(
+ ServerURL url,
+ StateString navigationalState,
+ StateString interactionState,
+ Mode mode,
+ WindowState windowState)
{
int meta = PortletRequestDecoder.ACTION_MASK;
@@ -76,7 +81,11 @@
configure(meta, url, mode, windowState);
}
- public static void encodeRender(ServerURL url, StateString navigationalState, Mode mode, WindowState windowState)
+ public static void encodeRender(
+ ServerURL url,
+ StateString navigationalState,
+ Mode mode,
+ WindowState windowState)
{
int meta = PortletRequestDecoder.RENDER_MASK;
17 years, 5 months
JBoss Portal SVN: r5970 - trunk/core/src/main/org/jboss/portal/core/aspects/controller
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-09 09:34:07 -0500 (Tue, 09 Jan 2007)
New Revision: 5970
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
Log:
minor reformat
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-01-09 13:41:06 UTC (rev 5969)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-01-09 14:34:07 UTC (rev 5970)
@@ -166,6 +166,7 @@
//
if (dashboard)
{
+ // Edit page
ParametersStateString navState = new ParametersStateString();
navState.setValue("editPageSelect", rpc.getPage().getName());
InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("ConfiguratorPortletInstance", navState);
@@ -187,6 +188,9 @@
label = "My Dashboard";
}
+ //
+
+
// Link to admin/default portal
String showadminURL = null;
String showDefaultURL = null;
@@ -289,7 +293,6 @@
StringBuffer html = new StringBuffer();
html.append("<ul id=\"tabsHeader\">");
- List currentChildren = new ArrayList();
for (Iterator i = navElements.iterator(); i.hasNext();)
{
PortalObjectImpl navElement = (PortalObjectImpl)i.next();
17 years, 5 months
JBoss Portal SVN: r5969 - in trunk: core workflow workflow/src/main/org/jboss/portal/workflow workflow/src/main/org/jboss/portal/workflow/cms workflow/src/main/org/jboss/portal/workflow/test workflow/src/resources/portal-workflow-sar/META-INF
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-01-09 08:41:06 -0500 (Tue, 09 Jan 2007)
New Revision: 5969
Modified:
trunk/core/build.xml
trunk/workflow/build.log
trunk/workflow/build.sh
trunk/workflow/build.xml
trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java
trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml
Log:
added workflow module / make workflow reuse existing JNDI binder and common libraries / fixes deployment cache issue in core
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/core/build.xml 2007-01-09 13:41:06 UTC (rev 5969)
@@ -134,7 +134,7 @@
<path refid="jboss.portal-theme.classpath"/>
<path refid="jboss.portal-security.classpath"/>
<path refid="jboss.portal-test.classpath"/>
- <path refid="jboss.portal-workflow.classpath"/>
+ <path refid="jboss.portal-workflow.classpath"/>
</path>
<!--+=======================================+-->
Modified: trunk/workflow/build.log
===================================================================
--- trunk/workflow/build.log 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/build.log 2007-01-09 13:41:06 UTC (rev 5969)
@@ -1,72 +1,51 @@
-
-configure:
-Overriding previous definition of reference to apache.ant.classpath
-
-configure-modules:
-
-configure-defaults:
-Overriding previous definition of reference to javac.classpath
-
-configure-tools:
-
-_configure:jbossaop:task:
-
-_configure:xdoclet:task:
-
-_configure:xdoclet:ejbdoclet:
-
-_configure:xdoclet:jmxdoclet:
-
-init:
-
-tests:
- [echo]
- build.reports=C:\projects\core-portal\jboss-portal-trunk\workflow/output/reports
- test.reports=C:\projects\core-portal\jboss-portal-trunk\workflow/output/tests
- module.output=C:\projects\core-portal\jboss-portal-trunk\workflow/output
- driver.path=C:\projects\core-portal\jboss-portal-trunk/thirdparty/hsqldb/lib//hsqldb.jar
- junit.printsummary=true
- junit.batchtest.haltonerror=false
- junit.batchtest.haltonfailure=false
- junit.batchtest.fork=true
- junit.timeout=600000
- junit.jvm=java
- junit.jvm.options=-Ddummy
- junit.formatter.usefile=true
-
- [mkdir] Created dir: C:\projects\core-portal\jboss-portal-trunk\workflow\output\reports
- [mkdir] Created dir: C:\projects\core-portal\jboss-portal-trunk\workflow\output\tests
- [junit_] Running org.jboss.portal.workflow.test.HelloWorldDbTest
- [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.11 sec
- [junit_] Testsuite: org.jboss.portal.workflow.test.HelloWorldDbTest
- [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.11 sec
- [junit_] ------------- Standard Error -----------------
- [junit_] log4j:WARN No appenders could be found for logger (org.jbpm.JbpmConfiguration).
- [junit_] log4j:WARN Please initialize the log4j system properly.
- [junit_] ------------- ---------------- ---------------
- [junit_]
- [junit_] Testcase: testSimplePersistence took 6.079 sec
- [junit_] Running org.jboss.portal.workflow.test.PortalCMSPublish
- [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.828 sec
- [junit_] Testsuite: org.jboss.portal.workflow.test.PortalCMSPublish
- [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.828 sec
- [junit_] ------------- Standard Output ---------------
- [junit_] Assigning this task to the Managers
- [junit_] Assigning this task to the Managers
- [junit_] Manager=Admin(1)
- [junit_] Manager=eric.brown(a)jboss.com(1)
- [junit_] Manager=Admin(2)
- [junit_] Manager=eric.brown(a)jboss.com(2)
- [junit_] Manager=sohil.shah(a)jboss.com(1)
- [junit_] Manager=sohil.shah(a)jboss.com(2)
- [junit_] This publish request was approved...../default/index2.html
- [junit_] This publish request was approved...../default/index.html
- [junit_] ------------- ---------------- ---------------
- [junit_] ------------- Standard Error -----------------
- [junit_] log4j:WARN No appenders could be found for logger (org.jbpm.JbpmConfiguration).
- [junit_] log4j:WARN Please initialize the log4j system properly.
- [junit_] ------------- ---------------- ---------------
- [junit_]
- [junit_] Testcase: testCMSPublish took 6.812 sec
-
-BUILD SUCCESSFUL
+
+configure:
+Overriding previous definition of reference to apache.ant.classpath
+
+configure-modules:
+
+configure-defaults:
+Overriding previous definition of reference to javac.classpath
+
+configure-tools:
+
+_configure:jbossaop:task:
+
+_configure:xdoclet:task:
+
+_configure:xdoclet:ejbdoclet:
+
+_configure:xdoclet:jmxdoclet:
+
+_default:compile-classes:
+ [mkdir] Created dir: /Users/julien/java/jboss-portal-2.6/workflow/output/classes
+ [mkdir] Created dir: /Users/julien/java/jboss-portal-2.6/workflow/output/gen/classes
+ [javac] Compiling 12 source files to /Users/julien/java/jboss-portal-2.6/workflow/output/classes
+
+_default:check-exists-etc:
+
+_default:compile-etc:
+ [mkdir] Created dir: /Users/julien/java/jboss-portal-2.6/workflow/output/etc
+ [copy] Copying 1 file to /Users/julien/java/jboss-portal-2.6/workflow/output/etc
+
+_default:check-exists-resources:
+
+_default:compile-resources:
+ [mkdir] Created dir: /Users/julien/java/jboss-portal-2.6/workflow/output/resources
+ [copy] Copying 6 files to /Users/julien/java/jboss-portal-2.6/workflow/output/resources
+ [copy] Copied 10 empty directories to 1 empty directory under /Users/julien/java/jboss-portal-2.6/workflow/output/resources
+
+compile:
+
+output:
+ [mkdir] Created dir: /Users/julien/java/jboss-portal-2.6/workflow/output/lib
+ [jar] Building jar: /Users/julien/java/jboss-portal-2.6/workflow/output/lib/portal-workflow-lib.jar
+ [copy] Copying 2 files to /Users/julien/java/jboss-portal-2.6/workflow/output/lib/portal-workflow.war
+
+_default:most:
+
+most:
+
+main:
+
+BUILD SUCCESSFUL
Modified: trunk/workflow/build.sh
===================================================================
--- trunk/workflow/build.sh 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/build.sh 2007-01-09 13:41:06 UTC (rev 5969)
@@ -1,49 +1,49 @@
-#!/bin/sh
-##
-## Invokes a script of the same name in the 'tools' module.
-##
-## The 'tools' module is expected to be a peer directory of the directory
-## in which this script lives.
-##
-## @author Jason Dillon <jason(a)planet57.com>
-##
-
-# $Id: build.sh 2 2005-01-14 23:01:32Z vietj $
-
-PROGNAME=`basename $0`
-DIRNAME=`dirname $0`
-
-# Buss it yo
-main() {
- if [ "x$TOOLS_ROOT" = "x" ]; then
- TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
- fi
-
- MODULE_ROOT=`cd $DIRNAME; pwd`
- export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
-
- # Where is the target script?
- target="$TOOLS_ROOT/bin/$PROGNAME"
- if [ ! -f "$target" ]; then
- echo "${PROGNAME}: *ERROR* The target executable does not exist:"
- echo "${PROGNAME}:"
- echo "${PROGNAME}: $target"
- echo "${PROGNAME}:"
- echo "${PROGNAME}: Please make sure you have checked out the 'tools' module"
- echo "${PROGNAME}: and make sure it is up to date."
- exit 2
- fi
-
- # Get busy yo!
- if [ "x$DEBUG" != "x" ]; then
- echo "${PROGNAME}: Executing: /bin/sh $target $@"
- fi
- if [ "x$TRACE" = "x" ]; then
- exec /bin/sh $target "$@"
- else
- exec /bin/sh -x $target "$@"
- fi
-}
-
-# Lets get ready to rumble!
-main "$@"
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason(a)planet57.com>
+##
+
+# $Id: build.sh 1015 2005-11-04 20:15:13Z mholzner $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools' module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Modified: trunk/workflow/build.xml
===================================================================
--- trunk/workflow/build.xml 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/build.xml 2007-01-09 13:41:06 UTC (rev 5969)
@@ -116,6 +116,7 @@
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
+ <path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
</path>
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -24,35 +24,32 @@
/**
* Created on : Dec 21, 2006
- * @author Sohil Shah - sohil.shah(a)jboss.com
*
+ * @author Sohil Shah - sohil.shah(a)jboss.com
*/
public class WorkflowException extends Exception
{
- /**
- *
- *
- */
- public WorkflowException()
- {
- this("");
+ /**
+ *
+ */
+ public WorkflowException()
+ {
+ this("");
+ }
+
+ /**
+ * @param e
+ */
+ public WorkflowException(Exception e)
+ {
+ super(e);
+ }
+
+ /**
+ * @param e
+ */
+ public WorkflowException(String e)
+ {
+ super(e);
}
-
- /**
- *
- * @param e
- */
- public WorkflowException(Exception e)
- {
- super(e);
- }
-
- /**
- *
- * @param e
- */
- public WorkflowException(String e)
- {
- super(e);
- }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -23,40 +23,41 @@
package org.jboss.portal.workflow.cms;
import java.util.Collection;
+
import org.jboss.portal.workflow.WorkflowException;
/**
* Created on : Dec 19, 2006
+ *
* @author Sohil Shah - sohil.shah(a)jboss.com
- *
*/
public interface ApprovePublish
{
- /**
- * Called when content is added to the CMS, and needs to be approved by the managers
- * before it can be published to go live
- *
- * @param content
- * @return returns the process id of the workflow process set in motion
- */
- public long requestApproval(Content content) throws WorkflowException;
-
- /**
- * Called when a manager either approves or rejects the publishing of a specific content to
- * go live
- *
- * @param processId
- * @param manager userId of the manager
- * @param approved true if approved, false if rejected
- */
- public void processManagerResponse(long processId,String manager,boolean approved) throws WorkflowException;
-
- /**
- * Retrieves a queue of unapproved content associated with the specified file in the CMS
- *
- * @param filePath
- * @return
- * @throws WorkflowException
- */
- public Collection getPendingQueue(String filePath) throws WorkflowException;
+ /**
+ * Called when content is added to the CMS, and needs to be approved by the managers
+ * before it can be published to go live
+ *
+ * @param content
+ * @return returns the process id of the workflow process set in motion
+ */
+ public long requestApproval(Content content) throws WorkflowException;
+
+ /**
+ * Called when a manager either approves or rejects the publishing of a specific content to
+ * go live
+ *
+ * @param processId
+ * @param manager userId of the manager
+ * @param approved true if approved, false if rejected
+ */
+ public void processManagerResponse(long processId, String manager, boolean approved) throws WorkflowException;
+
+ /**
+ * Retrieves a queue of unapproved content associated with the specified file in the CMS
+ *
+ * @param filePath
+ * @return
+ * @throws WorkflowException
+ */
+ public Collection getPendingQueue(String filePath) throws WorkflowException;
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -30,16 +30,16 @@
import java.util.StringTokenizer;
import java.util.List;
-import javax.naming.CompositeName;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.log4j.Logger;
-import org.jboss.naming.NonSerializableFactory;
import org.jboss.portal.workflow.service.WorkflowService;
import org.jboss.portal.workflow.WorkflowException;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.common.util.Tools;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
@@ -53,451 +53,432 @@
/**
* Created on : Dec 19, 2006
- * @author Sohil Shah - sohil.shah(a)jboss.com
*
+ * @author Sohil Shah - sohil.shah(a)jboss.com
*/
public class ApprovePublishImpl extends AbstractJBossService implements ApprovePublish
{
- /**
- *
- */
- private static final Logger log = Logger.getLogger(ApprovePublishImpl.class);
-
- /**
- *
- */
- private WorkflowService workflowService = null;
- private String process = null;
- private String processName = null;
- private String managerEmails = null;
- private String[] managers = null;
- private boolean overwrite = false;
- private String from = null;
- private String subject = null;
- private String body = null;
-
- private String jndiName = null;
-
- /**
- *
- *
- */
- public ApprovePublishImpl()
- {
-
- }
-
- /**
- *
- */
- public void startService() throws Exception
- {
- super.startService();
-
- if (this.jndiName != null)
- {
- NonSerializableFactory.rebind(new CompositeName(this.jndiName), this, true);
- }
-
- InputStream is = null;
- JbpmContext jbpmContext = null;
- try
- {
- is = new ByteArrayInputStream(this.process.getBytes());
- jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
-
- Document document = DocumentBuilderFactory.newInstance().
- newDocumentBuilder().parse(is);
-
- Element root = document.getDocumentElement();
- this.processName = root.getAttribute("name");
- ProcessDefinition processDefinition = jbpmContext.getGraphSession().
- findLatestProcessDefinition(this.processName);
- if(processDefinition == null)
- {
- processDefinition = ProcessDefinition.
- parseXmlString(this.process);
- jbpmContext.deployProcessDefinition(processDefinition);
- }
- else
- {
- //a process definition already exists....should deploy a new version
- //of the definition if overwrite is true
- ProcessDefinition fromConfig = ProcessDefinition.parseXmlString(this.process);
- if(this.overwrite)
- {
- //if the two of them are not same, create a new version
- //of this process definition
- jbpmContext.deployProcessDefinition(fromConfig);
- }
- }
- }
- catch(Exception e)
- {
- this.stopService();
- throw new RuntimeException(e);
- }
- finally
- {
- if(is!=null)
- {
- try{is.close();}catch(Exception e){}
- }
- if(jbpmContext!=null)
- {
- jbpmContext.close();
- }
- }
-
- //process managers that can serve as approvers/rejecters
- StringTokenizer st = new StringTokenizer(this.managerEmails,",");
- this.managers = new String[st.countTokens()];
- for(int i=0;i<managers.length;i++)
- {
- this.managers[i] = st.nextToken();
- }
- }
-
- /**
- *
- */
- public void stopService() throws Exception
- {
- super.stopService();
-
- if (this.jndiName != null)
- {
- NonSerializableFactory.unbind(this.jndiName);
- }
- }
-
- /**
- *
- * @return
- */
- public WorkflowService getWorkflowService()
- {
- return this.workflowService;
- }
-
- /**
- *
- * @param workflowService
- */
- public void setWorkflowService(WorkflowService workflowService)
- {
- this.workflowService = workflowService;
- }
-
- /**
- *
- * @return
- */
- public String getProcess()
- {
- return this.process;
- }
-
- /**
- *
- * @param process
- */
- public void setProcess(String process)
- {
- this.process = process;
- }
-
-
- /**
- * @return the managerRoles
- */
- public String getManagerEmails()
- {
- return managerEmails;
- }
+ /**
+ *
+ */
+ private static final Logger log = Logger.getLogger(ApprovePublishImpl.class);
- /**
- * @param managerRoles the managerRoles to set
- */
- public void setManagerEmails(String managerEmails)
- {
- this.managerEmails = managerEmails;
- }
-
-
+ /**
+ *
+ */
+ private WorkflowService workflowService = null;
+ private String process = null;
+ private String processName = null;
+ private String managerEmails = null;
+ private String[] managers = null;
+ private boolean overwrite = false;
+ private String from = null;
+ private String subject = null;
+ private String body = null;
+ private JNDI.Binding jndiBinding;
- /**
- * @return the overwrite
- */
- public boolean isOverwrite()
- {
- return overwrite;
- }
+ private String jndiName = null;
- /**
- * @param overwrite the overwrite to set
- */
- public void setOverwrite(boolean overwrite)
- {
- this.overwrite = overwrite;
- }
-
- /**
- *
- * @return
- */
- public String getJNDIName()
- {
- return this.jndiName;
- }
-
- /**
- *
- * @param jndiName
- */
- public void setJNDIName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
-
- /**
- * @return the body
- */
- public String getBody()
- {
- return body;
- }
+ /**
+ *
+ *
+ */
+ public ApprovePublishImpl()
+ {
- /**
- * @param body the body to set
- */
- public void setBody(String body)
- {
- this.body = body;
- }
+ }
- /**
- * @return the from
- */
- public String getFrom()
- {
- return from;
- }
+ /**
+ *
+ */
+ public void startService() throws Exception
+ {
+ super.startService();
- /**
- * @param from the from to set
- */
- public void setFrom(String from)
- {
- this.from = from;
- }
+ if (this.jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
- /**
- * @return the subject
- */
- public String getSubject()
- {
- return subject;
- }
+ InputStream is = null;
+ JbpmContext jbpmContext = null;
+ try
+ {
+ is = new ByteArrayInputStream(this.process.getBytes());
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
- /**
- * @param subject the subject to set
- */
- public void setSubject(String subject)
- {
- this.subject = subject;
- }
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
- //----------ApprovePublish Implementation------------------------------------------------------------------
- /**
- * Called when content is added to the CMS, and needs to be approved by the managers
- * before it can be published to go live
- *
- * @param content
- * @return returns the process id of the workflow process set in motion
- */
- public long requestApproval(Content content) throws WorkflowException
- {
- long processId = 0;
- JbpmContext jbpmContext = null;
- ProcessInstance processInstance = null;
- boolean success = false;
- try
- {
- jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
-
- //The next line creates one execution of the process definition.
- // After construction, the process execution has one main path
- // of execution (=the root token) that is positioned in the
- // start-state.
- processInstance = jbpmContext.newProcessInstance(this.processName);
-
- //After construction, the process execution has one main path
- // of execution (=the root token).
- Token token = processInstance.getRootToken();
-
- //set the process variables
- processInstance.getContextInstance().setVariable("content",content);
- processInstance.getContextInstance().setVariable("managers", this.managers);
- processInstance.getContextInstance().setVariable("from", this.from);
- processInstance.getContextInstance().setVariable("subject", this.subject);
- processInstance.getContextInstance().setVariable("body", this.body);
-
- //start the workflow, starts the cms publish approval workflow
- //this creates a task to approve/reject a cms publish for the Admins
- token.signal();
-
- //mark as a successfull process initiation
- success = true;
- }
- catch(Exception e)
- {
- success = false;
- throw new WorkflowException(e);
- }
- finally
- {
- if(processInstance!=null && success)
- {
- jbpmContext.save(processInstance);
- processId = processInstance.getId();
- }
- if(jbpmContext!=null)
- {
- jbpmContext.close();
- }
- }
- return processId;
- }
-
- /**
- * Called when a manager either approves or rejects the publishing of a specific content to
- * go live
- *
- * @param processId
- * @param manager userId of the manager
- * @param approved true if approved, false if rejected
- */
- public void processManagerResponse(long processId, String manager, boolean approved) throws WorkflowException
- {
- JbpmContext jbpmContext = null;
- ProcessInstance processInstance = null;
- try
- {
- jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
-
- //Now, we search for all process instances of this process definition.
- processInstance = jbpmContext.loadProcessInstance(processId);
-
- if(processInstance.hasEnded())
- {
- log.debug("This process has already ended...");
- return;
- }
-
- processInstance.getContextInstance().setVariable("approved", new Boolean(approved));
-
- Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
- if(allTasks != null)
- {
- for(Iterator itr=allTasks.iterator();itr.hasNext();)
- {
- TaskInstance cour = (TaskInstance)itr.next();
- if(cour.getActorId().equals(manager))
- {
- log.debug("Manager="+cour.getActorId()+"("+processId+")");
-
- //check and make sure this task instance is not marked for deletion
- if(cour.getVariable(processInstance.getId()+":"+cour.getId())!=null)
- {
- continue;
- }
-
- if(!approved)
- {
- cour.start();
- cour.end("rejection");
- break;
- }
- else
- {
- cour.start();
- cour.end("approval");
- break;
- }
- }
- }
- }
- }
- catch(Exception e)
- {
- throw new WorkflowException(e);
- }
- finally
- {
- if(processInstance!=null)
- {
- jbpmContext.save(processInstance);
- }
- if(jbpmContext!=null)
- {
- jbpmContext.close();
- }
- }
- }
-
- /**
- * Retrieves a queue of unapproved content associated with the specified file in the CMS
- *
- * @param filePath
- * @return
- * @throws WorkflowException
- */
- public Collection getPendingQueue(String filePath) throws WorkflowException
- {
- Collection pendingQueue = new ArrayList();
- JbpmContext jbpmContext = null;
- try
- {
- jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
-
- GraphSession graphSession = jbpmContext.getGraphSession();
- ProcessDefinition processDef = graphSession.findLatestProcessDefinition(this.processName);
- List processInstances = graphSession.findProcessInstances(processDef.getId());
-
- if(processInstances != null)
- {
- for(int i=0;i<processInstances.size();i++)
- {
- ProcessInstance cour = (ProcessInstance)processInstances.get(i);
- //iterate through a list of currently pending approval tasks
- if(!cour.hasEnded())
- {
- Content content = (Content)cour.getContextInstance().getVariable("content");
-
- //apply proper criteria to extract pending content only for the specified file
- if(content!=null)
- {
- int lastIndex = content.getPath().lastIndexOf('/');
- String criteriaPath = content.getPath().substring(0,lastIndex);
-
- if(criteriaPath.trim().equals(filePath.trim()))
- {
- pendingQueue.add(content);
- }
- }
- }
- }
- }
- }
- finally
- {
- if(jbpmContext!=null)
- {
- jbpmContext.close();
- }
- }
- return pendingQueue;
- }
+ Element root = document.getDocumentElement();
+ this.processName = root.getAttribute("name");
+ ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition(this.processName);
+ if (processDefinition == null)
+ {
+ processDefinition = ProcessDefinition.parseXmlString(this.process);
+ jbpmContext.deployProcessDefinition(processDefinition);
+ }
+ else
+ {
+ // A process definition already exists....should deploy a new version
+ // of the definition if overwrite is true
+ ProcessDefinition fromConfig = ProcessDefinition.parseXmlString(this.process);
+ if (this.overwrite)
+ {
+ // If the two of them are not same, create a new version
+ // of this process definition
+ jbpmContext.deployProcessDefinition(fromConfig);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ //
+ this.stopService();
+
+ //
+ throw e;
+ }
+ finally
+ {
+ Tools.safeClose(is);
+ Tools.safeClose(jbpmContext);
+ }
+
+ //process managers that can serve as approvers/rejecters
+ StringTokenizer st = new StringTokenizer(this.managerEmails, ",");
+ this.managers = new String[st.countTokens()];
+ for (int i = 0; i < managers.length; i++)
+ {
+ this.managers[i] = st.nextToken();
+ }
+ }
+
+ /**
+ *
+ */
+ public void stopService() throws Exception
+ {
+ super.stopService();
+
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+
+ /**
+ * @return
+ */
+ public WorkflowService getWorkflowService()
+ {
+ return this.workflowService;
+ }
+
+ /**
+ * @param workflowService
+ */
+ public void setWorkflowService(WorkflowService workflowService)
+ {
+ this.workflowService = workflowService;
+ }
+
+ /**
+ * @return
+ */
+ public String getProcess()
+ {
+ return this.process;
+ }
+
+ /**
+ * @param process
+ */
+ public void setProcess(String process)
+ {
+ this.process = process;
+ }
+
+
+ /**
+ * @return the managerRoles
+ */
+ public String getManagerEmails()
+ {
+ return managerEmails;
+ }
+
+ /**
+ * @param managerEmails the manager emails to set
+ */
+ public void setManagerEmails(String managerEmails)
+ {
+ this.managerEmails = managerEmails;
+ }
+
+
+ /**
+ * @return the overwrite
+ */
+ public boolean isOverwrite()
+ {
+ return overwrite;
+ }
+
+ /**
+ * @param overwrite the overwrite to set
+ */
+ public void setOverwrite(boolean overwrite)
+ {
+ this.overwrite = overwrite;
+ }
+
+ /**
+ * @return
+ */
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ /**
+ * @param jndiName
+ */
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+
+ /**
+ * @return the body
+ */
+ public String getBody()
+ {
+ return body;
+ }
+
+ /**
+ * @param body the body to set
+ */
+ public void setBody(String body)
+ {
+ this.body = body;
+ }
+
+ /**
+ * @return the from
+ */
+ public String getFrom()
+ {
+ return from;
+ }
+
+ /**
+ * @param from the from to set
+ */
+ public void setFrom(String from)
+ {
+ this.from = from;
+ }
+
+ /**
+ * @return the subject
+ */
+ public String getSubject()
+ {
+ return subject;
+ }
+
+ /**
+ * @param subject the subject to set
+ */
+ public void setSubject(String subject)
+ {
+ this.subject = subject;
+ }
+
+ //----------ApprovePublish Implementation------------------------------------------------------------------
+ /**
+ * Called when content is added to the CMS, and needs to be approved by the managers
+ * before it can be published to go live
+ *
+ * @param content
+ * @return returns the process id of the workflow process set in motion
+ */
+ public long requestApproval(Content content) throws WorkflowException
+ {
+ long processId = 0;
+ JbpmContext jbpmContext = null;
+ ProcessInstance processInstance = null;
+ boolean success = false;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ //The next line creates one execution of the process definition.
+ // After construction, the process execution has one main path
+ // of execution (=the root token) that is positioned in the
+ // start-state.
+ processInstance = jbpmContext.newProcessInstance(this.processName);
+
+ //After construction, the process execution has one main path
+ // of execution (=the root token).
+ Token token = processInstance.getRootToken();
+
+ //set the process variables
+ processInstance.getContextInstance().setVariable("content", content);
+ processInstance.getContextInstance().setVariable("managers", this.managers);
+ processInstance.getContextInstance().setVariable("from", this.from);
+ processInstance.getContextInstance().setVariable("subject", this.subject);
+ processInstance.getContextInstance().setVariable("body", this.body);
+
+ //start the workflow, starts the cms publish approval workflow
+ //this creates a task to approve/reject a cms publish for the Admins
+ token.signal();
+
+ //mark as a successfull process initiation
+ success = true;
+ }
+ catch (Exception e)
+ {
+ success = false;
+ throw new WorkflowException(e);
+ }
+ finally
+ {
+ if (processInstance != null && success)
+ {
+ jbpmContext.save(processInstance);
+ processId = processInstance.getId();
+ }
+ Tools.safeClose(jbpmContext);
+ }
+ return processId;
+ }
+
+ /**
+ * Called when a manager either approves or rejects the publishing of a specific content to
+ * go live
+ *
+ * @param processId
+ * @param manager userId of the manager
+ * @param approved true if approved, false if rejected
+ */
+ public void processManagerResponse(long processId, String manager, boolean approved) throws WorkflowException
+ {
+ JbpmContext jbpmContext = null;
+ ProcessInstance processInstance = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ //Now, we search for all process instances of this process definition.
+ processInstance = jbpmContext.loadProcessInstance(processId);
+
+ if (processInstance.hasEnded())
+ {
+ log.debug("This process has already ended...");
+ return;
+ }
+
+ processInstance.getContextInstance().setVariable("approved", new Boolean(approved));
+
+ Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
+ if (allTasks != null)
+ {
+ for (Iterator itr = allTasks.iterator(); itr.hasNext();)
+ {
+ TaskInstance cour = (TaskInstance)itr.next();
+ if (cour.getActorId().equals(manager))
+ {
+ log.debug("Manager=" + cour.getActorId() + "(" + processId + ")");
+
+ //check and make sure this task instance is not marked for deletion
+ if (cour.getVariable(processInstance.getId() + ":" + cour.getId()) != null)
+ {
+ continue;
+ }
+
+ if (!approved)
+ {
+ cour.start();
+ cour.end("rejection");
+ break;
+ }
+ else
+ {
+ cour.start();
+ cour.end("approval");
+ break;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new WorkflowException(e);
+ }
+ finally
+ {
+ if (processInstance != null)
+ {
+ jbpmContext.save(processInstance);
+ }
+ Tools.safeClose(jbpmContext);
+ }
+ }
+
+ /**
+ * Retrieves a queue of unapproved content associated with the specified file in the CMS
+ *
+ * @param filePath
+ * @return
+ * @throws WorkflowException
+ */
+ public Collection getPendingQueue(String filePath) throws WorkflowException
+ {
+ Collection pendingQueue = new ArrayList();
+ JbpmContext jbpmContext = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+ ProcessDefinition processDef = graphSession.findLatestProcessDefinition(this.processName);
+ List processInstances = graphSession.findProcessInstances(processDef.getId());
+
+ if (processInstances != null)
+ {
+ for (int i = 0; i < processInstances.size(); i++)
+ {
+ ProcessInstance cour = (ProcessInstance)processInstances.get(i);
+ //iterate through a list of currently pending approval tasks
+ if (!cour.hasEnded())
+ {
+ Content content = (Content)cour.getContextInstance().getVariable("content");
+
+ //apply proper criteria to extract pending content only for the specified file
+ if (content != null)
+ {
+ int lastIndex = content.getPath().lastIndexOf('/');
+ String criteriaPath = content.getPath().substring(0, lastIndex);
+
+ if (criteriaPath.trim().equals(filePath.trim()))
+ {
+ pendingQueue.add(content);
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ Tools.safeClose(jbpmContext);
+ }
+ return pendingQueue;
+ }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -31,82 +31,80 @@
import javax.servlet.UnavailableException;
import javax.naming.InitialContext;
+
import org.jboss.portal.workflow.cms.ApprovePublish;
/**
* Created on : Dec 20, 2006
- * @author Sohil Shah - sohil.shah(a)jboss.com
*
+ * @author Sohil Shah - sohil.shah(a)jboss.com
*/
public class ApprovePublishServlet extends HttpServlet
{
- private ApprovePublish approvePublishWorkflow = null;
- /**
- *
- */
- public void init() throws ServletException
- {
- try
- {
- super.init();
- InitialContext context = new InitialContext();
- approvePublishWorkflow = (ApprovePublish)context.lookup("java:portal/ApprovePublishWorkflow");
- }
- catch(Exception e)
- {
- throw new UnavailableException(e.toString());
- }
- }
+ private ApprovePublish approvePublishWorkflow = null;
- /**
- *
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- this.doPost(request, response);
- }
+ /**
+ *
+ */
+ public void init() throws ServletException
+ {
+ try
+ {
+ super.init();
+ InitialContext context = new InitialContext();
+ approvePublishWorkflow = (ApprovePublish)context.lookup("java:portal/ApprovePublishWorkflow");
+ }
+ catch (Exception e)
+ {
+ throw new UnavailableException(e.toString());
+ }
+ }
- /**
- *
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- try
- {
- String processId = request.getParameter("pId");
- String manager = request.getParameter("manager");
- boolean approve = false;
- if(request.getRequestURI().indexOf("approve")!=-1)
- {
- approve = true;
- }
-
- this.approvePublishWorkflow.processManagerResponse(
- Long.parseLong(processId),manager,approve
- );
-
- /**
- * TODO: this is a hack job until a decent GUI is integrated
- * with this workflow..Yes Yes, this will be based on JSP then
- */
- StringBuffer buffer = new StringBuffer();
- buffer.append("<html>\n");
- if(approve)
- {
- buffer.append("<span>The content was successfully published</span>\n");
- }
- else
- {
- buffer.append("<span>The content publish request was rejected</span>\n");
- }
- buffer.append("</html>\n");
-
- response.getWriter().write(buffer.toString());
- response.getWriter().flush();
- }
- catch(Exception e)
- {
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,e.toString());
- }
- }
+ /**
+ *
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ this.doPost(request, response);
+ }
+
+ /**
+ *
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ try
+ {
+ String processId = request.getParameter("pId");
+ String manager = request.getParameter("manager");
+ boolean approve = request.getRequestURI().indexOf("approve") != -1;
+
+ this.approvePublishWorkflow.processManagerResponse(
+ Long.parseLong(processId), manager, approve
+ );
+
+ /**
+ * TODO: this is a hack job until a decent GUI is integrated
+ * with this workflow..Yes Yes, this will be based on JSP then
+ */
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<html>\n");
+ if (approve)
+ {
+ buffer.append("<span>The content was successfully published</span>\n");
+ }
+ else
+ {
+ buffer.append("<span>The content publish request was rejected</span>\n");
+ }
+ buffer.append("</html>\n");
+
+ response.getWriter().write(buffer.toString());
+ response.getWriter().flush();
+ }
+ catch (Exception e)
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+ }
+ }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -29,119 +29,120 @@
/**
* Created on : Dec 20, 2006
+ *
* @author Sohil Shah - sohil.shah(a)jboss.com
- *
*/
public class Content implements Serializable
{
- private String path = null;
- private String userName = null;
- private String mimeType = null;
- private int size = 0;
- private Date creationDate = null;
-
- /**
- *
- *
- */
- public Content()
- {
-
- }
- /**
- * @return the path
- */
- public String getPath()
- {
- return path;
- }
+ private String path = null;
+ private String userName = null;
+ private String mimeType = null;
+ private int size = 0;
+ private Date creationDate = null;
- /**
- * @param path the path to set
- */
- public void setPath(String path)
- {
- this.path = path;
- }
+ /**
+ *
+ *
+ */
+ public Content()
+ {
- /**
- * @return the userName
- */
- public String getUserName()
- {
- return userName;
- }
+ }
- /**
- * @param userName the userName to set
- */
- public void setUserName(String userName)
- {
- this.userName = userName;
- }
+ /**
+ * @return the path
+ */
+ public String getPath()
+ {
+ return path;
+ }
- /**
- * @return the mimeType
- */
- public String getMimeType()
- {
- return mimeType;
- }
+ /**
+ * @param path the path to set
+ */
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
- /**
- * @param mimeType the mimeType to set
- */
- public void setMimeType(String mimeType)
- {
- this.mimeType = mimeType;
- }
+ /**
+ * @return the userName
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
- /**
- * @return the size
- */
- public int getSize()
- {
- return size;
- }
+ /**
+ * @param userName the userName to set
+ */
+ public void setUserName(String userName)
+ {
+ this.userName = userName;
+ }
- /**
- * @param size the size to set
- */
- public void setSize(int size)
- {
- this.size = size;
- }
-
- public String getSizeStr()
- {
- return String.valueOf((this.size / 1024))+"kb";
- }
+ /**
+ * @return the mimeType
+ */
+ public String getMimeType()
+ {
+ return mimeType;
+ }
- /**
- * @return the creationDate
- */
- public Date getCreationDate()
- {
- return creationDate;
- }
+ /**
+ * @param mimeType the mimeType to set
+ */
+ public void setMimeType(String mimeType)
+ {
+ this.mimeType = mimeType;
+ }
- /**
- * @param creationDate the creationDate to set
- */
- public void setCreationDate(Date creationDate)
- {
- this.creationDate = creationDate;
- }
-
- public String getCreationDateStr()
- {
- String date = "";
- if (this.creationDate != null)
- {
- Format formatter = new SimpleDateFormat("MM/dd/yy HH:mm");
- date = formatter.format(this.creationDate);
- }
- return date;
- }
+ /**
+ * @return the size
+ */
+ public int getSize()
+ {
+ return size;
+ }
+
+ /**
+ * @param size the size to set
+ */
+ public void setSize(int size)
+ {
+ this.size = size;
+ }
+
+ public String getSizeStr()
+ {
+ return String.valueOf((this.size / 1024)) + "kb";
+ }
+
+ /**
+ * @return the creationDate
+ */
+ public Date getCreationDate()
+ {
+ return creationDate;
+ }
+
+ /**
+ * @param creationDate the creationDate to set
+ */
+ public void setCreationDate(Date creationDate)
+ {
+ this.creationDate = creationDate;
+ }
+
+ public String getCreationDateStr()
+ {
+ String date = "";
+ if (this.creationDate != null)
+ {
+ Format formatter = new SimpleDateFormat("MM/dd/yy HH:mm");
+ date = formatter.format(this.creationDate);
+ }
+ return date;
+ }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -27,28 +27,27 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
-
/**
- *
* Created on : Dec 21, 2006
- * @author Sohil Shah - sohil.shah(a)jboss.com
*
+ * @author Sohil Shah - sohil.shah(a)jboss.com
*/
-public class TaskExceptionHandler implements ActionHandler
+public class TaskExceptionHandler implements ActionHandler
{
- /**
- *
- */
- public void execute(ExecutionContext executionContext)
- {
- TaskInstance current = executionContext.getTaskInstance();
-
- TaskInstance t = executionContext.getTaskMgmtInstance().
- createTaskInstance(executionContext.getTask(),executionContext);
- t.setActorId(current.getActorId());
-
- current.setVariable(executionContext.getProcessInstance().getId()+":"+current.getId(), "markAsDeleted");
-
- throw new RuntimeException(executionContext.getException());
- }
+
+ /**
+ *
+ */
+ public void execute(ExecutionContext executionContext)
+ {
+ TaskInstance current = executionContext.getTaskInstance();
+
+ TaskInstance t = executionContext.getTaskMgmtInstance().
+ createTaskInstance(executionContext.getTask(), executionContext);
+ t.setActorId(current.getActorId());
+
+ current.setVariable(executionContext.getProcessInstance().getId() + ":" + current.getId(), "markAsDeleted");
+
+ throw new RuntimeException(executionContext.getException());
+ }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -26,38 +26,39 @@
import org.jbpm.graph.exe.*;
// MyActionHandler represents a class that could execute
+
// some user code during the execution of a jBPM process.
/**
* @author sohil.shah(a)jboss.com
*/
-public class Finalize implements ActionHandler
+public class Finalize implements ActionHandler
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- // Before each test (in the setUp), the isExecuted member
- // will be set to false.
- public static boolean isExecuted = false;
+ // Before each test (in the setUp), the isExecuted member
+ // will be set to false.
+ public static boolean isExecuted = false;
- // The action will set the isExecuted to true so the
- // unit test will be able to show when the action
- // is being executed.
- public void execute(ExecutionContext executionContext)
- {
- String path = (String)executionContext.getContextInstance().getVariable("path");
-
- Object rejection = executionContext.getContextInstance().getVariable("rejection");
-
- if(rejection!=null)
- {
- System.out.println("This publish request was rejected....."+path);
- }
- else
- {
- System.out.println("This publish request was approved....."+path);
- }
-
-
- isExecuted = true;
- }
+ // The action will set the isExecuted to true so the
+ // unit test will be able to show when the action
+ // is being executed.
+ public void execute(ExecutionContext executionContext)
+ {
+ String path = (String)executionContext.getContextInstance().getVariable("path");
+
+ Object rejection = executionContext.getContextInstance().getVariable("rejection");
+
+ if (rejection != null)
+ {
+ System.out.println("This publish request was rejected....." + path);
+ }
+ else
+ {
+ System.out.println("This publish request was approved....." + path);
+ }
+
+
+ isExecuted = true;
+ }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -34,199 +34,214 @@
import org.jbpm.graph.exe.Token;
/**
- *
* @author sohil.shah(a)jboss.com
- *
*/
-public class HelloWorldDbTest extends TestCase {
-
- static JbpmConfiguration jbpmConfiguration = null;
+public class HelloWorldDbTest extends TestCase
+{
- static {
- // An example configuration file such as this can be found in
- // 'src/config.files'. Typically the configuration information is in the
- // resource file 'jbpm.cfg.xml', but here we pass in the configuration
- // information as an XML string.
-
- // First we create a JbpmConfiguration statically. One JbpmConfiguration
- // can be used for all threads in the system, that is why we can safely
- // make it static.
+ static JbpmConfiguration jbpmConfiguration = null;
- jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
-
- // A jbpm-context mechanism separates the jbpm core
- // engine from the services that jbpm uses from
- // the environment.
-
- " <jbpm-context>" +
- " <service name='persistence' " +
- " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
- " </jbpm-context>" +
-
- // Also all the resource files that are used by jbpm are
- // referenced from the jbpm.cfg.xml
-
- " <string name='resource.hibernate.cfg.xml' " +
- " value='conf/hibernate.cfg.xml' />" +
- " <string name='resource.business.calendar' " +
- " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
- " <string name='resource.default.modules' " +
- " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
- " <string name='resource.converter' " +
- " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
- " <string name='resource.action.types' " +
- " value='org/jbpm/graph/action/action.types.xml' />" +
- " <string name='resource.node.types' " +
- " value='org/jbpm/graph/node/node.types.xml' />" +
- " <string name='resource.varmapping' " +
- " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
- "</jbpm-configuration>"
- );
- }
-
- public void setUp() {
- jbpmConfiguration.createSchema();
- }
-
- public void tearDown() {
- jbpmConfiguration.dropSchema();
- }
+ static
+ {
+ // An example configuration file such as this can be found in
+ // 'src/config.files'. Typically the configuration information is in the
+ // resource file 'jbpm.cfg.xml', but here we pass in the configuration
+ // information as an XML string.
- public void testSimplePersistence() {
- // Between the 3 method calls below, all data is passed via the
- // database. Here, in this unit test, these 3 methods are executed
- // right after each other because we want to test a complete process
- // scenario. But in reality, these methods represent different
- // requests to a server.
-
- // Since we start with a clean, empty in-memory database, we have to
- // deploy the process first. In reality, this is done once by the
- // process developer.
- deployProcessDefinition();
+ // First we create a JbpmConfiguration statically. One JbpmConfiguration
+ // can be used for all threads in the system, that is why we can safely
+ // make it static.
- // Suppose we want to start a process instance (=process execution)
- // when a user submits a form in a web application...
- processInstanceIsCreatedWhenUserSubmitsWebappForm();
+ jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
- // Then, later, upon the arrival of an asynchronous message the
- // execution must continue.
- theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
- }
+ // A jbpm-context mechanism separates the jbpm core
+ // engine from the services that jbpm uses from
+ // the environment.
- public void deployProcessDefinition() {
- // This test shows a process definition and one execution
- // of the process definition. The process definition has
- // 3 nodes: an unnamed start-state, a state 's' and an
- // end-state named 'end'.
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='hello_world'>" +
- " <start-state name='start'>" +
- " <transition to='s' />" +
- " </start-state>" +
- " <state name='s'>" +
- " <transition to='end' />" +
- " </state>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ " <jbpm-context>" +
+ " <service name='persistence' " +
+ " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
+ " </jbpm-context>" +
- // Lookup the pojo persistence context-builder that is configured above
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- // Deploy the process definition in the database
- jbpmContext.deployProcessDefinition(processDefinition);
+ // Also all the resource files that are used by jbpm are
+ // referenced from the jbpm.cfg.xml
- } finally {
- // Tear down the pojo persistence context.
- // This includes flush the SQL for inserting the process definition
- // to the database.
- jbpmContext.close();
- }
- }
+ " <string name='resource.hibernate.cfg.xml' " +
+ " value='conf/hibernate.cfg.xml' />" +
+ " <string name='resource.business.calendar' " +
+ " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
+ " <string name='resource.default.modules' " +
+ " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
+ " <string name='resource.converter' " +
+ " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
+ " <string name='resource.action.types' " +
+ " value='org/jbpm/graph/action/action.types.xml' />" +
+ " <string name='resource.node.types' " +
+ " value='org/jbpm/graph/node/node.types.xml' />" +
+ " <string name='resource.varmapping' " +
+ " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
+ "</jbpm-configuration>"
+ );
+ }
- public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
- // The code in this method could be inside a struts-action
- // or a JSF managed bean.
+ public void setUp()
+ {
+ jbpmConfiguration.createSchema();
+ }
- // Lookup the pojo persistence context-builder that is configured above
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
+ public void tearDown()
+ {
+ jbpmConfiguration.dropSchema();
+ }
- GraphSession graphSession = jbpmContext.getGraphSession();
-
- ProcessDefinition processDefinition =
- graphSession.findLatestProcessDefinition("hello_world");
-
- // With the processDefinition that we retrieved from the database, we
- // can create an execution of the process definition just like in the
- // hello_world example (which was without persistence).
- ProcessInstance processInstance =
- new ProcessInstance(processDefinition);
-
- Token token = processInstance.getRootToken();
- assertEquals("start", token.getNode().getName());
- // Let's start the process execution
- token.signal();
- // Now the process is in the state 's'.
- assertEquals("s", token.getNode().getName());
-
- // Now the processInstance is saved in the database. So the
- // current state of the execution of the process is stored in the
- // database.
- jbpmContext.save(processInstance);
- // The method below will get the process instance back out
- // of the database and resume execution by providing another
- // external signal.
+ public void testSimplePersistence()
+ {
+ // Between the 3 method calls below, all data is passed via the
+ // database. Here, in this unit test, these 3 methods are executed
+ // right after each other because we want to test a complete process
+ // scenario. But in reality, these methods represent different
+ // requests to a server.
- } finally {
- // Tear down the pojo persistence context.
- jbpmContext.close();
- }
- }
+ // Since we start with a clean, empty in-memory database, we have to
+ // deploy the process first. In reality, this is done once by the
+ // process developer.
+ deployProcessDefinition();
- public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
- // The code in this method could be the content of a message driven bean.
-
- // Lookup the pojo persistence context-builder that is configured above
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
+ // Suppose we want to start a process instance (=process execution)
+ // when a user submits a form in a web application...
+ processInstanceIsCreatedWhenUserSubmitsWebappForm();
- GraphSession graphSession = jbpmContext.getGraphSession();
- // First, we need to get the process instance back out of the database.
- // There are several options to know what process instance we are dealing
- // with here. The easiest in this simple test case is just to look for
- // the full list of process instances. That should give us only one
- // result. So let's look up the process definition.
-
- ProcessDefinition processDefinition =
- graphSession.findLatestProcessDefinition("hello_world");
+ // Then, later, upon the arrival of an asynchronous message the
+ // execution must continue.
+ theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
+ }
- // Now, we search for all process instances of this process definition.
- List processInstances =
- graphSession.findProcessInstances(processDefinition.getId());
-
- // Because we know that in the context of this unit test, there is
- // only one execution. In real life, the processInstanceId can be
- // extracted from the content of the message that arrived or from
- // the user making a choice.
- ProcessInstance processInstance =
- (ProcessInstance) processInstances.get(0);
-
- // Now we can continue the execution. Note that the processInstance
- // delegates signals to the main path of execution (=the root token).
- processInstance.signal();
+ public void deployProcessDefinition()
+ {
+ // This test shows a process definition and one execution
+ // of the process definition. The process definition has
+ // 3 nodes: an unnamed start-state, a state 's' and an
+ // end-state named 'end'.
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition name='hello_world'>" +
+ " <start-state name='start'>" +
+ " <transition to='s' />" +
+ " </start-state>" +
+ " <state name='s'>" +
+ " <transition to='end' />" +
+ " </state>" +
+ " <end-state name='end' />" +
+ "</process-definition>"
+ );
- // After this signal, we know the process execution should have
- // arrived in the end-state.
- assertTrue(processInstance.hasEnded());
-
- // Now we can update the state of the execution in the database
- jbpmContext.save(processInstance);
+ // Lookup the pojo persistence context-builder that is configured above
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ // Deploy the process definition in the database
+ jbpmContext.deployProcessDefinition(processDefinition);
- } finally {
- // Tear down the pojo persistence context.
- jbpmContext.close();
- }
- }
+ }
+ finally
+ {
+ // Tear down the pojo persistence context.
+ // This includes flush the SQL for inserting the process definition
+ // to the database.
+ jbpmContext.close();
+ }
+ }
+
+ public void processInstanceIsCreatedWhenUserSubmitsWebappForm()
+ {
+ // The code in this method could be inside a struts-action
+ // or a JSF managed bean.
+
+ // Lookup the pojo persistence context-builder that is configured above
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+
+ ProcessDefinition processDefinition =
+ graphSession.findLatestProcessDefinition("hello_world");
+
+ // With the processDefinition that we retrieved from the database, we
+ // can create an execution of the process definition just like in the
+ // hello_world example (which was without persistence).
+ ProcessInstance processInstance =
+ new ProcessInstance(processDefinition);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start", token.getNode().getName());
+ // Let's start the process execution
+ token.signal();
+ // Now the process is in the state 's'.
+ assertEquals("s", token.getNode().getName());
+
+ // Now the processInstance is saved in the database. So the
+ // current state of the execution of the process is stored in the
+ // database.
+ jbpmContext.save(processInstance);
+ // The method below will get the process instance back out
+ // of the database and resume execution by providing another
+ // external signal.
+
+ }
+ finally
+ {
+ // Tear down the pojo persistence context.
+ jbpmContext.close();
+ }
+ }
+
+ public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived()
+ {
+ // The code in this method could be the content of a message driven bean.
+
+ // Lookup the pojo persistence context-builder that is configured above
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+ // First, we need to get the process instance back out of the database.
+ // There are several options to know what process instance we are dealing
+ // with here. The easiest in this simple test case is just to look for
+ // the full list of process instances. That should give us only one
+ // result. So let's look up the process definition.
+
+ ProcessDefinition processDefinition =
+ graphSession.findLatestProcessDefinition("hello_world");
+
+ // Now, we search for all process instances of this process definition.
+ List processInstances =
+ graphSession.findProcessInstances(processDefinition.getId());
+
+ // Because we know that in the context of this unit test, there is
+ // only one execution. In real life, the processInstanceId can be
+ // extracted from the content of the message that arrived or from
+ // the user making a choice.
+ ProcessInstance processInstance =
+ (ProcessInstance)processInstances.get(0);
+
+ // Now we can continue the execution. Note that the processInstance
+ // delegates signals to the main path of execution (=the root token).
+ processInstance.signal();
+
+ // After this signal, we know the process execution should have
+ // arrived in the end-state.
+ assertTrue(processInstance.hasEnded());
+
+ // Now we can update the state of the execution in the database
+ jbpmContext.save(processInstance);
+
+ }
+ finally
+ {
+ // Tear down the pojo persistence context.
+ jbpmContext.close();
+ }
+ }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -35,275 +35,270 @@
import junit.framework.TestCase;
/**
- *
* @author sohil.shah(a)jboss.com
- *
*/
-public class PortalCMSPublish extends TestCase
+public class PortalCMSPublish extends TestCase
{
- static JbpmConfiguration jbpmConfiguration = null;
- static ProcessDefinition processDefinition = null;
+ static JbpmConfiguration jbpmConfiguration = null;
+ static ProcessDefinition processDefinition = null;
- static
- {
- // An example configuration file such as this can be found in
- // 'src/config.files'. Typically the configuration information is in the
- // resource file 'jbpm.cfg.xml', but here we pass in the configuration
- // information as an XML string.
-
- // First we create a JbpmConfiguration statically. One JbpmConfiguration
- // can be used for all threads in the system, that is why we can safely
- // make it static.
+ static
+ {
+ // An example configuration file such as this can be found in
+ // 'src/config.files'. Typically the configuration information is in the
+ // resource file 'jbpm.cfg.xml', but here we pass in the configuration
+ // information as an XML string.
- jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
-
- // A jbpm-context mechanism separates the jbpm core
- // engine from the services that jbpm uses from
- // the environment.
-
- " <jbpm-context>" +
- " <service name='persistence' " +
- " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
- " </jbpm-context>" +
-
- // Also all the resource files that are used by jbpm are
- // referenced from the jbpm.cfg.xml
-
- " <string name='resource.hibernate.cfg.xml' " +
- " value='conf/hibernate.cfg.xml' />" +
- " <string name='resource.business.calendar' " +
- " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
- " <string name='resource.default.modules' " +
- " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
- " <string name='resource.converter' " +
- " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
- " <string name='resource.action.types' " +
- " value='org/jbpm/graph/action/action.types.xml' />" +
- " <string name='resource.node.types' " +
- " value='org/jbpm/graph/node/node.types.xml' />" +
- " <string name='resource.varmapping' " +
- " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
- "</jbpm-configuration>"
- );
-
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='approval_workflow'>" +
- " <start-state>" +
- " <transition to='request_approval'/>" +
- " </start-state>" +
- " <task-node name='request_approval'>"+
- " <task name='approve_publish'>" +
- " <assignment class='org.jboss.portal.workflow.test.PublishAssignmentHandler'/>" +
- " </task>" +
- " <controller>" +
- " <variable name='path' access='read'/>"+
- " </controller>"+
- " <transition name='approval' to='end'/>" +
- " <transition name='rejection' to='end'>" +
- " <script name='signalRejection'>"+
- " <variable name='rejection'/>"+
- " <expression>"+
- " System.out.println(\"Running the rejection script....\");rejection=true;"+
- " </expression>"+
- " </script>"+
- " </transition>"+
- " </task-node>"+
- " <end-state name='end'>" +
- " <event type='node-enter'>"+
- " <action class='org.jboss.portal.workflow.test.Finalize'/>"+
- " </event>"+
- " </end-state>"+
- "</process-definition>"
- );
- }
-
- /**
- *
- */
- public void setUp()
- {
- jbpmConfiguration.createSchema();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- jbpmContext.deployProcessDefinition(processDefinition);
- }
- finally
- {
- jbpmContext.close();
- }
- }
+ // First we create a JbpmConfiguration statically. One JbpmConfiguration
+ // can be used for all threads in the system, that is why we can safely
+ // make it static.
- /**
- *
- */
- protected void tearDown() throws Exception
- {
- jbpmConfiguration.dropSchema();
- }
-
- public void testCMSPublish() throws Exception
- {
- long processId1 = this.createTask("/default/index.html");
- long processId2 = this.createTask("/default/index2.html");
-
- ApprovalThread t1 = new ApprovalThread(processId1,"/default/index.html",true);
- ApprovalThread t2 = new ApprovalThread(processId2,"/default/index2.html",false);
- Thread thread1 = new Thread(t1);
- Thread thread2 = new Thread(t2);
-
- thread1.start();
- thread2.start();
-
- while(!t1.done || !t2.done)
- {
- //busy wait here
- }
- }
-
- /**
- *
- * @param path
- * @return
- */
- private long createTask(String path)
- {
- long processId = 0;
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = null;
- try
- {
- //The next line creates one execution of the process definition.
- // After construction, the process execution has one main path
- // of execution (=the root token) that is positioned in the
- // start-state.
- processInstance = jbpmContext.newProcessInstance("approval_workflow");
-
- //After construction, the process execution has one main path
- // of execution (=the root token).
- Token token = processInstance.getRootToken();
-
- //set the process variables
- processInstance.getContextInstance().setVariable("path",path);
-
- //start the workflow, starts the cms publish approval workflow
- //this creates a task to approve/reject a cms publish for the Admins
- token.signal();
- }
- finally
- {
- if(processInstance!=null)
- {
- jbpmContext.save(processInstance);
- processId = processInstance.getId();
+ jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+
+ // A jbpm-context mechanism separates the jbpm core
+ // engine from the services that jbpm uses from
+ // the environment.
+
+ " <jbpm-context>" +
+ " <service name='persistence' " +
+ " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
+ " </jbpm-context>" +
+
+ // Also all the resource files that are used by jbpm are
+ // referenced from the jbpm.cfg.xml
+
+ " <string name='resource.hibernate.cfg.xml' " +
+ " value='conf/hibernate.cfg.xml' />" +
+ " <string name='resource.business.calendar' " +
+ " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
+ " <string name='resource.default.modules' " +
+ " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
+ " <string name='resource.converter' " +
+ " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
+ " <string name='resource.action.types' " +
+ " value='org/jbpm/graph/action/action.types.xml' />" +
+ " <string name='resource.node.types' " +
+ " value='org/jbpm/graph/node/node.types.xml' />" +
+ " <string name='resource.varmapping' " +
+ " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
+ "</jbpm-configuration>"
+ );
+
+ processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition name='approval_workflow'>" +
+ " <start-state>" +
+ " <transition to='request_approval'/>" +
+ " </start-state>" +
+ " <task-node name='request_approval'>" +
+ " <task name='approve_publish'>" +
+ " <assignment class='org.jboss.portal.workflow.test.PublishAssignmentHandler'/>" +
+ " </task>" +
+ " <controller>" +
+ " <variable name='path' access='read'/>" +
+ " </controller>" +
+ " <transition name='approval' to='end'/>" +
+ " <transition name='rejection' to='end'>" +
+ " <script name='signalRejection'>" +
+ " <variable name='rejection'/>" +
+ " <expression>" +
+ " System.out.println(\"Running the rejection script....\");rejection=true;" +
+ " </expression>" +
+ " </script>" +
+ " </transition>" +
+ " </task-node>" +
+ " <end-state name='end'>" +
+ " <event type='node-enter'>" +
+ " <action class='org.jboss.portal.workflow.test.Finalize'/>" +
+ " </event>" +
+ " </end-state>" +
+ "</process-definition>"
+ );
+ }
+
+ /**
+ *
+ */
+ public void setUp()
+ {
+ jbpmConfiguration.createSchema();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ jbpmContext.deployProcessDefinition(processDefinition);
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+
+ /**
+ *
+ */
+ protected void tearDown() throws Exception
+ {
+ jbpmConfiguration.dropSchema();
+ }
+
+ public void testCMSPublish() throws Exception
+ {
+ long processId1 = this.createTask("/default/index.html");
+ long processId2 = this.createTask("/default/index2.html");
+
+ ApprovalThread t1 = new ApprovalThread(processId1, "/default/index.html", true);
+ ApprovalThread t2 = new ApprovalThread(processId2, "/default/index2.html", false);
+ Thread thread1 = new Thread(t1);
+ Thread thread2 = new Thread(t2);
+
+ thread1.start();
+ thread2.start();
+
+ while (!t1.done || !t2.done)
+ {
+ //busy wait here
+ }
+ }
+
+ /**
+ * @param path
+ * @return
+ */
+ private long createTask(String path)
+ {
+ long processId = 0;
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = null;
+ try
+ {
+ //The next line creates one execution of the process definition.
+ // After construction, the process execution has one main path
+ // of execution (=the root token) that is positioned in the
+ // start-state.
+ processInstance = jbpmContext.newProcessInstance("approval_workflow");
+
+ //After construction, the process execution has one main path
+ // of execution (=the root token).
+ Token token = processInstance.getRootToken();
+
+ //set the process variables
+ processInstance.getContextInstance().setVariable("path", path);
+
+ //start the workflow, starts the cms publish approval workflow
+ //this creates a task to approve/reject a cms publish for the Admins
+ token.signal();
+ }
+ finally
+ {
+ if (processInstance != null)
+ {
+ jbpmContext.save(processInstance);
+ processId = processInstance.getId();
+ }
+ jbpmContext.close();
+ }
+ return processId;
+ }
+
+ /**
+ * @param path
+ * @param processId
+ * @param manager
+ * @param reject
+ * @throws Exception
+ */
+ private void executeTask(String path, long processId, String manager, boolean reject) throws Exception
+ {
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = null;
+ try
+ {
+ // Now, we search for all process instances of this process definition.
+ processInstance = jbpmContext.loadProcessInstance(processId);
+
+ if (processInstance.hasEnded())
+ {
+ System.out.println("This process has already ended...");
+ return;
+ }
+
+ //here act as an Admin and approve/reject one of the tasks
+ Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
+ String[] transitions = {"approval", "rejection"};
+ java.util.Random random = new java.util.Random(12343);
+ boolean markedForRejection = false;
+ for (Iterator itr = allTasks.iterator(); itr.hasNext();)
+ {
+ TaskInstance cour = (TaskInstance)itr.next();
+ if (markedForRejection)
+ {
+ cour.end(transitions[1]);
+ continue;
+ }
+ if (cour.getActorId().equals(manager))
+ {
+ System.out.println("Manager=" + cour.getActorId() + "(" + processId + ")");
+ int randomIndex = Math.abs(random.nextInt() % 2);
+ if (randomIndex == 1)
+ {
+ //kill this task
+ markedForRejection = true;
+ cour.end(transitions[randomIndex]);
+ }
+ else
+ {
+ cour.end(transitions[randomIndex]);
+ break;
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (processInstance != null)
+ {
+ jbpmContext.save(processInstance);
+ }
+ jbpmContext.close();
+ }
+ }
+
+
+ /**
+ * @author sshah
+ */
+ private class ApprovalThread implements Runnable
+ {
+ long processId = 0;
+ String path = null;
+ boolean reject = false;
+ boolean done = false;
+
+ private ApprovalThread(long processId, String path, boolean reject)
+ {
+ this.processId = processId;
+ this.path = path;
+ this.reject = reject;
+ }
+
+ public void run()
+ {
+ try
+ {
+ String[] managers = {"Admin", "eric.brown(a)jboss.com", "sohil.shah(a)jboss.com"};
+ for (int i = 0; i < managers.length; i++)
+ {
+ executeTask(this.path, this.processId, managers[i], this.reject);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ done = true;
}
- jbpmContext.close();
}
- return processId;
}
-
- /**
- *
- * @param path
- * @param processId
- * @param manager
- * @param reject
- * @throws Exception
- */
- private void executeTask(String path,long processId,String manager,boolean reject) throws Exception
- {
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = null;
- try
- {
- // Now, we search for all process instances of this process definition.
- processInstance = jbpmContext.loadProcessInstance(processId);
-
- if(processInstance.hasEnded())
- {
- System.out.println("This process has already ended...");
- return;
- }
-
- //here act as an Admin and approve/reject one of the tasks
- Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
- String[] transitions = {"approval","rejection"};
- java.util.Random random = new java.util.Random(12343);
- boolean markedForRejection = false;
- for(Iterator itr=allTasks.iterator();itr.hasNext();)
- {
- TaskInstance cour = (TaskInstance)itr.next();
- if(markedForRejection)
- {
- cour.end(transitions[1]);
- continue;
- }
- if(cour.getActorId().equals(manager))
- {
- System.out.println("Manager="+cour.getActorId()+"("+processId+")");
- int randomIndex = Math.abs(random.nextInt()%2);
- if(randomIndex == 1)
- {
- //kill this task
- markedForRejection = true;
- cour.end(transitions[randomIndex]);
- }
- else
- {
- cour.end(transitions[randomIndex]);
- break;
- }
- }
- }
- }
- finally
- {
- if(processInstance!=null)
- {
- jbpmContext.save(processInstance);
- }
- jbpmContext.close();
- }
- }
-
-
- /**
- *
- * @author sshah
- *
- */
- private class ApprovalThread implements Runnable
- {
- long processId = 0;
- String path = null;
- boolean reject = false;
- boolean done = false;
- private ApprovalThread(long processId,String path,boolean reject)
- {
- this.processId = processId;
- this.path = path;
- this.reject = reject;
- }
-
- public void run()
- {
- try
- {
- String[] managers = {"Admin","eric.brown(a)jboss.com","sohil.shah(a)jboss.com"};
- for(int i=0;i<managers.length;i++)
- {
- executeTask(this.path,this.processId,managers[i],this.reject);
- }
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- done = true;
- }
- }
- }
}
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java 2007-01-09 13:41:06 UTC (rev 5969)
@@ -30,37 +30,36 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
/**
- *
* @author sohil.shah(a)jboss.com
- *
*/
-public class PublishAssignmentHandler implements AssignmentHandler {
+public class PublishAssignmentHandler implements AssignmentHandler
+{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- /**
- *
- */
- public void assign(Assignable assignable,ExecutionContext executionContext)
- {
- int taskInstances = 0;
- Collection assignedTasks = executionContext.getTaskMgmtInstance().getTaskInstances();
- if(assignedTasks!=null)
- {
- taskInstances = assignedTasks.size();
- }
-
- if(taskInstances == 1)
- {
- System.out.println("Assigning this task to the Managers");
- String[] managers = {"Admin","sohil.shah(a)jboss.com","eric.brown(a)jboss.com"};
- assignable.setActorId(managers[0]);
- for(int i=1;i<managers.length;i++)
- {
- TaskInstance t = executionContext.getTaskMgmtInstance().
- createTaskInstance(((TaskInstance)assignable).getTask(),executionContext);
- t.setActorId(managers[i]);
- }
- }
- }
+ /**
+ *
+ */
+ public void assign(Assignable assignable, ExecutionContext executionContext)
+ {
+ int taskInstances = 0;
+ Collection assignedTasks = executionContext.getTaskMgmtInstance().getTaskInstances();
+ if (assignedTasks != null)
+ {
+ taskInstances = assignedTasks.size();
+ }
+
+ if (taskInstances == 1)
+ {
+ System.out.println("Assigning this task to the Managers");
+ String[] managers = {"Admin", "sohil.shah(a)jboss.com", "eric.brown(a)jboss.com"};
+ assignable.setActorId(managers[0]);
+ for (int i = 1; i < managers.length; i++)
+ {
+ TaskInstance t = executionContext.getTaskMgmtInstance().
+ createTaskInstance(((TaskInstance)assignable).getTask(), executionContext);
+ t.setActorId(managers[i]);
+ }
+ }
+ }
}
Modified: trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml 2007-01-09 00:35:52 UTC (rev 5968)
+++ trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml 2007-01-09 13:41:06 UTC (rev 5969)
@@ -31,7 +31,7 @@
<xmbean/>
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<attribute name="DoChecking">true</attribute>
- <attribute name="ConfigLocation">conf/hibernate.cfg.xml</attribute>
+ <attribute name="ConfigLocation">conf/hibernate/workflow/hibernate.cfg.xml</attribute>
<attribute name="JNDIName">java:/portal/workflow/WorkFlowSessionFactory</attribute>
</mbean>
@@ -49,7 +49,7 @@
<jbpm-context>
<service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory"/>
</jbpm-context>
- <string name="resource.hibernate.cfg.xml" value="conf/hibernate.cfg.xml"/>
+ <string name="resource.hibernate.cfg.xml" value="conf/hibernate/workflow/hibernate.cfg.xml"/>
<string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties"/>
<string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties"/>
<string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties"/>
17 years, 5 months
JBoss Portal SVN: r5968 - trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-08 19:35:52 -0500 (Mon, 08 Jan 2007)
New Revision: 5968
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
Log:
- More behavioral fixes to registration handling.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-08 22:47:50 UTC (rev 5967)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-09 00:35:52 UTC (rev 5968)
@@ -157,40 +157,44 @@
registrationInfo = new RegistrationInfo(this);
}
- // check if the configured registration information is correct and if we can get the service description
- if (registrationInfo.initialize(serviceDescription, getId()))
+ // only process service description if consumer is not already registered
+ if (!registrationInfo.isRegistrationValid())
{
- try
+ // check if the configured registration information is correct and if we can get the service description
+ if (registrationInfo.initialize(serviceDescription, getId()))
{
- log.debug("Attempting registration");
- RegistrationContext registrationContext = endpointConfigurationInfo.getRegistrationService()
- .register(registrationInfo.getRegistrationData());
+ try
+ {
+ log.debug("Attempting registration");
+ RegistrationContext registrationContext = endpointConfigurationInfo.getRegistrationService()
+ .register(registrationInfo.getRegistrationData());
- if (registrationContext == null)
+ if (registrationContext == null)
+ {
+ throw new PortletInvokerException("Received null response after registration from producer '" + producerId + "'");
+ }
+
+ //todo: hook to registration subsystem correctly Registration should deal with state and
+ // it should be possible to create a RegistrationContext from a Registration
+ registrationInfo.setRegistrationContext(registrationContext);
+ log.info("Successfully registered with handle: '" + registrationContext.getRegistrationHandle() + "'");
+ }
+ catch (Exception e)
{
- throw new PortletInvokerException("Received null response after registration from producer '" + producerId + "'");
+ registrationInfo.resetRegistration();
+ throw new PortletInvokerException("Couldn't register with producer '" + producerId + "'", e);
}
- //todo: hook to registration subsystem correctly Registration should deal with state and
- // it should be possible to create a RegistrationContext from a Registration
- registrationInfo.setRegistrationContext(registrationContext);
- log.info("Successfully registered with handle: '" + registrationContext.getRegistrationHandle() + "'");
+ log.debug("Requesting service description after registration");
+ extractOfferedPortlets(getServiceDescription());
+ isInitialized = true;
}
- catch (Exception e)
+ else
{
- registrationInfo.resetRegistration();
- throw new PortletInvokerException("Couldn't register with producer '" + producerId + "'", e);
+ log.info("Consumer is not ready to be registered with producer because of missing or invalid registration information.");
+ isInitialized = false;
}
-
- log.debug("Requesting service description after registration");
- extractOfferedPortlets(getServiceDescription());
- isInitialized = true;
}
- else
- {
- log.info("Consumer is not ready to be registered with producer because of missing or invalid registration information.");
- isInitialized = false;
- }
}
else
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-01-08 22:47:50 UTC (rev 5967)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-01-09 00:35:52 UTC (rev 5968)
@@ -205,7 +205,7 @@
{
log.debug("RegistrationInfo initialization requested");
boolean configurationValid;
- if (serviceDescription.isRequiresRegistration() && !isRegistrationValid())
+ if (serviceDescription.isRequiresRegistration())
{
requiresRegistration = true;
StringBuffer message = new StringBuffer("Producer '").append(producerId).append("' requires registration.");
17 years, 5 months
JBoss Portal SVN: r5967 - trunk/wsrp/src/main/org/jboss/portal/wsrp/producer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-08 17:47:50 -0500 (Mon, 08 Jan 2007)
New Revision: 5967
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
Log:
- Avoid useless work if there aren't any registration properties.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-01-08 22:46:42 UTC (rev 5966)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-01-08 22:47:50 UTC (rev 5967)
@@ -39,6 +39,7 @@
import org.jboss.portal.wsrp.core.InvalidHandleFault;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.MarkupType;
+import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
@@ -51,6 +52,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
/**
@@ -131,6 +133,7 @@
{
// todo: find out how to cache this
ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
+ // should we be sending the registration properties description as well?
ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
serviceDescription.setRequiresInitCookie(CookieProtocol.none);
PortletDescription[] descriptions = getPortletDescriptions(desiredLocales);
@@ -163,9 +166,16 @@
offeredPortlets = getPortletDescriptions(desiredLocales);
}
+ // do not create a ModelDescription if there is no registration properties
+ Map info = requirements.getRegistrationProperties();
+ ModelDescription description = null;
+ if (info != null && !info.isEmpty())
+ {
+ description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
+ }
+
return new ServiceDescription(true, offeredPortlets, null, null, null, null, CookieProtocol.none,
- WSRPUtils.convertRegistrationPropertiesToModelDescription(requirements.getRegistrationProperties()),
- producer.getSupportedLocales(), null, null);
+ description, producer.getSupportedLocales(), null, null);
}
/**
17 years, 5 months
JBoss Portal SVN: r5966 - trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-08 17:46:42 -0500 (Mon, 08 Jan 2007)
New Revision: 5966
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
Log:
- Avoid useless work if there aren't any registration properties.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-01-08 22:46:01 UTC (rev 5965)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-01-08 22:46:42 UTC (rev 5966)
@@ -217,48 +217,51 @@
{
configurationValid = true;
PropertyDescription[] propertyDescriptions = regPropDescs.getPropertyDescriptions();
- Map descriptionsMap = getRegistrationPropertyDescriptionsFromWSRP(propertyDescriptions);
+ if (propertyDescriptions != null && propertyDescriptions.length > 0)
+ {
+ Map descriptionsMap = getRegistrationPropertyDescriptionsFromWSRP(propertyDescriptions);
- Map registrationProperties = getOrCreateRegistrationPropertiesMap(true);
+ Map registrationProperties = getOrCreateRegistrationPropertiesMap(true);
- // check that we don't have unexpected registration properties and if so, mark them as invalid
- Set unexpected = new HashSet(registrationProperties.keySet());
- Set expectedNames = descriptionsMap.keySet();
- unexpected.removeAll(expectedNames);
- if (!unexpected.isEmpty())
- {
- message = new StringBuffer("The registration for producer '"
- + producerId + "' provided values for unexpected registration properties: ");
- for (Iterator invalidProps = unexpected.iterator(); invalidProps.hasNext();)
+ // check that we don't have unexpected registration properties and if so, mark them as invalid
+ Set unexpected = new HashSet(registrationProperties.keySet());
+ Set expectedNames = descriptionsMap.keySet();
+ unexpected.removeAll(expectedNames);
+ if (!unexpected.isEmpty())
{
- String name = (String)invalidProps.next();
- message.append("\t- ").append(name).append("\n");
- ((RegistrationProperty)registrationProperties.get(name)).setInvalid(true);
+ message = new StringBuffer("The registration for producer '"
+ + producerId + "' provided values for unexpected registration properties: ");
+ for (Iterator invalidProps = unexpected.iterator(); invalidProps.hasNext();)
+ {
+ String name = (String)invalidProps.next();
+ message.append("\t- ").append(name).append("\n");
+ ((RegistrationProperty)registrationProperties.get(name)).setInvalid(true);
+ }
+ log.info(message);
+ resetRegistration();
+ configurationValid = false;
}
- log.info(message);
- resetRegistration();
- configurationValid = false;
- }
- // now check for missing properties, add the missing ones with a null value
- StringBuffer missingProps = new StringBuffer();
- for (Iterator descriptionNames = expectedNames.iterator(); descriptionNames.hasNext();)
- {
- String name = (String)descriptionNames.next();
- RegistrationProperty prop = (RegistrationProperty)registrationProperties.get(name);
- if (prop == null)
+ // now check for missing properties, add the missing ones with a null value
+ StringBuffer missingProps = new StringBuffer();
+ for (Iterator descriptionNames = expectedNames.iterator(); descriptionNames.hasNext();)
{
- Object missingProp = descriptionsMap.get(name);
- registrationProperties.put(name, missingProp);
- missingProps.append("Missing value for ").append(missingProp).append("\n");
+ String name = (String)descriptionNames.next();
+ RegistrationProperty prop = (RegistrationProperty)registrationProperties.get(name);
+ if (prop == null)
+ {
+ Object missingProp = descriptionsMap.get(name);
+ registrationProperties.put(name, missingProp);
+ missingProps.append("Missing value for ").append(missingProp).append("\n");
+ }
}
- }
- if (missingProps.length() > 0)
- {
- log.info(missingProps);
- resetRegistration();
- configurationValid = false;
+ if (missingProps.length() > 0)
+ {
+ log.info(missingProps);
+ resetRegistration();
+ configurationValid = false;
+ }
}
}
else
17 years, 5 months
JBoss Portal SVN: r5965 - trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-01-08 17:46:01 -0500 (Mon, 08 Jan 2007)
New Revision: 5965
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
Log:
- Fixed incorrect behavior in refreshIfNeeded (thanks Matt).
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-08 15:29:00 UTC (rev 5964)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-01-08 22:46:01 UTC (rev 5965)
@@ -192,25 +192,27 @@
isInitialized = false;
}
}
+ else
+ {
+ log.debug("Registration not required");
+ setRegistrationInfo(RegistrationInfo.REGISTRATION_NOT_NEEDED);
+ setServiceDescriptionRequest(getUnregisteredServiceDescriptionRequest());
+ extractOfferedPortlets(getServiceDescription());
+ isInitialized = true;
+ }
//todo: could extract more information here...
- log.debug("Registration not required");
- setRegistrationInfo(RegistrationInfo.REGISTRATION_NOT_NEEDED);
- setServiceDescriptionRequest(getUnregisteredServiceDescriptionRequest());
- extractOfferedPortlets(getServiceDescription());
- isInitialized = true;
+ if (isInitialized)
+ {
+ resetCacheTimerIfNeeded();
+ }
+ else
+ {
+ log.warn("Producer is NOT initialized.");
+ }
}
- if (isInitialized)
- {
- resetCacheTimerIfNeeded();
- }
- else
- {
- log.warn("Producer is NOT initialized.");
- }
-
return isInitialized;
}
@@ -448,26 +450,6 @@
}
}
- /**
- * @return
- * @throws PortletInvokerException
- * @since 2.6
- */
- private ServiceDescription getMinimalServiceDescription() throws PortletInvokerException
- {
- ServiceDescription serviceDescription;
- try
- {
- serviceDescription = endpointConfigurationInfo.getServiceDescriptionService().getServiceDescription(getUnregisteredServiceDescriptionRequest());
- }
- catch (Exception e)
- {
- throw new PortletInvokerException("Couldn't access service description for producer '"
- + producerId + "'", e);
- }
- return serviceDescription;
- }
-
private void setServiceDescriptionRequest(GetServiceDescription request)
{
serviceDescriptionRequest = request;
17 years, 5 months