gatein SVN: r3827 - in components/pc/trunk: federation/src/main/java/org/gatein/pc/federation/impl and 5 other directories.
by do-not-reply@jboss.org
Author: mwringe
Date: 2010-08-13 10:41:57 -0400 (Fri, 13 Aug 2010)
New Revision: 3827
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java
components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java
components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
Log:
GTNPC-26: patch to add support for import/export. Test cases included.
Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java
===================================================================
--- components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -71,7 +71,7 @@
/**
* Clone a portlet.
*
- * @param stateType the portle state type desired
+ * @param stateType the portlet state type desired
* @param portletContext the portlet context to clone @return the clone id
* @return the cloned portlet context
* @throws IllegalArgumentException if the portletId is null
@@ -125,4 +125,26 @@
* @throws PortletInvokerException a portlet invoker exception
*/
PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException;
+
+ /**
+ * Exports a portlet from the invoker which can be used to recreate this portlet during an import portlet operation
+ * The returned portlet Id will be the portlet Id of the base portlet, not a cloned portlet Id
+ * If the portlet contains state, it will be returned regardless if the portlet invoker is set to persist state locally.
+ *
+ * @param stateType the portlet state type desired
+ * @param originalPortletContext the context of the porlet to be exported
+ * @return A new portlet context which can be used to import a portlet
+ * @throws PortletInvokerException
+ */
+ PortletContext exportPortlet(PortletStateType stateType, PortletContext originalPortletContext) throws PortletInvokerException;
+
+ /**
+ * Imports a portlet into the invoker.
+ *
+ * @param stateType the portlet state type desired
+ * @param contextToImport the context to be imported
+ * @return The portletcontext for the imported portlet
+ * @throws PortletInvokerException
+ */
+ PortletContext importPortlet(PortletStateType stateType, PortletContext contextToImport) throws PortletInvokerException;
}
Modified: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -219,6 +219,21 @@
}
+ public PortletContext exportPortlet(PortletStateType stateType, PortletContext compoundPortletContext)
+ throws PortletInvokerException
+ {
+ PortletContext portletContext = dereference(compoundPortletContext);
+ portletContext = portletInvoker.exportPortlet(stateType, portletContext);
+ return reference(portletContext);
+ }
+
+ public PortletContext importPortlet(PortletStateType stateType, PortletContext compoundPortletContext) throws PortletInvokerException
+ {
+ PortletContext portletContext = dereference(compoundPortletContext);
+ portletContext = portletInvoker.exportPortlet(stateType, portletContext);
+ return reference(portletContext);
+ }
+
private PortletContext dereference(PortletContext compoundPortletContext)
{
String portletId = compoundPortletContext.getId().substring(id.length() + 1);
Modified: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -231,6 +231,20 @@
return federated.setProperties(compoundPortletContext, changes);
}
+ public PortletContext exportPortlet(PortletStateType stateType, PortletContext compoundPortletContext)
+ throws PortletInvokerException
+ {
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.exportPortlet(stateType, compoundPortletContext);
+ }
+
+ public PortletContext importPortlet(PortletStateType stateType, PortletContext compoundPortletContext)
+ throws PortletInvokerException
+ {
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.importPortlet(stateType, compoundPortletContext);
+ }
+
public synchronized void setNullInvokerHandler(NullInvokerHandler nullHandler)
{
if (nullHandler == null)
Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -32,7 +32,9 @@
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.portlet.state.StateConversionException;
+import java.io.Serializable;
import java.util.Set;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -131,4 +133,16 @@
//
return next;
}
+
+ public PortletContext exportPortlet(PortletStateType stateType, PortletContext originalPortletContext)
+ throws PortletInvokerException, IllegalArgumentException
+ {
+ return safeGetNext().exportPortlet(stateType, originalPortletContext);
+ }
+
+ public PortletContext importPortlet(PortletStateType stateType, PortletContext originalPortletContext)
+ throws PortletInvokerException, IllegalArgumentException
+ {
+ return safeGetNext().importPortlet(stateType, originalPortletContext);
+ }
}
Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -225,6 +225,36 @@
}
}
+ public PortletContext importPortlet(PortletStateType stateType,
+ PortletContext portletContext) throws PortletInvokerException, IllegalArgumentException
+ {
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
+
+ PortletContext importContext = super.importPortlet(stateType, consumerContext.producerPortletContext);
+
+ if (importContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext statefulimportContext = (StatefulPortletContext)importContext;
+ ConsumerState consumerState = new ConsumerState<Serializable>(importContext.getId(), statefulimportContext.getType(), statefulimportContext.getState());
+ String id = persistenceManager.createState(consumerState);
+ return PortletContext.createPortletContext(CLONE_ID_PREFIX + id);
+ }
+ else
+ {
+ return importContext;
+ }
+
+ }
+
+ public PortletContext exportPortlet(PortletStateType stateType,
+ PortletContext portletContext) throws PortletInvokerException, IllegalArgumentException
+ {
+ ConsumerContext consumerContext = getConsumerContext(portletContext);
+
+ //
+ return super.exportPortlet(stateType, consumerContext.producerPortletContext);
+ }
+
public List<DestroyCloneFailure> destroyClones(List<PortletContext> portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
if (portletContexts == null)
Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -630,6 +630,104 @@
}
}
+ public PortletContext exportPortlet(PortletStateType stateType, PortletContext originalPortletContext) throws PortletInvokerException, IllegalArgumentException
+ {
+ if (originalPortletContext == null)
+ {
+ throw new IllegalArgumentException("No null portlet context accepted");
+ }
+
+ //
+ InternalContext context = getStateContext(originalPortletContext);
+ String portletId = context.getPortletId();
+
+ //
+ boolean persistLocally = stateManagementPolicy.persistLocally();
+
+ //
+ if (context.isStateful())
+ {
+ StatefulContext statefulContext = (StatefulContext)context;
+ try
+ {
+ PortletState sstate = new PortletState(portletId, statefulContext.getProperties());
+ Serializable marshalledState = stateConverter.marshall(stateType, sstate);
+ return StatefulPortletContext.create(portletId, stateType, marshalledState);
+ }
+ catch (StateConversionException e)
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+ else
+ {
+ if (persistLocally)
+ {
+ PropertyMap newState = new SimplePropertyMap();
+ getPropertiesFromMetaData(originalPortletContext, newState);
+ try
+ {
+ PortletState sstate = new PortletState(portletId, newState);
+ Serializable marshalledState = stateConverter.marshall(stateType, sstate);
+ return StatefulPortletContext.create(portletId, stateType, marshalledState);
+ }
+ catch (StateConversionException e)
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+ else
+ {
+ // if we don't have a state associated with this portlet context and we don't persistLocally then there is nothing to
+ // store here and we need to just return the value we were given.
+ //return context.getPortletContext();
+ return getPortlet(originalPortletContext).getContext();//originalPortletContext;
+ }
+ }
+ }
+
+ public PortletContext importPortlet(PortletStateType stateType, PortletContext contextToImport) throws PortletInvokerException
+ {
+ if (contextToImport == null)
+ {
+ throw new IllegalArgumentException("No null portlet id accepted");
+ }
+
+ try
+ {
+ if (contextToImport instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext statefulPortletContext = (StatefulPortletContext) contextToImport;
+ Boolean persistLocally = stateManagementPolicy.persistLocally();
+
+ PortletState portletState = getStateConverter().unmarshall(stateType, statefulPortletContext.getState());
+ //
+ if (persistLocally)
+ {
+ // Create the new state
+
+ String cloneStateId = persistenceManager.createState(statefulPortletContext.getId(), portletState.getProperties());
+
+ // Return the clone context
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + cloneStateId;
+ return PortletContext.createPortletContext(cloneId);
+ }
+ else
+ {
+ return marshall(statefulPortletContext.getType(), statefulPortletContext.getId(), portletState.getProperties());
+ }
+ }
+ else
+ {
+ return getPortlet(contextToImport).getContext();
+ }
+ }
+ catch (StateConversionException e)
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+
private <S extends Serializable> PortletContext marshall(PortletStateType<S> stateType, String portletId, PropertyMap props) throws PortletInvokerException
{
try
Modified: components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java
===================================================================
--- components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -212,4 +212,16 @@
{
throw new UnsupportedOperationException();
}
+
+ public PortletContext exportPortlet(PortletStateType stateType,
+ PortletContext originalPortletContext) throws PortletInvokerException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletContext importPortlet(PortletStateType stateType,
+ PortletContext originalPortletContext) throws PortletInvokerException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
}
Modified: components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
===================================================================
--- components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -29,8 +29,10 @@
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.StatefulPortletContext;
import org.gatein.pc.api.state.PropertyMap;
+import org.gatein.pc.portlet.impl.state.StateConverterV0;
import org.gatein.pc.portlet.support.info.PortletInfoSupport;
import org.gatein.pc.portlet.support.PortletSupport;
import org.gatein.pc.api.info.MetaInfo;
@@ -38,11 +40,13 @@
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
import org.gatein.pc.portlet.state.AbstractPropertyContext;
+import org.gatein.pc.portlet.state.StateConverter;
import org.gatein.pc.api.state.AccessMode;
import org.gatein.pc.api.state.DestroyCloneFailure;
import org.gatein.pc.api.state.PropertyChange;
import org.gatein.pc.api.state.PropertyContext;
import org.gatein.pc.portlet.state.SimplePropertyMap;
+import org.gatein.pc.portlet.state.producer.PortletState;
import static org.jboss.unit.api.Assert.*;
import org.jboss.unit.api.pojo.annotations.Test;
@@ -168,6 +172,17 @@
*
*/
protected abstract void addPreference(PortletContext popRef, String key, List<String> defaultValue, Boolean readOnly);
+
+ /**
+ *
+ */
+ protected abstract PortletContext exportPortletContext(PortletContext contextToImport) throws PortletInvokerException;
+
+ /**
+ *
+ */
+ protected abstract PortletContext importPortletContext(PortletContext contextToImport) throws PortletInvokerException;
+
/**
*
@@ -958,4 +973,240 @@
}
}
}
+
+ @Test
+ public void testExportNullPortletContext() throws Exception
+ {
+ try
+ {
+ exportPortletContext(null);
+ fail("Was expecting an illegal arguement exception.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ //expected
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testExportsNonExisitngPOP() throws Exception
+ {
+ PortletContext popCTX = createNonExistingPOPRef();
+ try
+ {
+ exportPortletContext(popCTX);
+ fail("Was expecting a NoSuchPortletException.");
+ }
+ catch (NoSuchPortletException e)
+ {
+ //expected
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testExportNonExisitngCCP() throws Exception
+ {
+ PortletContext ccpCTX = createNonExistingLocalCCPRef();
+ try
+ {
+ exportPortletContext(ccpCTX);
+ fail("Was expecting a NoSuchPortletException.");
+ }
+ catch (NoSuchPortletException e)
+ {
+ //expected
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testExportInvalidPOP() throws Exception
+ {
+ PortletContext popCtx = createInvalidPOPRef();
+ try
+ {
+ exportPortletContext(popCtx);
+ fail("was expecting an InvalidPortletIdException");
+ }
+ catch (InvalidPortletIdException expected)
+ {
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testExportPortlet() throws Exception
+ {
+ PropertyMap expectedProperties = new SimplePropertyMap();
+ expectedProperties.setProperty("abc", Arrays.asList("def"));
+
+ PortletInfoSupport info = new PortletInfoSupport();
+ info.getMeta().setDisplayName("MyPortlet");
+ PortletContext popCtx = createPOPRef(info);
+
+ PortletContext export0Ctx = exportPortletContext(popCtx);
+
+ //Make sure we get back the ID for the original portlet
+ assertEquals("PortletId", export0Ctx.getId());
+ //check by doing an import
+ checkWithImportPortlet(export0Ctx, popCtx, new SimplePropertyMap());
+
+
+ //add a preference to the portlet to make it store a state
+ addPreference(popCtx, "abc", Arrays.asList("def"));
+ PortletContext export1Ctx = exportPortletContext(popCtx);
+
+ //Make sure we get back the ID for the original portlet
+ assertEquals("PortletId", export1Ctx.getId());
+ //check by doing an import
+ checkWithImportPortlet(export1Ctx, popCtx, expectedProperties);
+
+ PortletContext ccp1Ctx = createClone(popCtx);
+ PortletContext export2Ctx = exportPortletContext(ccp1Ctx);
+
+ //Make sure we get back the ID for the original portlet
+ assertEquals("PortletId", export2Ctx.getId());
+ //Check by doing an import
+ checkWithImportPortlet(export2Ctx, ccp1Ctx, expectedProperties);
+
+ PortletContext ccp2Ctx = createClone(ccp1Ctx);
+ //make sure that adding a property to the already cloned ccp1Ctx doesn't interfere with exports
+ PropertyChange[] propertyChanges = new PropertyChange[1];
+ propertyChanges[0] = PropertyChange.newUpdate("123", Arrays.asList("456"));
+ ccp1Ctx = setProperties(ccp1Ctx, propertyChanges);
+ assertTrue(getProperties(ccp1Ctx).containsKey("123"));
+ assertFalse(getProperties(export2Ctx).containsKey("123"));
+
+ PortletContext export3Ctx = exportPortletContext(ccp2Ctx);
+
+ //Make sure we get back the ID for the original portlet
+ assertEquals("PortletId", export3Ctx.getId());
+ //Check by doing an import
+ checkWithImportPortlet(export3Ctx, ccp2Ctx, expectedProperties);
+ }
+
+ protected void checkWithImportPortlet(PortletContext exportedPortletContext, PortletContext originalPortletContext, PropertyMap expectedProperties) throws Exception
+ {
+ PortletContext importedPortletContext = importPortletContext(exportedPortletContext);
+
+ Portlet importedPortlet = getPortlet(importedPortletContext);
+
+ PortletContext portletContext = importedPortlet.getContext();
+
+ //make sure the expected portlet context and the one we get back from the import are the same
+ assertEquals(originalPortletContext.getApplicationName(), portletContext.getApplicationName());
+ assertEquals(originalPortletContext.getPortletName(), portletContext.getPortletName());
+
+ if (originalPortletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext statefulExpected = (StatefulPortletContext)originalPortletContext;
+
+ assertTrue(portletContext instanceof StatefulPortletContext);
+ StatefulPortletContext statefulPortletContext = (StatefulPortletContext)portletContext;
+
+ //Check that the states are the same
+ StateConverter sc = new StateConverterV0();
+ PortletState state = sc.unmarshall(PortletStateType.OPAQUE, (byte[])statefulPortletContext.getState());
+ PortletState expectedState = sc.unmarshall(PortletStateType.OPAQUE, (byte[])statefulExpected.getState());
+
+ assertEquals(expectedState.getPortletId(), state.getPortletId());
+ assertEquals(expectedState.getProperties(), state.getProperties());
+ assertEquals(expectedState.getTerminationTime(), state.getTerminationTime());
+ assertEquals(expectedState.getClass(), state.getClass());
+ }
+
+ PropertyMap properties = getProperties(portletContext);
+ assertEquals(expectedProperties, properties);
+ assertEquals(getProperties(originalPortletContext), properties);
+
+ }
+
+ @Test
+ public void testImportNullPortletContext() throws Exception
+ {
+ try
+ {
+ importPortletContext(null);
+ fail("Was expecting an illegal arguement exception.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ //expected
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testImportsNonExisitngPOP() throws Exception
+ {
+ PortletContext popCTX = createNonExistingPOPRef();
+ try
+ {
+ importPortletContext(popCTX);
+ fail("Was expecting a NoSuchPortletException.");
+ }
+ catch (NoSuchPortletException e)
+ {
+ //expected
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testImportNonExisitngCCP() throws Exception
+ {
+ PortletContext ccpCTX = createNonExistingLocalCCPRef();
+ try
+ {
+ importPortletContext(ccpCTX);
+ fail("Was expecting a NoSuchPortletException.");
+ }
+ catch (NoSuchPortletException e)
+ {
+ //expected
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testImportInvalidPOP() throws Exception
+ {
+ PortletContext popCtx = createInvalidPOPRef();
+ try
+ {
+ importPortletContext(popCtx);
+ fail("was expecting an InvalidPortletIdException");
+ }
+ catch (InvalidPortletIdException expected)
+ {
+ }
+ assertNoExistingState();
+ }
+
+ @Test
+ public void testImport() throws Exception
+ {
+ //This will create the portlet into the container and check that it doesn't have any properties set
+ PortletContext popCtx = createPOPRef(new PortletInfoSupport());
+ assertTrue(getProperties(popCtx).isEmpty());
+
+ //Create the state bytes manually and create the portletcontext.
+ //Tests what happens if a stateful portlet is export on one machine and imported into another
+ StateConverter sc = new StateConverterV0();
+ PropertyMap propertyMap = new SimplePropertyMap();
+ propertyMap.setProperty("test", Arrays.asList("123"));
+ PortletState portletState = new PortletState("PortletId", propertyMap);
+ byte[] stateBytes = sc.marshall(PortletStateType.OPAQUE, portletState);
+
+ StatefulPortletContext portletContext = StatefulPortletContext.create("PortletId", PortletStateType.OPAQUE, stateBytes);
+
+ //import portlet
+ PortletContext importedPortletContext = importPortletContext(portletContext);
+
+ //Make sure that this new portlet has the properties we want
+ assertEquals(propertyMap, getProperties(importedPortletContext));
+ }
+
}
Modified: components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
===================================================================
--- components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -252,4 +252,14 @@
assertEquals(1, portlets.size());
return (Portlet)portlets.iterator().next();
}
+
+ protected PortletContext importPortletContext(PortletContext contextToImport) throws PortletInvokerException
+ {
+ return consumer.importPortlet(PortletStateType.OPAQUE, contextToImport);
+ }
+
+ protected PortletContext exportPortletContext(PortletContext originalPortletContext) throws PortletInvokerException
+ {
+ return consumer.exportPortlet(PortletStateType.OPAQUE, originalPortletContext);
+ }
}
Modified: components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
--- components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2010-08-13 13:24:00 UTC (rev 3826)
+++ components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2010-08-13 14:41:57 UTC (rev 3827)
@@ -237,4 +237,14 @@
assertEquals(1, portlets.size());
return (Portlet)portlets.iterator().next();
}
+
+ protected PortletContext importPortletContext(PortletContext contextToImport) throws PortletInvokerException
+ {
+ return producer.importPortlet(PortletStateType.OPAQUE, contextToImport);
+ }
+
+ protected PortletContext exportPortletContext(PortletContext originalPortletContext) throws PortletInvokerException
+ {
+ return producer.exportPortlet(PortletStateType.OPAQUE, originalPortletContext);
+ }
}
14 years, 5 months
gatein SVN: r3826 - in exo/portal/branches/3.1.x: component/resources/src/main/java/org/exoplatform/services/resources and 6 other directories.
by do-not-reply@jboss.org
Author: trong.tran
Date: 2010-08-13 09:24:00 -0400 (Fri, 13 Aug 2010)
New Revision: 3826
Modified:
exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
exo/portal/branches/3.1.x/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
Revert last committes that would be done in next version
Modified: exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
===================================================================
--- exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -26,7 +26,6 @@
import org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
-import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.ValueParam;
@@ -261,9 +260,7 @@
public boolean isGadgetDeveloper(String username)
{
- if(PropertyManager.isDevelopping())
- return true;
- return false;
+ return true;
}
public String getCountry()
Modified: exo/portal/branches/3.1.x/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
===================================================================
--- exo/portal/branches/3.1.x/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -20,10 +20,14 @@
package org.exoplatform.services.resources;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.ListResourceBundle;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* May 7, 2004
@@ -74,7 +78,7 @@
String key = keys.nextElement();
if (key != null)
{
- map.put(key.trim(), getString(key));
+ map.put(key, getString(key));
}
}
}
Modified: exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
===================================================================
--- exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-08-13 13:24:00 UTC (rev 3826)
@@ -83,20 +83,16 @@
}
}
-RssAggregator.prototype.renderFeed = function(feedObj) {
- if(feedObj.rc != 200 && feedObj.data == undefined) {
- document.write("the url: " + feedurl + " is down or invalid");
- return;
- }
- this.feed = feedObj.data;
- gadgets.window.setTitle("RSS: " + this.feed.Title);
+RssAggregator.prototype.renderFeed = function(feed) {
+ this.feed = feed;
+ gadgets.window.setTitle("RSS: " + feed.Title);
var feedEl = _gel("feedContainer");
var bullet = "<img src='" + this.getFavicon(feedurl) + "' alt='' border=0 align='absmiddle' style='height:16;width:16;' onerror='this.style.visibility=\"hidden\";'> ";
- if (this.feed != null) {
+ if (feed != null) {
// Access the data for a given entry
- if (this.feed.Entry) {
- for (var i = 0; i < this.feed.Entry.length; i++) {
+ if (feed.Entry) {
+ for (var i = 0; i < feed.Entry.length; i++) {
var itemEl = document.createElement('div');
var item_title = document.createElement('div');
var item_more = document.createElement('div');
@@ -120,10 +116,10 @@
item_date.className = 'date';
item_link.className = 'link';
- item_title.innerHTML = bullet + "<a id='link_title_"+i+"' class='titlelink' href='" + this.feed.Entry[i].Link + "' onclick='rssAggregator.toggleDescription("+i+");return false;'>" + this.feed.Entry[i].Title + "</a>";
- item_date.innerHTML = this.timeToPrettyString(this.feed.Entry[i].Date);
+ item_title.innerHTML = bullet + "<a id='link_title_"+i+"' class='titlelink' href='" + feed.Entry[i].Link + "' onclick='rssAggregator.toggleDescription("+i+");return false;'>" + feed.Entry[i].Title + "</a>";
+ item_date.innerHTML = this.timeToPrettyString(feed.Entry[i].Date);
- item_desc.innerHTML = this.feed.Entry[i].Summary;
+ item_desc.innerHTML = feed.Entry[i].Summary;
item_link.innerHTML = this.generateLinkContent(i);
@@ -150,10 +146,6 @@
}
RssAggregator.prototype.refreshFeed = function() {
- var params = {};
- params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.FEED;
- params[gadgets.io.RequestParameters.NUM_ENTRIES] = entries;
- params[gadgets.io.RequestParameters.GET_SUMMARIES] = true;
- gadgets.io.makeRequest(prefs.getString("rssurl"), function(feedObj) {rssAggregator.renderFeed(feedObj);}, params);
+ _IG_FetchFeedAsJSON(prefs.getString("rssurl"), function(feed) {rssAggregator.renderFeed(feed);}, entries, true);
}
Modified: exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
===================================================================
--- exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -313,38 +313,17 @@
public String getDisplayName()
{
- try
- {
- return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
- }
- catch (Exception ex)
- {
- return "COULD NOT GET DISPLAY NAME OF THE PORTLET";
- }
+ return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
}
public String getDescription()
{
- try
- {
- return getMetaValue(MetaInfo.DESCRIPTION, name_);
- }
- catch (Exception ex)
- {
- return "COULD NOT GET DESCRIPTION OF THE PORTLET";
- }
+ return getMetaValue(MetaInfo.DESCRIPTION, name_);
}
public PreferencesInfo getPortletPreferences()
{
- try
- {
- return portletInfo_.getPreferences();
- }
- catch (Exception ex)
- {
- return null;
- }
+ return portletInfo_.getPreferences();
}
private String getMetaValue(String metaKey, String defaultValue)
Modified: exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
--- exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-08-13 13:24:00 UTC (rev 3826)
@@ -32,10 +32,6 @@
*/
PortalDragDrop.prototype.init = function(e) {
- if (eXo.core.DragDrop.dndEvent && eXo.core.DragDrop.dndEvent.clickObject == this){
- return;
- }
-
if (!e) e = window.event;
if(((e.which) && (e.which == 2 || e.which == 3)) || ((e.button) && (e.button == 2))) return;
@@ -198,9 +194,7 @@
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode != 27)) {
- if (dndEvent.foundTargetObject.foundIndex != null) {
- eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
- }
+ eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
} else {
if(dndEvent.dragObject.parentNode.nodeName.toLowerCase() == "td") {
dndEvent.dragObject.parentNode.style.width = "auto";
@@ -226,6 +220,12 @@
dndEvent.dragObject.style.width = "auto" ;
};
+ DragDrop.cancelCallback = function(dndEvent) {
+ if(Browser.browserType == "ie" && Browser.findMouseYInClient(dndEvent.backupMouseEvent) < 0) {
+ DragDrop.onDrop(dndEvent.backupMouseEvent);
+ }
+ };
+
var clickObject = this;
var componentBlock = DOMUtil.findAncestorByClass(clickObject, "UIComponentBlock") ;
@@ -284,7 +284,7 @@
] ;
try {
- dndEvent.lastFoundTargetObject.foundIndex = null;
+ dndEvent.lastFoundTargetObject.foundIndex = -1;
} catch(err) {
}
Modified: exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
===================================================================
--- exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2010-08-13 13:24:00 UTC (rev 3826)
@@ -98,56 +98,6 @@
}
newLayer.parentNode.style.top = -height + "px";
editBlock.style.display = "block";
-
- //resize width of portlet/container control if IE + LTR align BEGIN
-
- var uiInfoBar = DOMUtil.findFirstDescendantByClass(editBlock, "div", "UIInfoBar");
-
- if( uiInfoBar && (eXo.core.Browser.isIE6() || (eXo.core.Browser.isIE7() && eXo.core.I18n.isRT()))){
- //resize width of portlet/container only one time
- if(uiInfoBar.style.width == ""){
- var dragControlArea = DOMUtil.findFirstDescendantByClass(uiInfoBar, "div", "DragControlArea");
-
- var portletIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "div", "PortletIcon");
- var editPortletPropertiesIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "a", "EditPortletPropertiesIcon");
- var deletePortletIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "a", "DeletePortletIcon");
-
- var contarnerIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "div", "ContainerIcon");
- var editContainerIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "a", "EditContainerIcon");
- var deleteContainerIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "a", "DeleteContainerIcon");
-
- var uiInfoBarWidth = dragControlArea.offsetWidth;
-
- if(DOMUtil.hasClass(portlet, "UIPortlet")){
- uiInfoBarWidth += portletIcon.offsetWidth;
-
- if(editPortletPropertiesIcon){
- uiInfoBarWidth += editPortletPropertiesIcon.offsetWidth;
- }
-
- if(deletePortletIcon){
- uiInfoBarWidth += deletePortletIcon.offsetWidth;
- }
- }
-
- if(DOMUtil.hasClass(portlet, "UIContainer")){
- uiInfoBarWidth += contarnerIcon.offsetWidth
-
- if(editContainerIcon){
- uiInfoBarWidth += editContainerIcon.offsetWidth;
- }
-
- if(deleteContainerIcon){
- uiInfoBarWidth += deleteContainerIcon.offsetWidth;
- }
- }
-
- uiInfoBar.style.width= uiInfoBarWidth + 35 + "px";
- }
-
- }
- //resize width of portlet/container control if IE + LTR align END
-
} else {
editBlock.style.display = "none";
if(!DOMUtil.hasClass(portlet, "UIPortlet")) {
Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-08-13 13:24:00 UTC (rev 3826)
@@ -37,14 +37,12 @@
<div class="FixHeight">
<%
if(hasPermission) {
- if(portletTitle == null || portletTitle.trim().length() < 1) {
- try {
- String portletName = uicomponent.getProducedOfferedPortlet().getInfo().getName();
- print _ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description." + portletName);
- } catch(Exception e){
- print uicomponent.getDisplayName();
- }
- } else print portletTitle;
+ try {
+ String portletName = uicomponent.getProducedOfferedPortlet().getInfo().getName();
+ print _ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description." + portletName);
+ } catch(Exception e){
+ print uicomponent.getDisplayName();
+ }
} else print "<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>";
%>
</div>
@@ -62,12 +60,10 @@
if(portalMode != uiPortalApp.CONTAINER_BLOCK_EDIT_MODE && portalMode != uiPortalApp.APP_BLOCK_EDIT_MODE) {
if(uicomponent.getShowInfoBar()) {
- String title = portletTitle;
- if(title == null || title.trim().length() < 1)
- title = uicomponent.getTitle();
- if(title == null || title.trim().length() < 1)
+ String title = uicomponent.getTitle();
+ if(title == null || title.trim().length() < 1)
title = uicomponent.getDisplayName();
- if(title == null || title.trim().length() < 1)
+ if(title == null || title.trim().length() < 1)
title = portletId;
/*Begin Window Portlet Bar*/
String visibility = "visible";
@@ -292,9 +288,7 @@
String portletIcon = uicomponent.getIcon();
if(portletIcon == null) portletIcon = "PortletIcon";
- String title = portletTitle;
- if(title == null || title.trim().length() < 1)
- title = uicomponent.getDisplayTitle();
+ String title = uicomponent.getDisplayTitle();
if(title.length() > 30) title = title.substring(0,27) + "...";
%>
<div class="PortletIcon $portletIcon"><%=hasPermission ? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
Modified: exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
===================================================================
--- exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -73,16 +73,17 @@
{
// Specify whether or not date/time parsing is to be lenient.
sdf.setLenient(false);
- sdf.parse(s);
+ Date stDate = sdf.parse(s);
+ s = stFormat.format(stDate);
}
catch (Exception e)
{
- throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args, ApplicationMessage.WARNING));
+ throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
}
if (s.matches(DATETIME_REGEX) && isValidDateTime(s))
return;
- throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args, ApplicationMessage.WARNING));
+ throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
}
private boolean isValidDateTime(String dateTime)
Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -199,7 +199,7 @@
}
Mode mode = renderURL.getMode();
- if (mode != null)
+ if (mode != null && !mode.equals(Mode.VIEW))
{
appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
}
Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -21,7 +21,6 @@
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.ApplicationState;
@@ -313,24 +312,50 @@
public boolean isNoCache()
{
- if(PropertyManager.isDevelopping())
- return true;
- return false;
+ /*
+ * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
+ * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
+ * null) { String prefs = userGadgetStorage.get(username,
+ * getApplicationName(), getApplicationInstanceUniqueId(), PREF_NO_CACHE);
+ * return prefs.equals("1"); } } catch (Exception e) {} return false;
+ */
+ return true;
}
public void setNoCache(boolean value)
{
+ /*
+ * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
+ * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
+ * null && getGadgetRegistryService().isGadgetDeveloper(username)) {
+ * userGadgetStorage.save(username, getApplicationName(),
+ * getApplicationInstanceUniqueId(), PREF_NO_CACHE, value ? "1" : "0"); } }
+ * catch (Exception e) {}
+ */
}
public boolean isDebug()
{
- if(PropertyManager.isDevelopping())
- return true;
- return false;
+ /*
+ * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
+ * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
+ * null) { String prefs = userGadgetStorage.get(username,
+ * getApplicationName(), getApplicationInstanceUniqueId(), PREF_DEBUG);
+ * return prefs.equals("1"); } } catch (Exception e) {} return false;
+ */
+ return true;
}
public void setDebug(boolean value)
{
+ /*
+ * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
+ * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
+ * null && getGadgetRegistryService().isGadgetDeveloper(username)) {
+ * userGadgetStorage.save(username, getApplicationName(),
+ * getApplicationInstanceUniqueId(), PREF_DEBUG, value ? "1" : "0"); } }
+ * catch (Exception e) {}
+ */
}
public boolean isGadgetDeveloper()
@@ -366,7 +391,11 @@
public void addUserPref(String addedUserPref) throws Exception
{
DataStorage service = getApplicationComponent(DataStorage.class);
- org.exoplatform.portal.pom.spi.gadget.Gadget gadget = new org.exoplatform.portal.pom.spi.gadget.Gadget();
+ org.exoplatform.portal.pom.spi.gadget.Gadget gadget = service.load(state, ApplicationType.GADGET);
+ if (gadget == null)
+ {
+ gadget = new org.exoplatform.portal.pom.spi.gadget.Gadget();
+ }
//
gadget.addUserPref(addedUserPref);
Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-08-13 12:43:07 UTC (rev 3825)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-08-13 13:24:00 UTC (rev 3826)
@@ -325,6 +325,12 @@
}
//
+ if (portletTitle == null)
+ {
+ portletTitle = "Portlet";
+ }
+
+ //
if (context.useAjax() && !prcontext.getFullRender())
{
if (markup != null)
14 years, 5 months
gatein SVN: r3825 - in portal/branches/portalsecurity/portal: src/main/java and 6 other directories.
by do-not-reply@jboss.org
Author: sohil.shah(a)jboss.com
Date: 2010-08-13 08:43:07 -0400 (Fri, 13 Aug 2010)
New Revision: 3825
Added:
portal/branches/portalsecurity/portal/src/main/java/META-INF/
portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component-mustmatchall.properties
portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component.properties
Modified:
portal/branches/portalsecurity/portal/pom.xml
portal/branches/portalsecurity/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java
portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java
portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java
portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/plugin/AbstractSecurityTest.java
portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java
Log:
testsuite integration with rule based UserACL
Modified: portal/branches/portalsecurity/portal/pom.xml
===================================================================
--- portal/branches/portalsecurity/portal/pom.xml 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/pom.xml 2010-08-13 12:43:07 UTC (rev 3825)
@@ -161,7 +161,6 @@
</execution>
</executions>
</plugin>
-
</plugins>
</build>
</project>
Added: portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component-mustmatchall.properties
===================================================================
--- portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component-mustmatchall.properties (rev 0)
+++ portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component-mustmatchall.properties 2010-08-13 12:43:07 UTC (rev 3825)
@@ -0,0 +1,71 @@
+import java.util.Set
+import java.util.HashSet
+
+function boolean <function>(Set userRoles)
+{
+ String[] allowedRoles = new String[]{<roleList>};
+
+ for(Object local: userRoles)
+ {
+ String userRole = (String)local;
+ String[] userSplit = userRole.split(":");
+ String userMembershipType = null;
+ String userGroup = null;
+ if(userSplit.length < 2)
+ {
+ userMembershipType = "*";
+ userGroup = userRole;
+ }
+ else
+ {
+ userMembershipType = userSplit[0].trim();
+ userGroup = userSplit[1].trim();
+ }
+
+ for(String allowedRole: allowedRoles)
+ {
+ String[] allowedSplit = allowedRole.split(":");
+ String allowedMembershipType = null;
+ String allowedGroup = null;
+ if(allowedSplit.length < 2)
+ {
+ allowedMembershipType = "*";
+ allowedGroup = allowedRole;
+ }
+ else
+ {
+ allowedMembershipType = allowedSplit[0].trim();
+ allowedGroup = allowedSplit[1].trim();
+ }
+
+ if(userMembershipType.equals("*") || allowedMembershipType.equals("*"))
+ {
+ if(!userGroup.equals(allowedGroup))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if(!userMembershipType.equals(allowedMembershipType) || !userGroup.equals(allowedGroup))
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+rule "<ruleReference>"
+
+when
+$ruleName: String()
+$roles: HashSet()
+eval($ruleName.contains("<ruleReference>"))
+eval(<function>($roles))
+
+then
+insert(Boolean.TRUE);
+end
\ No newline at end of file
Added: portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component.properties
===================================================================
--- portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component.properties (rev 0)
+++ portal/branches/portalsecurity/portal/src/main/java/META-INF/exo-roles-component.properties 2010-08-13 12:43:07 UTC (rev 3825)
@@ -0,0 +1,71 @@
+import java.util.Set
+import java.util.HashSet
+
+function boolean <function>(Set userRoles)
+{
+ String[] allowedRoles = new String[]{<roleList>};
+
+ for(Object local: userRoles)
+ {
+ String userRole = (String)local;
+ String[] userSplit = userRole.split(":");
+ String userMembershipType = null;
+ String userGroup = null;
+ if(userSplit.length < 2)
+ {
+ userMembershipType = "*";
+ userGroup = userRole;
+ }
+ else
+ {
+ userMembershipType = userSplit[0].trim();
+ userGroup = userSplit[1].trim();
+ }
+
+ for(String allowedRole: allowedRoles)
+ {
+ String[] allowedSplit = allowedRole.split(":");
+ String allowedMembershipType = null;
+ String allowedGroup = null;
+ if(allowedSplit.length < 2)
+ {
+ allowedMembershipType = "*";
+ allowedGroup = allowedRole;
+ }
+ else
+ {
+ allowedMembershipType = allowedSplit[0].trim();
+ allowedGroup = allowedSplit[1].trim();
+ }
+
+ if(userMembershipType.equals("*") || allowedMembershipType.equals("*"))
+ {
+ if(userGroup.equals(allowedGroup))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if(userMembershipType.equals(allowedMembershipType) && userGroup.equals(allowedGroup))
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+rule "<ruleReference>"
+
+when
+$ruleName: String()
+$roles: HashSet()
+eval($ruleName.contains("<ruleReference>"))
+eval(<function>($roles))
+
+then
+insert(Boolean.TRUE);
+end
\ No newline at end of file
Modified: portal/branches/portalsecurity/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
===================================================================
--- portal/branches/portalsecurity/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2010-08-13 12:43:07 UTC (rev 3825)
@@ -25,13 +25,17 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.config.security.plugin.JBossSecurityPlugin;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.security.Identity;
import org.exoplatform.services.security.MembershipEntry;
+import org.exoplatform.portal.config.security.plugin.JBossSecurityPlugin;
+import org.exoplatform.portal.config.security.plugin.ExoEnforcementPoint;
+import org.exoplatform.portal.config.security.plugin.ExoPolicyProvisioner;
+import org.jboss.security.authz.agent.enforcement.EnforcementException;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -157,9 +161,31 @@
portalCreatorGroups_ = defragmentPermission(allGroups);
//Start the Authz Security service
- //this.securityPlugin = new JBossSecurityPlugin();
- //this.securityPlugin.start();
+ this.securityPlugin = new JBossSecurityPlugin();
+ this.securityPlugin.start();
+
+ //bootstrap policy provisioning
+ ExoPolicyProvisioner policyProvisioner = this.securityPlugin.getExoPolicyProvisioner();
+ policyProvisioner.setSuperuser(this.superUser_);
+ policyProvisioner.setGuestGroup(this.guestGroup_);
+ if(this.navigationCreatorMembershipType_ != null && this.navigationCreatorMembershipType_.trim().length() >0)
+ {
+ policyProvisioner.setNavigationCreatorMembershipType(this.navigationCreatorMembershipType_);
+ }
+ if(this.portalCreatorGroups_ != null && !this.portalCreatorGroups_.isEmpty())
+ {
+ policyProvisioner.setPortalCreatorGroups(this.portalCreatorGroups_);
+ }
+
+ //Initialize the PolicyProvisioner
+ policyProvisioner.initialize();
+
}
+
+ public JBossSecurityPlugin getSecurityPlugin()
+ {
+ return this.securityPlugin;
+ }
// TODO: unnecessary to keep potalACLPlugin
public void addPortalACLPlugin(PortalACLPlugin plugin)
@@ -231,7 +257,7 @@
public boolean hasPermission(PortalConfig pconfig)
{
- Identity identity = getIdentity();
+ /*Identity identity = getIdentity();
if (hasPermission(identity, pconfig.getEditPermission()))
{
pconfig.setModifiable(true);
@@ -239,49 +265,58 @@
}
pconfig.setModifiable(false);
String[] accessPerms = (pconfig.getAccessPermissions());
- for (String per : accessPerms)
+ if(accessPerms != null)
{
- if (hasPermission(identity, per))
- {
- return true;
- }
+ for (String per : accessPerms)
+ {
+ if (hasPermission(identity, per))
+ {
+ return true;
+ }
+ }
}
- return false;
+
+ return false;*/
+ try
+ {
+ //Use the JBoss Security Framework
+ ExoEnforcementPoint enforcementPoint = this.securityPlugin.getExoEnforcementPoint();
+ Identity identity = this.getIdentity();
+ if(enforcementPoint.checkWriteAccess(identity, pconfig))
+ {
+ pconfig.setModifiable(true);
+ return true;
+ }
+ pconfig.setModifiable(false);
+ return enforcementPoint.checkReadAccess(identity, pconfig);
+ }
+ catch(EnforcementException enfe)
+ {
+ //TODO: log this....
+ throw new RuntimeException(enfe);
+ }
}
public boolean hasEditPermission(PortalConfig pconfig)
{
- return hasPermission(getIdentity(), pconfig.getEditPermission());
+ //return hasPermission(getIdentity(), pconfig.getEditPermission());
+ try
+ {
+ //Use the JBoss Security Framework
+ ExoEnforcementPoint enforcementPoint = this.securityPlugin.getExoEnforcementPoint();
+ Identity identity = this.getIdentity();
+ return enforcementPoint.checkWriteAccess(identity, pconfig);
+ }
+ catch(EnforcementException enfe)
+ {
+ //TODO: log this....
+ throw new RuntimeException(enfe);
+ }
}
- /**
- * This method is equivalent to <code>hasEditPermission(PortalConfig)</code>. That allows us
- * to check edit permission on a UIPortal, without converting UIPortal into PortalConfig via
- * PortalDataMapper.
- *
- * @param ownerType the owner type
- * @param ownerId the owner id
- * @param editPermExpression the permission expression
- * @return true or false
- */
- public boolean hasEditPermissionOnPortal(String ownerType, String ownerId, String editPermExpression)
- {
- Identity identity = this.getIdentity();
- if(superUser_.equals(identity.getUserId()))
- {
- return true;
- }
-
- if(PortalConfig.USER_TYPE.equals(ownerType)){
- return identity.getUserId().equals(ownerId);
- }
-
- return hasPermission(identity, editPermExpression);
- }
-
public boolean hasCreatePortalPermission()
{
- Identity identity = getIdentity();
+ /*Identity identity = getIdentity();
if (superUser_.equals(identity.getUserId()))
{
return true;
@@ -297,12 +332,22 @@
return true;
}
}
- return false;
+ return false;*/
+ try
+ {
+ ExoEnforcementPoint enforcementPoint = this.securityPlugin.getExoEnforcementPoint();
+ return enforcementPoint.checkCreatePortalAccess(getIdentity());
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
}
public boolean hasEditPermission(PageNavigation pageNav)
{
- Identity identity = getIdentity();
+ /*Identity identity = getIdentity();
if (superUser_.equals(identity.getUserId()))
{
pageNav.setModifiable(true);
@@ -336,12 +381,28 @@
{
return pageNav.getOwnerId().equals(identity.getUserId());
}
- return false;
+ return false;*/
+ try
+ {
+ ExoEnforcementPoint enforcementPoint = this.securityPlugin.getExoEnforcementPoint();
+ Identity identity = this.getIdentity();
+ boolean hasWriteAccess = enforcementPoint.checkWriteAccess(identity, pageNav);
+ if(hasWriteAccess && superUser_.equals(identity.getUserId()))
+ {
+ pageNav.setModifiable(true);
+ }
+ return hasWriteAccess;
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
}
public boolean hasPermission(Page page)
{
- Identity identity = getIdentity();
+ /*Identity identity = getIdentity();
if (PortalConfig.USER_TYPE.equals(page.getOwnerType()))
{
if (page.getOwnerId().equals(identity.getUserId()))
@@ -372,12 +433,31 @@
}
}
}
- return false;
+ return false;*/
+ try
+ {
+ ExoEnforcementPoint enforcementPoint = this.securityPlugin.getExoEnforcementPoint();
+ Identity identity = this.getIdentity();
+ boolean hasWriteAccess = enforcementPoint.checkWriteAccess(identity, page);
+ if(hasWriteAccess)
+ {
+ page.setModifiable(true);
+ return true;
+ }
+
+ page.setModifiable(false);
+ return enforcementPoint.checkReadAccess(identity, page);
+ }
+ catch(EnforcementException enfe)
+ {
+ //TODO: log this....
+ throw new RuntimeException(enfe);
+ }
}
public boolean hasEditPermission(Page page)
{
- Identity identity = getIdentity();
+ /*Identity identity = getIdentity();
if (PortalConfig.USER_TYPE.equals(page.getOwnerType()))
{
if (page.getOwnerId().equals(identity.getUserId()))
@@ -393,11 +473,55 @@
return true;
}
page.setModifiable(false);
- return false;
+ return false;*/
+ try
+ {
+ ExoEnforcementPoint enforcementPoint = this.securityPlugin.getExoEnforcementPoint();
+ Identity identity = this.getIdentity();
+ boolean hasWriteAccess = enforcementPoint.checkWriteAccess(identity, page);
+ if(hasWriteAccess)
+ {
+ page.setModifiable(true);
+ return true;
+ }
+
+ page.setModifiable(false);
+ return false;
+ }
+ catch(EnforcementException enfe)
+ {
+ //TODO: log this....
+ throw new RuntimeException(enfe);
+ }
}
-
+
/**
+ * This method is equivalent to <code>hasEditPermission(PortalConfig)</code>. That allows us
+ * to check edit permission on a UIPortal, without converting UIPortal into PortalConfig via
+ * PortalDataMapper.
*
+ * @param ownerType the owner type
+ * @param ownerId the owner id
+ * @param editPermExpression the permission expression
+ * @return true or false
+ */
+ public boolean hasEditPermissionOnPortal(String ownerType, String ownerId, String editPermExpression)
+ {
+ Identity identity = this.getIdentity();
+ if(superUser_.equals(identity.getUserId()))
+ {
+ return true;
+ }
+
+ if(PortalConfig.USER_TYPE.equals(ownerType)){
+ return identity.getUserId().equals(ownerId);
+ }
+
+ return hasPermission(identity, editPermExpression);
+ }
+
+ /**
+ *
* Minh Hoang TO - This method is equivalent to
* <code>hasEditPermission(Page)</code>. It allows us to check edit
* permission with a UIPage, without converting UIPage into Page via
@@ -424,6 +548,32 @@
{
return hasPermission(getIdentity(), expPerm);
}
+
+ public boolean hasPermission(Identity identity, String expPerm)
+ {
+ String currentUser = identity.getUserId();
+ if (superUser_.equals(currentUser))
+ {
+ return true;
+ }
+ if (expPerm == null)
+ {
+ return false;
+ }
+ if (EVERYONE.equals(expPerm))
+ {
+ return true;
+ }
+ Permission permission = new Permission();
+ permission.setPermissionExpression(expPerm);
+ String groupId = permission.getGroupId();
+ if (currentUser == null && groupId.equals(guestGroup_))
+ {
+ return true;
+ }
+ String membership = permission.getMembership();
+ return identity.isMemberOf(groupId, membership);
+ }
/**
* @param group
@@ -473,32 +623,6 @@
return id;
}
- public boolean hasPermission(Identity identity, String expPerm)
- {
- String currentUser = identity.getUserId();
- if (superUser_.equals(currentUser))
- {
- return true;
- }
- if (expPerm == null)
- {
- return false;
- }
- if (EVERYONE.equals(expPerm))
- {
- return true;
- }
- Permission permission = new Permission();
- permission.setPermissionExpression(expPerm);
- String groupId = permission.getGroupId();
- if (currentUser == null && groupId.equals(guestGroup_))
- {
- return true;
- }
- String membership = permission.getMembership();
- return identity.isMemberOf(groupId, membership);
- }
-
private List<String> defragmentPermission(String permission)
{
List<String> result = new ArrayList<String>();
Modified: portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java
===================================================================
--- portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java 2010-08-13 12:43:07 UTC (rev 3825)
@@ -28,6 +28,8 @@
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.security.Identity;
import org.exoplatform.services.security.MembershipEntry;
+import org.exoplatform.portal.config.security.plugin.ExoPolicyProvisioner;
+import org.exoplatform.portal.config.security.plugin.JBossSecurityPlugin;
import java.util.Collection;
import java.util.Collections;
@@ -45,6 +47,7 @@
protected UserACL ua;
protected User root, administrator, manager, user, guest;
+ protected JBossSecurityPlugin securityPlugin;
@Override
protected void setUp() throws Exception
@@ -70,7 +73,30 @@
this.manager = manager;
this.user = user;
this.guest = guest;
+ this.securityPlugin = this.ua.getSecurityPlugin();
}
+
+ protected void provisionPortalPolicy(PortalConfig portal) throws Exception
+ {
+ ExoPolicyProvisioner exoPolicyProvisioner = this.securityPlugin.getExoPolicyProvisioner();
+
+ //Provision the Policy for this Resource
+ exoPolicyProvisioner.provision(portal);
+
+ //Debug
+ exoPolicyProvisioner.debug();
+ }
+
+ protected void provisionPagePolicy(Page page) throws Exception
+ {
+ ExoPolicyProvisioner exoPolicyProvisioner = this.securityPlugin.getExoPolicyProvisioner();
+
+ //Provision the Policy for this Resource
+ exoPolicyProvisioner.provision(page);
+
+ //Debug
+ exoPolicyProvisioner.debug();
+ }
public class User
{
Modified: portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java
===================================================================
--- portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java 2010-08-13 12:43:07 UTC (rev 3825)
@@ -31,12 +31,14 @@
protected abstract String getOwnerType();
- public void testPage()
+ public void testPage() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[0]);
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -53,12 +55,14 @@
assertFalse(guest.hasEditPermission(page));
}
- public void testPageAccessibleByEveryone()
+ public void testPageAccessibleByEveryone() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[]{"Everyone"});
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -75,13 +79,15 @@
assertFalse(guest.hasEditPermission(page));
}
- public void testPageEditableByEveryone()
+ public void testPageEditableByEveryone() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[0]);
page.setEditPermission("Everyone");
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -98,12 +104,14 @@
assertTrue(guest.hasEditPermission(page));
}
- public void testPageAccessibleByGuests()
+ public void testPageAccessibleByGuests() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[]{"whatever:/platform/guests"});
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -120,13 +128,15 @@
assertFalse(guest.hasEditPermission(page));
}
- public void testPageEditableByGuests()
+ public void testPageEditableByGuests() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[0]);
page.setEditPermission("whatever:/platform/guests");
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -143,12 +153,14 @@
assertTrue(guest.hasEditPermission(page));
}
- public void testPageAccessibleByEveryOneAndGuests()
+ public void testPageAccessibleByEveryOneAndGuests() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[]{"Everyone", "whatever:/platform/guests"});
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -165,12 +177,14 @@
assertFalse(guest.hasEditPermission(page));
}
- public void testPageWithAccessPermission()
+ public void testPageWithAccessPermission() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[]{"manager:/manageable"});
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
@@ -190,13 +204,15 @@
assertFalse(guest.hasPermission(page));
}
- public void testPageWithEditPermission()
+ public void testPageWithEditPermission() throws Exception
{
Page page = new Page();
page.setOwnerType(getOwnerType());
page.setOwnerId("foo");
page.setAccessPermissions(new String[0]);
page.setEditPermission("manager:/manageable");
+
+ this.provisionPagePolicy(page);
//
assertTrue(root.hasPermission(page));
Modified: portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java
===================================================================
--- portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java 2010-08-13 12:43:07 UTC (rev 3825)
@@ -28,12 +28,14 @@
*/
public class TestUserPageACL extends AbstractTestUserACL
{
- public void testUserPageIsAlwaysUsableOnlyByItsOwner()
+ public void testUserPageIsAlwaysUsableOnlyByItsOwner() throws Exception
{
Page page = new Page();
page.setOwnerType("user");
page.setOwnerId("user");
page.setAccessPermissions(new String[0]);
+ this.provisionPagePolicy(page);
+
assertTrue(root.hasPermission(page));
assertFalse(administrator.hasPermission(page));
assertFalse(manager.hasPermission(page));
@@ -50,6 +52,8 @@
page.setOwnerType("user");
page.setOwnerId("user");
page.setAccessPermissions(new String[]{"manager:/manageable"});
+ this.provisionPagePolicy(page);
+
assertTrue(root.hasPermission(page));
assertFalse(administrator.hasPermission(page));
assertTrue(manager.hasPermission(page));
@@ -66,6 +70,8 @@
page.setOwnerType("user");
page.setOwnerId("user");
page.setEditPermission("manager:/manageable");
+ this.provisionPagePolicy(page);
+
assertTrue(root.hasPermission(page));
assertFalse(administrator.hasPermission(page));
assertFalse(manager.hasPermission(page));
@@ -83,6 +89,8 @@
page.setOwnerType("user");
page.setOwnerId("user");
page.setAccessPermissions(new String[]{"Everyone"});
+ this.provisionPagePolicy(page);
+
assertTrue(root.hasPermission(page));
assertTrue(administrator.hasPermission(page));
assertTrue(manager.hasPermission(page));
@@ -100,6 +108,8 @@
page.setOwnerId("user");
page.setAccessPermissions(new String[0]);
page.setEditPermission("Everyone");
+ this.provisionPagePolicy(page);
+
assertTrue(root.hasPermission(page));
assertFalse(administrator.hasPermission(page));
assertFalse(manager.hasPermission(page));
Modified: portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/plugin/AbstractSecurityTest.java
===================================================================
--- portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/plugin/AbstractSecurityTest.java 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/plugin/AbstractSecurityTest.java 2010-08-13 12:43:07 UTC (rev 3825)
@@ -49,9 +49,6 @@
@Override
protected void setUp() throws Exception
{
- securityPlugin = new JBossSecurityPlugin();
- securityPlugin.start();
-
// Setting up the initial state of data used during enforcement decisions
// Setup the UserACL instance
UserACLMetaData md = new UserACLMetaData();
@@ -66,6 +63,7 @@
// Initializes the UserACL instance
this.ua = new UserACL(md);
+ this.securityPlugin = this.ua.getSecurityPlugin();
// SetUp the mock identities
Modified: portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java
===================================================================
--- portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java 2010-08-13 12:25:10 UTC (rev 3824)
+++ portal/branches/portalsecurity/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java 2010-08-13 12:43:07 UTC (rev 3825)
@@ -21,6 +21,7 @@
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.security.AbstractTestUserACL;
+import org.exoplatform.portal.config.security.plugin.ExoPolicyProvisioner;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
@@ -29,10 +30,11 @@
public class TestPortalACL extends AbstractTestUserACL
{
- public void testFoo()
+ public void testFoo() throws Exception
{
PortalConfig portal = new PortalConfig();
portal.setAccessPermissions(new String[0]);
+ this.provisionPortalPolicy(portal);
//
assertTrue(root.hasEditPermission(portal));
@@ -49,10 +51,11 @@
assertFalse(guest.hasPermission(portal));
}
- public void testPortalAccessible()
+ public void testPortalAccessible() throws Exception
{
PortalConfig portal = new PortalConfig();
portal.setAccessPermissions(new String[]{"manager:/manageable"});
+ this.provisionPortalPolicy(portal);
//
assertTrue(root.hasEditPermission(portal));
@@ -69,11 +72,12 @@
assertFalse(guest.hasPermission(portal));
}
- public void testPortalEditable()
+ public void testPortalEditable() throws Exception
{
PortalConfig portal = new PortalConfig();
portal.setAccessPermissions(new String[0]);
portal.setEditPermission("manager:/manageable");
+ this.provisionPortalPolicy(portal);
//
assertTrue(root.hasEditPermission(portal));
@@ -90,11 +94,12 @@
assertFalse(guest.hasPermission(portal));
}
- public void testPortalAccessibleAndEditable()
+ public void testPortalAccessibleAndEditable() throws Exception
{
PortalConfig portal = new PortalConfig();
portal.setAccessPermissions(new String[]{"manager:/manageable"});
portal.setEditPermission("manager:/manageable");
+ this.provisionPortalPolicy(portal);
//
assertTrue(root.hasEditPermission(portal));
14 years, 5 months
gatein SVN: r3824 - in exo/portal/branches/3.1.x: webui/portal/src/main/java/org/exoplatform/portal/webui/application and 1 other directory.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 08:25:10 -0400 (Fri, 13 Aug 2010)
New Revision: 3824
Modified:
exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
EXOGTN-17: Disable caching and add debug for gadgets while running GateIn in developing mode
Modified: exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
===================================================================
--- exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-08-13 12:17:20 UTC (rev 3823)
+++ exo/portal/branches/3.1.x/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-08-13 12:25:10 UTC (rev 3824)
@@ -26,6 +26,7 @@
import org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.ValueParam;
@@ -260,7 +261,9 @@
public boolean isGadgetDeveloper(String username)
{
- return true;
+ if(PropertyManager.isDevelopping())
+ return true;
+ return false;
}
public String getCountry()
Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-08-13 12:17:20 UTC (rev 3823)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-08-13 12:25:10 UTC (rev 3824)
@@ -21,6 +21,7 @@
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.ApplicationState;
@@ -312,50 +313,24 @@
public boolean isNoCache()
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null) { String prefs = userGadgetStorage.get(username,
- * getApplicationName(), getApplicationInstanceUniqueId(), PREF_NO_CACHE);
- * return prefs.equals("1"); } } catch (Exception e) {} return false;
- */
- return true;
+ if(PropertyManager.isDevelopping())
+ return true;
+ return false;
}
public void setNoCache(boolean value)
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null && getGadgetRegistryService().isGadgetDeveloper(username)) {
- * userGadgetStorage.save(username, getApplicationName(),
- * getApplicationInstanceUniqueId(), PREF_NO_CACHE, value ? "1" : "0"); } }
- * catch (Exception e) {}
- */
}
public boolean isDebug()
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null) { String prefs = userGadgetStorage.get(username,
- * getApplicationName(), getApplicationInstanceUniqueId(), PREF_DEBUG);
- * return prefs.equals("1"); } } catch (Exception e) {} return false;
- */
- return true;
+ if(PropertyManager.isDevelopping())
+ return true;
+ return false;
}
public void setDebug(boolean value)
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null && getGadgetRegistryService().isGadgetDeveloper(username)) {
- * userGadgetStorage.save(username, getApplicationName(),
- * getApplicationInstanceUniqueId(), PREF_DEBUG, value ? "1" : "0"); } }
- * catch (Exception e) {}
- */
}
public boolean isGadgetDeveloper()
14 years, 5 months
gatein SVN: r3823 - exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 08:17:20 -0400 (Fri, 13 Aug 2010)
New Revision: 3823
Modified:
exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
Log:
EXOGTN-34: Rss gadget displays blank screen when feed url is invalid rss link
Modified: exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
===================================================================
--- exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-08-13 11:54:37 UTC (rev 3822)
+++ exo/portal/branches/3.1.x/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-08-13 12:17:20 UTC (rev 3823)
@@ -83,16 +83,20 @@
}
}
-RssAggregator.prototype.renderFeed = function(feed) {
- this.feed = feed;
- gadgets.window.setTitle("RSS: " + feed.Title);
+RssAggregator.prototype.renderFeed = function(feedObj) {
+ if(feedObj.rc != 200 && feedObj.data == undefined) {
+ document.write("the url: " + feedurl + " is down or invalid");
+ return;
+ }
+ this.feed = feedObj.data;
+ gadgets.window.setTitle("RSS: " + this.feed.Title);
var feedEl = _gel("feedContainer");
var bullet = "<img src='" + this.getFavicon(feedurl) + "' alt='' border=0 align='absmiddle' style='height:16;width:16;' onerror='this.style.visibility=\"hidden\";'> ";
- if (feed != null) {
+ if (this.feed != null) {
// Access the data for a given entry
- if (feed.Entry) {
- for (var i = 0; i < feed.Entry.length; i++) {
+ if (this.feed.Entry) {
+ for (var i = 0; i < this.feed.Entry.length; i++) {
var itemEl = document.createElement('div');
var item_title = document.createElement('div');
var item_more = document.createElement('div');
@@ -116,10 +120,10 @@
item_date.className = 'date';
item_link.className = 'link';
- item_title.innerHTML = bullet + "<a id='link_title_"+i+"' class='titlelink' href='" + feed.Entry[i].Link + "' onclick='rssAggregator.toggleDescription("+i+");return false;'>" + feed.Entry[i].Title + "</a>";
- item_date.innerHTML = this.timeToPrettyString(feed.Entry[i].Date);
+ item_title.innerHTML = bullet + "<a id='link_title_"+i+"' class='titlelink' href='" + this.feed.Entry[i].Link + "' onclick='rssAggregator.toggleDescription("+i+");return false;'>" + this.feed.Entry[i].Title + "</a>";
+ item_date.innerHTML = this.timeToPrettyString(this.feed.Entry[i].Date);
- item_desc.innerHTML = feed.Entry[i].Summary;
+ item_desc.innerHTML = this.feed.Entry[i].Summary;
item_link.innerHTML = this.generateLinkContent(i);
@@ -146,6 +150,10 @@
}
RssAggregator.prototype.refreshFeed = function() {
- _IG_FetchFeedAsJSON(prefs.getString("rssurl"), function(feed) {rssAggregator.renderFeed(feed);}, entries, true);
+ var params = {};
+ params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.FEED;
+ params[gadgets.io.RequestParameters.NUM_ENTRIES] = entries;
+ params[gadgets.io.RequestParameters.GET_SUMMARIES] = true;
+ gadgets.io.makeRequest(prefs.getString("rssurl"), function(feedObj) {rssAggregator.renderFeed(feedObj);}, params);
}
14 years, 5 months
gatein SVN: r3822 - exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 07:54:37 -0400 (Fri, 13 Aug 2010)
New Revision: 3822
Modified:
exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
Log:
EXOGTN-30: Draged component is dropped automatically as the cursor is moved out of browser border
Modified: exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
--- exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-08-13 11:49:54 UTC (rev 3821)
+++ exo/portal/branches/3.1.x/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-08-13 11:54:37 UTC (rev 3822)
@@ -32,6 +32,10 @@
*/
PortalDragDrop.prototype.init = function(e) {
+ if (eXo.core.DragDrop.dndEvent && eXo.core.DragDrop.dndEvent.clickObject == this){
+ return;
+ }
+
if (!e) e = window.event;
if(((e.which) && (e.which == 2 || e.which == 3)) || ((e.button) && (e.button == 2))) return;
@@ -194,7 +198,9 @@
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode != 27)) {
- eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
+ if (dndEvent.foundTargetObject.foundIndex != null) {
+ eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
+ }
} else {
if(dndEvent.dragObject.parentNode.nodeName.toLowerCase() == "td") {
dndEvent.dragObject.parentNode.style.width = "auto";
@@ -220,12 +226,6 @@
dndEvent.dragObject.style.width = "auto" ;
};
- DragDrop.cancelCallback = function(dndEvent) {
- if(Browser.browserType == "ie" && Browser.findMouseYInClient(dndEvent.backupMouseEvent) < 0) {
- DragDrop.onDrop(dndEvent.backupMouseEvent);
- }
- };
-
var clickObject = this;
var componentBlock = DOMUtil.findAncestorByClass(clickObject, "UIComponentBlock") ;
@@ -284,7 +284,7 @@
] ;
try {
- dndEvent.lastFoundTargetObject.foundIndex = -1;
+ dndEvent.lastFoundTargetObject.foundIndex = null;
} catch(err) {
}
14 years, 5 months
gatein SVN: r3821 - in exo/portal/branches/3.1.x: webui/portal/src/main/java/org/exoplatform/portal/webui/application and 1 other directory.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 07:49:54 -0400 (Fri, 13 Aug 2010)
New Revision: 3821
Modified:
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
EXOGTN-29: GateIn should use the portlet title set in RenderResponse for the title on info bar
Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-08-13 11:47:25 UTC (rev 3820)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-08-13 11:49:54 UTC (rev 3821)
@@ -37,12 +37,14 @@
<div class="FixHeight">
<%
if(hasPermission) {
- try {
- String portletName = uicomponent.getProducedOfferedPortlet().getInfo().getName();
- print _ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description." + portletName);
- } catch(Exception e){
- print uicomponent.getDisplayName();
- }
+ if(portletTitle == null || portletTitle.trim().length() < 1) {
+ try {
+ String portletName = uicomponent.getProducedOfferedPortlet().getInfo().getName();
+ print _ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description." + portletName);
+ } catch(Exception e){
+ print uicomponent.getDisplayName();
+ }
+ } else print portletTitle;
} else print "<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>";
%>
</div>
@@ -60,10 +62,12 @@
if(portalMode != uiPortalApp.CONTAINER_BLOCK_EDIT_MODE && portalMode != uiPortalApp.APP_BLOCK_EDIT_MODE) {
if(uicomponent.getShowInfoBar()) {
- String title = uicomponent.getTitle();
- if(title == null || title.trim().length() < 1)
+ String title = portletTitle;
+ if(title == null || title.trim().length() < 1)
+ title = uicomponent.getTitle();
+ if(title == null || title.trim().length() < 1)
title = uicomponent.getDisplayName();
- if(title == null || title.trim().length() < 1)
+ if(title == null || title.trim().length() < 1)
title = portletId;
/*Begin Window Portlet Bar*/
String visibility = "visible";
@@ -288,7 +292,9 @@
String portletIcon = uicomponent.getIcon();
if(portletIcon == null) portletIcon = "PortletIcon";
- String title = uicomponent.getDisplayTitle();
+ String title = portletTitle;
+ if(title == null || title.trim().length() < 1)
+ title = uicomponent.getDisplayTitle();
if(title.length() > 30) title = title.substring(0,27) + "...";
%>
<div class="PortletIcon $portletIcon"><%=hasPermission ? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-08-13 11:47:25 UTC (rev 3820)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-08-13 11:49:54 UTC (rev 3821)
@@ -325,12 +325,6 @@
}
//
- if (portletTitle == null)
- {
- portletTitle = "Portlet";
- }
-
- //
if (context.useAjax() && !prcontext.getFullRender())
{
if (markup != null)
14 years, 5 months
gatein SVN: r3820 - exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 07:47:25 -0400 (Fri, 13 Aug 2010)
New Revision: 3820
Modified:
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
Log:
EXOGTN-27: Portlet Mode handling does not work correctly
Modified: exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
--- exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-08-13 11:36:08 UTC (rev 3819)
+++ exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-08-13 11:47:25 UTC (rev 3820)
@@ -199,7 +199,7 @@
}
Mode mode = renderURL.getMode();
- if (mode != null && !mode.equals(Mode.VIEW))
+ if (mode != null)
{
appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
}
14 years, 5 months
gatein SVN: r3819 - exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 07:36:08 -0400 (Fri, 13 Aug 2010)
New Revision: 3819
Modified:
exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
Log:
EXOGTN-23: Exceptions are not properly handled in ApplicationRegistry portlet
Modified: exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
===================================================================
--- exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2010-08-13 11:29:49 UTC (rev 3818)
+++ exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2010-08-13 11:36:08 UTC (rev 3819)
@@ -313,17 +313,38 @@
public String getDisplayName()
{
- return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
+ try
+ {
+ return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
+ }
+ catch (Exception ex)
+ {
+ return "COULD NOT GET DISPLAY NAME OF THE PORTLET";
+ }
}
public String getDescription()
{
- return getMetaValue(MetaInfo.DESCRIPTION, name_);
+ try
+ {
+ return getMetaValue(MetaInfo.DESCRIPTION, name_);
+ }
+ catch (Exception ex)
+ {
+ return "COULD NOT GET DESCRIPTION OF THE PORTLET";
+ }
}
public PreferencesInfo getPortletPreferences()
{
- return portletInfo_.getPreferences();
+ try
+ {
+ return portletInfo_.getPreferences();
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
}
private String getMetaValue(String metaKey, String defaultValue)
14 years, 5 months
gatein SVN: r3818 - exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-13 07:29:49 -0400 (Fri, 13 Aug 2010)
New Revision: 3818
Modified:
exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
Log:
EXOGTN-20: Fix error in validator of Start/End Publication Date
Modified: exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
===================================================================
--- exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-08-13 11:28:14 UTC (rev 3817)
+++ exo/portal/branches/3.1.x/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-08-13 11:29:49 UTC (rev 3818)
@@ -73,17 +73,16 @@
{
// Specify whether or not date/time parsing is to be lenient.
sdf.setLenient(false);
- Date stDate = sdf.parse(s);
- s = stFormat.format(stDate);
+ sdf.parse(s);
}
catch (Exception e)
{
- throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
+ throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args, ApplicationMessage.WARNING));
}
if (s.matches(DATETIME_REGEX) && isValidDateTime(s))
return;
- throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
+ throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args, ApplicationMessage.WARNING));
}
private boolean isValidDateTime(String dateTime)
14 years, 5 months