JBoss Portal SVN: r5940 - in trunk: common/src/main/org/jboss/portal/common/util wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer wsrp/src/main/org/jboss/portal/wsrp/consumer wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-29 02:05:37 -0500 (Fri, 29 Dec 2006)
New Revision: 5940
Modified:
trunk/common/src/main/org/jboss/portal/common/util/Tools.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
Log:
- Consumer now is able to discriminate between POPs and CCPs. Still need to handle implicit cloning!
- getPortletMap now also returns clones.
- Improved fast failure of several methods to avoid calls to WSRP when not needed.
- Added possibility of cloning WSRPPortlets.
- Cleaner management of cache.
- Modified incorrect assumption in PortletManagementTestCase. Needs more tests!
Modified: trunk/common/src/main/org/jboss/portal/common/util/Tools.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/Tools.java 2006-12-28 22:58:58 UTC (rev 5939)
+++ trunk/common/src/main/org/jboss/portal/common/util/Tools.java 2006-12-29 07:05:37 UTC (rev 5940)
@@ -26,6 +26,8 @@
import org.apache.log4j.Logger;
import org.jboss.portal.common.logging.Log4JWriter;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -38,12 +40,10 @@
import java.io.Serializable;
import java.io.StringWriter;
import java.io.Writer;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
+import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Array;
import java.math.BigInteger;
import java.net.URL;
import java.net.URLClassLoader;
@@ -380,6 +380,7 @@
return new Enumeration()
{
boolean hasMore = false;
+
public boolean hasMoreElements()
{
return hasMore;
@@ -391,7 +392,8 @@
{
hasMore = false;
}
- else{
+ else
+ {
throw new NoSuchElementException();
}
return o;
@@ -446,7 +448,7 @@
public static List toList(Object[] objects)
{
- List list = new ArrayList();
+ List list = new ArrayList(objects.length);
for (int i = 0; i < objects.length; i++)
{
Object object = objects[i];
@@ -520,8 +522,8 @@
* Returns an iterator over the array elements within the specified range.
*
* @param objects the array containing the objects to iterate on
- * @param from the inclusive start index
- * @param to the exclusive stop index
+ * @param from the inclusive start index
+ * @param to the exclusive stop index
* @return the iterator
* @throws IllegalArgumentException if the object array is null or the specified range is not valid
*/
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java 2006-12-28 22:58:58 UTC (rev 5939)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java 2006-12-29 07:05:37 UTC (rev 5940)
@@ -27,7 +27,6 @@
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
@@ -108,9 +107,9 @@
try
{
consumer.setProperties(original, null);
- ExtendedAssert.fail("Shouldn't be possible to set properties on non-cloned portlet");
+ ExtendedAssert.fail("Shouldn't be possible to set properties with null changes");
}
- catch (PortletInvokerException expected)
+ catch (IllegalArgumentException expected)
{
//expected
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-28 22:58:58 UTC (rev 5939)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-29 07:05:37 UTC (rev 5940)
@@ -119,9 +119,12 @@
/** The service factory. */
private ServiceFactory serviceFactory;
- /** The cached portlets. */
- private Map cachedPortletMap;
+ /** The Producer-Offered Portlets (handle -> WSRPPortlet) */
+ private Map popsMap;
+ /** Consumer-Configured Portlets (handle -> WSRPPortlet) */
+ private Map ccpsMap = new HashMap();
+
/** Portlet groups. */
private Map portletGroups;
@@ -191,44 +194,40 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletId, "portlet id", "PortletContext");
- Portlet portlet;
+ // first try to see if we want a cloned portlet
+ Portlet portlet = (Portlet)ccpsMap.get(portletId);
- // if cache is still valid, use information from cached service description
- if (useCache() && !isCacheExpired())
+ // the portlet is not cloned, so try POP ones...
+ if (portlet == null)
{
- log.debug("getPortlet from cached service description");
- Map portlets;
- try
+ // if cache is still valid, use information from cached service description
+ if (useCache() && !isCacheExpired())
{
- portlets = getPortletMap();
- }
- catch (ServiceDescriptionUnavailableException e)
- {
- throw new InvokerUnavailableException(e.getMessage(), e.getCause());
- }
+ log.debug("getPortlet from cached service description");
- portlet = (Portlet)portlets.get(portletId);
- }
- else // otherwise, retrieve just the information for the appropriate portlet
- {
- log.debug("getPortlet via getPortletDescription");
- initializeProducerInteractionAndRegisterIfPossible();
- GetPortletDescription gpd = WSRPTypeFactory.createGetPortletDescription(registrationContext, portletId);
- gpd.setUserContext(null); // todo: deal with user context!!
- try
- {
- PortletDescriptionResponse response = getPortletManagementService().getPortletDescription(gpd);
- ParameterValidation.throwIllegalArgExceptionIfNull(response, "PortletDescriptionResponse");
- portlet = createWSRPPortletFromPortletDescription(response.getPortletDescription());
+ portlet = (Portlet)popsMap.get(portletId);
}
- catch (InvalidHandleFault invalidHandleFault)
+ else // otherwise, retrieve just the information for the appropriate portlet
{
- throw new NoSuchPortletException(invalidHandleFault, portletId);
+ log.debug("getPortlet via getPortletDescription");
+ initializeProducerInteractionAndRegisterIfPossible();
+ GetPortletDescription gpd = WSRPTypeFactory.createGetPortletDescription(registrationContext, portletId);
+ gpd.setUserContext(null); // todo: deal with user context!!
+ try
+ {
+ PortletDescriptionResponse response = getPortletManagementService().getPortletDescription(gpd);
+ ParameterValidation.throwIllegalArgExceptionIfNull(response, "PortletDescriptionResponse");
+ portlet = createWSRPPortletFromPortletDescription(response.getPortletDescription());
+ }
+ catch (InvalidHandleFault invalidHandleFault)
+ {
+ throw new NoSuchPortletException(invalidHandleFault, portletId);
+ }
+ catch (Exception e)
+ {
+ throw new InvokerUnavailableException("Couldn't access remote producer '" + producerId + "'", e);
+ }
}
- catch (Exception e)
- {
- throw new InvokerUnavailableException("Couldn't access remote producer '" + producerId + "'", e);
- }
}
if (portlet == null)
@@ -266,6 +265,12 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
+ WSRPPortlet original = getWSRPPortlet(portletContext.getId());
+ if (original == null)
+ {
+ throw new PortletInvokerException("No portlet '" + portletContext.getId() + "' to clone!");
+ }
+
initializeProducerInteractionAndRegisterIfPossible();
// todo: deal with user context
@@ -273,7 +278,13 @@
WSRPUtils.convertToWSRPPortletContext(portletContext), null);
try
{
- return WSRPUtils.convertToPortalPortletContext(getPortletManagementService().clonePortlet(clonePortlet));
+ PortletContext newPortletContext = WSRPUtils.convertToPortalPortletContext(getPortletManagementService().clonePortlet(clonePortlet));
+ if (newPortletContext != null)
+ {
+ ccpsMap.put(newPortletContext.getId(), WSRPPortlet.createClone(newPortletContext, original.getWSRPInfo()));
+ }
+
+ return newPortletContext;
}
catch (Exception e)
{
@@ -281,14 +292,33 @@
}
}
- public List destroyClones(List portletIds) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- ParameterValidation.throwIllegalArgExceptionIfNull(portletIds, "Portlet identifiers");
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContexts, "Portlet identifiers");
+ int numberOfClones = portletContexts.size();
+ if (numberOfClones == 0)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ List handles = new ArrayList(numberOfClones);
+ List result = new ArrayList(numberOfClones);
+ for (Iterator contexts = portletContexts.iterator(); contexts.hasNext();)
+ {
+ PortletContext context = (PortletContext)contexts.next();
+ String id = context.getId();
+ if (getPortlet(id) == null)
+ {
+ result.add(new DestroyCloneFailure(id, "Couldn't destroy clone '" + id + "' because there is no such clone!"));
+ }
+ handles.add(id);
+ }
+
initializeProducerInteractionAndRegisterIfPossible();
DestroyPortlets destroyPortlets = WSRPTypeFactory.createDestroyPortlets(registrationContext,
- (String[])portletIds.toArray(new String[0]));
+ (String[])handles.toArray(new String[0]));
try
{
@@ -296,12 +326,22 @@
DestroyFailed[] failures = response.getDestroyFailed();
if (failures != null)
{
- List result = new ArrayList(failures.length);
+ // list all the failures and successes
+ List successfullyDestroyed = new ArrayList(handles);
for (int i = 0; i < failures.length; i++)
{
DestroyFailed failure = failures[i];
- result.add(new DestroyCloneFailure(failure.getPortletHandle(), failure.getReason()));
+ String handle = failure.getPortletHandle();
+ result.add(new DestroyCloneFailure(handle, failure.getReason()));
+ successfullyDestroyed.remove(handle);
}
+
+ // remove from the CCP map the clones that were sucessfully destroyed
+ for (Iterator clonesToRemove = successfullyDestroyed.iterator(); clonesToRemove.hasNext();)
+ {
+ ccpsMap.remove(clonesToRemove.next());
+ }
+
return result;
}
else
@@ -373,6 +413,13 @@
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(changes, "Property changes");
+ WSRPPortlet portlet = getWSRPPortlet(portletContext.getId());
+ if (portlet == null)
+ {
+ throw new PortletInvokerException("Cannot set properties on portlet '" + portletContext.getId()
+ + "' because there is no such portlet.");
+ }
+
initializeProducerInteractionAndRegisterIfPossible();
PropertyList propertyList = WSRPTypeFactory.createPropertyList();
@@ -405,7 +452,15 @@
try
{
- return WSRPUtils.convertToPortalPortletContext(getPortletManagementService().setPortletProperties(setPortletProperties));
+ PortletContext newPortletContext = WSRPUtils.convertToPortalPortletContext(getPortletManagementService().setPortletProperties(setPortletProperties));
+ portlet.setPortletContext(newPortletContext);
+ // if the portlet was cloned, add to the CCP map
+ if (!newPortletContext.getId().equals(portletContext.getId()))
+ {
+ ccpsMap.put(newPortletContext, portlet);
+ }
+
+ return newPortletContext;
}
catch (Exception e)
{
@@ -434,14 +489,7 @@
public Map getPortletGroupMap() throws ServiceDescriptionUnavailableException, PortletInvokerException
{
- if (useCache())
- {
- updateCachesIfNeeded();
- }
- else
- {
- extractOfferedPortlets(getServiceDescriptionAndRegisterIfNeeded()); // this updates portletGroups
- }
+ refreshPOPsIfNeeded();
return portletGroups;
}
@@ -471,16 +519,17 @@
private Map getPortletMap() throws ServiceDescriptionUnavailableException, PortletInvokerException
{
- if (useCache())
+ refreshPOPsIfNeeded();
+
+ if (ccpsMap.isEmpty())
{
- // Get most accurate value
- updateCachesIfNeeded();
-
- return cachedPortletMap;
+ return popsMap;
}
else
{
- return extractOfferedPortlets(getServiceDescriptionAndRegisterIfNeeded());
+ Map all = new HashMap(popsMap);
+ all.putAll(ccpsMap);
+ return all;
}
}
@@ -503,7 +552,7 @@
{
int length = portletDescriptions.length;
log.debug("Extracting " + length + " portlets.");
- Map portlets = new LinkedHashMap(length);
+ popsMap = new LinkedHashMap(length);
portletGroups = new HashMap();
for (int i = 0; i < length; i++)
@@ -513,16 +562,16 @@
if (wsrpPortlet != null)
{
- portlets.put(wsrpPortlet.getContext().getId(), wsrpPortlet);
+ popsMap.put(wsrpPortlet.getContext().getId(), wsrpPortlet);
}
}
-
- return portlets;
}
else
{
- return Collections.EMPTY_MAP;
+ popsMap = Collections.EMPTY_MAP;
}
+
+ return popsMap;
}
/**
@@ -552,7 +601,7 @@
}
else
{
- wsrpPortlet = new WSRPPortlet(portletHandle, info);
+ wsrpPortlet = new WSRPPortlet(PortletContext.createPortletContext(portletHandle), info);
// add the portlet to the appropriate group if needed
String portletGroupId = portletDescription.getGroupID();
@@ -577,16 +626,22 @@
return expirationCacheSeconds != null && expirationCacheSeconds.intValue() > 0;
}
- private void updateCachesIfNeeded()
- throws ServiceDescriptionUnavailableException, PortletInvokerException
+ private void refreshPOPsIfNeeded() throws ServiceDescriptionUnavailableException, PortletInvokerException
{
- if (isCacheExpired())
+ if (useCache())
{
- cachedPortletMap = extractOfferedPortlets(getServiceDescriptionAndRegisterIfNeeded());
+ if (isCacheExpired())
+ {
+ extractOfferedPortlets(getServiceDescriptionAndRegisterIfNeeded());
- // reset expiration time
- expirationTimeMillis = System.currentTimeMillis() + (expirationCacheSeconds.intValue() * 1000);
+ // reset expiration time
+ expirationTimeMillis = System.currentTimeMillis() + (expirationCacheSeconds.intValue() * 1000);
+ }
}
+ else
+ {
+ extractOfferedPortlets(getServiceDescriptionAndRegisterIfNeeded());
+ }
}
/**
@@ -595,7 +650,7 @@
*/
private boolean isCacheExpired()
{
- return System.currentTimeMillis() > expirationTimeMillis || cachedPortletMap == null || portletGroups == null;
+ return System.currentTimeMillis() > expirationTimeMillis || popsMap == null || portletGroups == null;
}
public Integer getExpirationCacheSeconds()
@@ -879,6 +934,7 @@
{
// the producer doesn't need registration, let this consumer know for future reference
registrationData = REGISTRATION_NOT_NEEDED;
+ extractOfferedPortlets(serviceDescription);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2006-12-28 22:58:58 UTC (rev 5939)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2006-12-29 07:05:37 UTC (rev 5940)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.wsrp.consumer.portlet;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.info.PortletInfo;
@@ -36,30 +37,31 @@
public class WSRPPortlet implements Portlet
{
- private String id;
+ private PortletContext portletContext;
private PortletInfo info;
public WSRPPortlet()
{
-
}
- public WSRPPortlet(String id)
+ public WSRPPortlet(PortletContext context, PortletInfo info)
{
- this.id = id;
+ ParameterValidation.throwIllegalArgExceptionIfNull(context, "PortletContext");
+ this.portletContext = context;
+ this.info = info;
}
- public WSRPPortlet(String id, PortletInfo info)
+ public static WSRPPortlet createClone(PortletContext newContext, WSRPPortletInfo originalInfo)
{
- this.id = id;
- this.info = info;
+ ParameterValidation.throwIllegalArgExceptionIfNull(newContext, "PortletContext");
+ return new WSRPPortlet(newContext, new WSRPPortletInfo(originalInfo));
}
/** Portlet interface implemented methods */
public PortletContext getContext()
{
- return PortletContext.createPortletContext(id);
+ return portletContext;
}
public PortletInfo getInfo()
@@ -72,13 +74,6 @@
return true;
}
- /** */
-
- public void setId(String id)
- {
- this.id = id;
- }
-
public void setInfo(PortletInfo info)
{
this.info = info;
@@ -89,4 +84,10 @@
{
return (WSRPPortletInfo)getInfo();
}
+
+ public void setPortletContext(PortletContext context)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(context, "PortletContext");
+ this.portletContext = context;
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2006-12-28 22:58:58 UTC (rev 5939)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2006-12-29 07:05:37 UTC (rev 5940)
@@ -26,6 +26,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.info.CacheInfo;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.MetaInfo;
@@ -67,10 +68,7 @@
public WSRPPortletInfo(final PortletDescription portletDescription)
{
- if (portletDescription == null)
- {
- throw new IllegalArgumentException("PortletDescription cannot be null!");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletDescription, "PortletDescription");
createCapabilitiesInfo(portletDescription);
@@ -79,6 +77,29 @@
createWSRPInfo(portletDescription);
}
+
+ public WSRPPortletInfo(WSRPPortletInfo other)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(other, "WSRPPortletInfo");
+
+ usesMethodGet = other.usesMethodGet;
+ defaultMarkupSecure = other.defaultMarkupSecure;
+ onlySecure = other.onlySecure;
+ hasUserSpecificState = other.hasUserSpecificState;
+ userContextStoredInSession = other.userContextStoredInSession;
+ templatesStoredInSession = other.templatesStoredInSession;
+ doesUrlTemplateProcessing = other.doesUrlTemplateProcessing;
+ groupId = other.groupId; // should be duplicate group id?
+
+ WSRPCapabilitiesInfo otherCapabilities = (WSRPCapabilitiesInfo)other.getCapabilities();
+ capabilities = new WSRPCapabilitiesInfo(new HashMap(otherCapabilities.mimeTypes),
+ new HashSet(otherCapabilities.modes), new HashSet(otherCapabilities.windowStates),
+ new HashSet(otherCapabilities.locales));
+
+ WSRPMetaInfo otherMeta = (WSRPMetaInfo)other.getMeta();
+ metaInfo = new WSRPMetaInfo(new HashMap(otherMeta.metaInfos));
+ }
+
public CapabilitiesInfo getCapabilities()
{
return capabilities;
@@ -195,61 +216,7 @@
locales.addAll(mimeTypeInfo.locales);
}
- capabilities = new CapabilitiesInfo()
- {
- public Set getMimeTypes()
- {
- return mimeTypes.keySet();
- }
-
- public Set getAllModes()
- {
- return modes;
- }
-
- public Set getModes(String mimeType)
- {
- MIMETypeInfo mimeTypeInfo = (MIMETypeInfo)mimeTypes.get(mimeType);
- if (mimeTypeInfo == null)
- {
- return Collections.EMPTY_SET;
- }
-
- return Collections.unmodifiableSet(mimeTypeInfo.modes);
- }
-
- public Set getAllWindowStates()
- {
- return windowStates;
- }
-
- public Set getWindowStates(String mimeType)
- {
- MIMETypeInfo mimeTypeInfo = (MIMETypeInfo)mimeTypes.get(mimeType);
- if (mimeTypeInfo == null)
- {
- return Collections.EMPTY_SET;
- }
-
- return Collections.unmodifiableSet(mimeTypeInfo.windowStates);
- }
-
- public Set getAllLocales()
- {
- return locales;
- }
-
- public Set getLocales(String mimeType)
- {
- MIMETypeInfo mimeTypeInfo = (MIMETypeInfo)mimeTypes.get(mimeType);
- if (mimeTypeInfo == null)
- {
- return Collections.EMPTY_SET;
- }
-
- return Collections.unmodifiableSet(mimeTypeInfo.locales);
- }
- };
+ capabilities = new WSRPCapabilitiesInfo(mimeTypes, modes, windowStates, locales);
}
private void createMetaInfo(PortletDescription portletDescription)
@@ -283,13 +250,7 @@
}
}
- metaInfo = new MetaInfo()
- {
- public org.jboss.portal.common.util.LocalizedString getMetaValue(String key)
- {
- return (org.jboss.portal.common.util.LocalizedString)metaInfos.get(key);
- }
- };
+ metaInfo = new WSRPMetaInfo(metaInfos);
}
private org.jboss.portal.common.util.LocalizedString createPortalLocalizedStringFrom(LocalizedString wsrpLocalizedString)
@@ -395,4 +356,88 @@
return mode.toString();
}
}
+
+ private class WSRPCapabilitiesInfo implements CapabilitiesInfo
+ {
+ private final Map mimeTypes;
+ private final Set modes;
+ private final Set windowStates;
+ private final Set locales;
+
+ public WSRPCapabilitiesInfo(Map mimeTypes, Set modes, Set windowStates, Set locales)
+ {
+ this.mimeTypes = mimeTypes;
+ this.modes = modes;
+ this.windowStates = windowStates;
+ this.locales = locales;
+ }
+
+ public Set getMimeTypes()
+ {
+ return mimeTypes.keySet();
+ }
+
+ public Set getAllModes()
+ {
+ return modes;
+ }
+
+ public Set getModes(String mimeType)
+ {
+ MIMETypeInfo mimeTypeInfo = (MIMETypeInfo)mimeTypes.get(mimeType);
+ if (mimeTypeInfo == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ return Collections.unmodifiableSet(mimeTypeInfo.modes);
+ }
+
+ public Set getAllWindowStates()
+ {
+ return windowStates;
+ }
+
+ public Set getWindowStates(String mimeType)
+ {
+ MIMETypeInfo mimeTypeInfo = (MIMETypeInfo)mimeTypes.get(mimeType);
+ if (mimeTypeInfo == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ return Collections.unmodifiableSet(mimeTypeInfo.windowStates);
+ }
+
+ public Set getAllLocales()
+ {
+ return locales;
+ }
+
+ public Set getLocales(String mimeType)
+ {
+ MIMETypeInfo mimeTypeInfo = (MIMETypeInfo)mimeTypes.get(mimeType);
+ if (mimeTypeInfo == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ return Collections.unmodifiableSet(mimeTypeInfo.locales);
+ }
+ }
+
+ private static class WSRPMetaInfo implements MetaInfo
+ {
+ private final Map metaInfos;
+
+ public WSRPMetaInfo(Map metaInfos)
+ {
+ this.metaInfos = metaInfos;
+ }
+
+ public org.jboss.portal.common.util.LocalizedString getMetaValue(String key)
+ {
+ return (org.jboss.portal.common.util.LocalizedString)metaInfos.get(key);
+ }
+ }
}
19 years
JBoss Portal SVN: r5939 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/framework test/wsrp/v1/consumer test/wsrp/v1/consumer/behaviors wsrp/consumer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-28 17:58:58 -0500 (Thu, 28 Dec 2006)
New Revision: 5939
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- Added more PortletManagement tests for Consumer. One test doesn't pass since I need to hook in clone detection on the Consumer.
- Temporary fix for language when creating Properties in WSRPConsumerImpl. Need a better solution.
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 2006-12-28 02:59:43 UTC (rev 5938)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-12-28 22:58:58 UTC (rev 5939)
@@ -125,6 +125,8 @@
/** The current order in the sequence (number of times the methods have been called) */
private int sequenceOrder;
+ private PortletManagementBehavior portletManagementBehavior;
+
public static final String USER_COOKIE = "cookie";
public TestWSRPProducerImpl()
@@ -154,6 +156,7 @@
sequence = new SingleBehaviorSequence(new TestBehaviorSequence.TestBehaviorSet(new BasicServiceDescriptionBehavior()));
sequenceOrder = 0;
+ portletManagementBehavior = new BasicPortletManagementBehavior();
}
// Behavior management **********************************************************************************************
@@ -305,38 +308,44 @@
throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault, InconsistentParametersFault,
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
+ PortletDescriptionResponse response = portletManagementBehavior.getPortletDescription(getPortletDescription);
incrementBehaviorCallCount();
- return new BasicPortletManagementBehavior().getPortletDescription(getPortletDescription);
+ return response;
}
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws InvalidUserCategoryFault, AccessDeniedFault, OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault, InconsistentParametersFault, MissingParametersFault, RemoteException
{
+ PortletContext portletContext = portletManagementBehavior.clonePortlet(clonePortlet);
incrementBehaviorCallCount();
- return new BasicPortletManagementBehavior().clonePortlet(clonePortlet);
+ return portletContext;
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws InconsistentParametersFault, MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
+ DestroyPortletsResponse response = portletManagementBehavior.destroyPortlets(destroyPortlets);
incrementBehaviorCallCount();
- return null;
+ return response;
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties) throws OperationFailedFault, InvalidHandleFault, MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault, AccessDeniedFault, InvalidRegistrationFault, RemoteException
{
+ PortletContext portletContext = portletManagementBehavior.setPortletProperties(setPortletProperties);
incrementBehaviorCallCount();
- return null;
+ return portletContext;
}
public PropertyList getPortletProperties(GetPortletProperties getPortletProperties) throws InvalidHandleFault, MissingParametersFault, InvalidRegistrationFault, AccessDeniedFault, OperationFailedFault, InconsistentParametersFault, InvalidUserCategoryFault, RemoteException
{
+ PropertyList list = portletManagementBehavior.getPortletProperties(getPortletProperties);
incrementBehaviorCallCount();
- return null;
+ return list;
}
public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription) throws MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault, InvalidRegistrationFault, AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
{
+ PortletPropertyDescriptionResponse descriptionResponse = portletManagementBehavior.getPortletPropertyDescription(getPortletPropertyDescription);
incrementBehaviorCallCount();
- return null;
+ return descriptionResponse;
}
// Producer implementation ******************************************************************************************
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java 2006-12-28 02:59:43 UTC (rev 5938)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java 2006-12-28 22:58:58 UTC (rev 5939)
@@ -24,10 +24,15 @@
package org.jboss.portal.test.wsrp.v1.consumer;
import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicPortletManagementBehavior;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -46,6 +51,7 @@
PortletContext clone = consumer.createClone(original);
ExtendedAssert.assertNotNull(clone);
ExtendedAssert.assertFalse(original.equals(clone));
+ ExtendedAssert.assertEquals(BasicPortletManagementBehavior.CLONED_HANDLE, clone.getId());
Portlet originalPortlet = consumer.getPortlet(original);
Portlet clonePortlet = consumer.getPortlet(clone);
@@ -61,16 +67,52 @@
public void testGetProperties() throws Exception
{
+ PortletContext original = PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ PropertyMap props = consumer.getProperties(original);
+ checkProperties(props, BasicPortletManagementBehavior.PROPERTY_VALUE);
+ PortletContext clone = consumer.createClone(original);
+ props = consumer.getProperties(clone);
+ checkProperties(props, BasicPortletManagementBehavior.PROPERTY_VALUE);
+
+ consumer.setProperties(clone, new PropertyChange[]
+ {
+ PropertyChange.newUpdate(BasicPortletManagementBehavior.PROPERTY_NAME,
+ new StringValue(BasicPortletManagementBehavior.PROPERTY_NEW_VALUE))
+ });
+ checkProperties(consumer.getProperties(clone), BasicPortletManagementBehavior.PROPERTY_NEW_VALUE);
+
+ consumer.setProperties(clone, new PropertyChange[]
+ {
+ PropertyChange.newReset(BasicPortletManagementBehavior.PROPERTY_NAME)
+ });
+ checkProperties(consumer.getProperties(clone), BasicPortletManagementBehavior.PROPERTY_VALUE);
}
+ private void checkProperties(PropertyMap props, String expectedValue)
+ {
+ ExtendedAssert.assertNotNull(props);
+ ExtendedAssert.assertEquals(1, props.size());
+ ExtendedAssert.assertEquals(expectedValue,
+ props.getProperty(BasicPortletManagementBehavior.PROPERTY_NAME).asString());
+ }
+
public void testDestroyClones() throws Exception
{
}
- public void testSetProperties() throws Exception
+ public void testInvalidSetProperties() throws Exception
{
-
+ PortletContext original = PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ try
+ {
+ consumer.setProperties(original, null);
+ ExtendedAssert.fail("Shouldn't be possible to set properties on non-cloned portlet");
+ }
+ catch (PortletInvokerException expected)
+ {
+ //expected
+ }
}
}
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 2006-12-28 02:59:43 UTC (rev 5938)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2006-12-28 22:58:58 UTC (rev 5939)
@@ -29,6 +29,7 @@
import org.jboss.portal.wsrp.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.ClonePortlet;
import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.GetPortletProperties;
import org.jboss.portal.wsrp.core.InconsistentParametersFault;
import org.jboss.portal.wsrp.core.InvalidHandleFault;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
@@ -37,6 +38,9 @@
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+import org.jboss.portal.wsrp.core.Property;
+import org.jboss.portal.wsrp.core.PropertyList;
+import org.jboss.portal.wsrp.core.SetPortletProperties;
import java.rmi.RemoteException;
@@ -47,22 +51,25 @@
*/
public class BasicPortletManagementBehavior extends PortletManagementBehavior
{
- public static final String CLONE_SUFFIX = "_clone";
+ private static final String CLONE_SUFFIX = "_clone";
+ public static final String PROPERTY_NAME = "prop1";
+ public static final String PROPERTY_VALUE = "value1";
+ public static final String PROPERTY_NEW_VALUE = "value2";
+ public static final String CLONED_HANDLE = BasicMarkupBehavior.PORTLET_HANDLE + CLONE_SUFFIX;
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws InvalidUserCategoryFault, AccessDeniedFault,
OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault, InconsistentParametersFault,
MissingParametersFault, RemoteException
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(clonePortlet, "ClonePortlet");
- PortletContext portletContext = clonePortlet.getPortletContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "portlet context", "ClonePortlet");
- String handle = portletContext.getPortletHandle();
- if (handle == null || handle.length() == 0 || !BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ String handle = getHandleFrom(clonePortlet.getPortletContext(), "ClonePortlet");
+
+ if (!BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, null);
}
- return WSRPTypeFactory.createPortletContext(handle + CLONE_SUFFIX);
+ return WSRPTypeFactory.createPortletContext(CLONED_HANDLE);
}
@@ -71,10 +78,7 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletDescription, "GetPortletDescription");
- PortletContext portletContext = getPortletDescription.getPortletContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "portlet context", "GetPortletDescription");
- String handle = portletContext.getPortletHandle();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(handle, "portlet handle", "PortletContext");
+ String handle = getHandleFrom(getPortletDescription.getPortletContext(), "GetPortletDescription");
String suffix;
if (handle.startsWith(BasicMarkupBehavior.PORTLET_HANDLE))
@@ -92,4 +96,63 @@
}
return WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription(handle, suffix));
}
+
+ public PropertyList getPortletProperties(GetPortletProperties getPortletProperties) throws InvalidHandleFault, MissingParametersFault, InvalidRegistrationFault, AccessDeniedFault, OperationFailedFault, InconsistentParametersFault, InvalidUserCategoryFault, RemoteException
+ {
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletProperties, "GetPortletProperties");
+ String handle = getHandleFrom(getPortletProperties.getPortletContext(), "GetPortletProperties");
+ PropertyList result = WSRPTypeFactory.createPropertyList();
+ if (BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ {
+ result.setProperties(new Property[]{WSRPTypeFactory.createProperty(PROPERTY_NAME, "en", PROPERTY_VALUE)});
+ }
+ else if (CLONED_HANDLE.equals(handle))
+ {
+ if (callCount != 2)
+ {
+ result.setProperties(new Property[]{WSRPTypeFactory.createProperty(PROPERTY_NAME, "en", PROPERTY_VALUE)});
+ }
+ else
+ {
+ result.setProperties(new Property[]{WSRPTypeFactory.createProperty(PROPERTY_NAME, "en", PROPERTY_NEW_VALUE)});
+ }
+ }
+ else
+ {
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
+ new IllegalArgumentException("Unknown handle '" + handle + "'"));
+ }
+
+ incrementCallCount();
+ return result;
+ }
+
+
+ public PortletContext setPortletProperties(SetPortletProperties setPortletProperties) throws OperationFailedFault,
+ InvalidHandleFault, MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault,
+ AccessDeniedFault, InvalidRegistrationFault, RemoteException
+ {
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(setPortletProperties, "SetPortletProperties");
+ String handle = getHandleFrom(setPortletProperties.getPortletContext(), "SetPortletProperties");
+
+ if (!(CLONED_HANDLE).equals(handle))
+ {
+ throw WSRPUtils.createOperationFailedFault(new IllegalArgumentException("Cannot modify portlet '" + handle + "'"));
+ }
+
+ return setPortletProperties.getPortletContext();
+ }
+
+ private String getHandleFrom(PortletContext portletContext, String context) throws MissingParametersFault, InvalidHandleFault
+ {
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "portlet context", context);
+ String handle = portletContext.getPortletHandle();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(handle, "portlet handle", "PortletContext");
+ if (handle.length() == 0)
+ {
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, null);
+ }
+
+ return handle;
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-28 02:59:43 UTC (rev 5938)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-28 22:58:58 UTC (rev 5939)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.util.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.jems.as.system.AbstractJBossService;
@@ -85,6 +86,7 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -387,7 +389,9 @@
break;
case PropertyChange.PREF_UPDATE:
- updates.add(WSRPTypeFactory.createProperty(change.getKey(), null, change.getValue().asString())); // todo: deal with language
+ // todo: deal with language more appropriately
+ updates.add(WSRPTypeFactory.createProperty(change.getKey(),
+ LocaleInfo.getRFC3066LanguageTagFor(Locale.getDefault()), change.getValue().asString()));
break;
default:
19 years
JBoss Portal SVN: r5938 - in trunk/wsrp: . src/main/org/jboss/portal/test/wsrp/framework src/main/org/jboss/portal/test/wsrp/v1/consumer src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors src/resources/tests src/resources/tests/test-wsrp-consumer-portletmanagement-sar src/resources/tests/test-wsrp-consumer-portletmanagement-sar/META-INF
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-27 21:59:43 -0500 (Wed, 27 Dec 2006)
New Revision: 5938
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestRunner.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
trunk/wsrp/src/resources/tests/test-wsrp-consumer-portletmanagement-sar/
trunk/wsrp/src/resources/tests/test-wsrp-consumer-portletmanagement-sar/META-INF/
trunk/wsrp/src/resources/tests/test-wsrp-consumer-portletmanagement-sar/META-INF/jboss-service.xml
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
Log:
- Started adding Portlet management behavior test support.
- Started adding PortletManagement test cases for Consumer.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/build.xml 2006-12-28 02:59:43 UTC (rev 5938)
@@ -423,6 +423,9 @@
<jar jarfile="${build.lib.test}/test-wsrp-consumer-markup.sar">
<fileset dir="${build.resources.test}/test-wsrp-consumer-markup-sar" includes="**/*"/>
</jar>
+ <jar jarfile="${build.lib.test}/test-wsrp-consumer-portletmanagement.sar">
+ <fileset dir="${build.resources.test}/test-wsrp-consumer-portletmanagement-sar" includes="**/*"/>
+ </jar>
</target>
<!-- Producer tests -->
@@ -595,6 +598,7 @@
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.consumer.ServiceDescriptionTestRunner"/>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.consumer.MarkupTestRunner"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.consumer.PortletManagementTestRunner"/>
</x-test>
<x-sysproperty>
<!--
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java 2006-12-28 02:59:43 UTC (rev 5938)
@@ -23,16 +23,11 @@
package org.jboss.portal.test.wsrp.framework;
-import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
-import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.CookieProtocol;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
-import org.jboss.portal.wsrp.core.LocalizedString;
-import org.jboss.portal.wsrp.core.MarkupType;
import org.jboss.portal.wsrp.core.OperationFailedFault;
-import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
@@ -60,20 +55,6 @@
return null;
}
- protected PortletDescription createPortletDescription(String portletHandle, String suffix)
- {
- PortletDescription portletDesc = new PortletDescription();
- portletDesc.setPortletHandle(portletHandle);
- portletDesc.setMarkupTypes(new MarkupType[]{new MarkupType("text/html", new String[]{WSRPConstants.NORMAL_WINDOW_STATE},
- new String[]{WSRPConstants.VIEW_MODE}, WSRPConstants.DEFAULT_LOCALES, null)});
- portletDesc.setDescription(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_DESCRIPTION + suffix));
- portletDesc.setTitle(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_TITLE + suffix));
- portletDesc.setShortTitle(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_SHORTTITLE + suffix));
- portletDesc.setDisplayName(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_DISPLAYNAME + suffix));
- portletDesc.setKeywords(new LocalizedString[]{ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_KEYWORD + suffix)});
- return portletDesc;
- }
-
public void setRequiresRegistration(boolean requiresRegistration)
{
serviceDescription.setRequiresRegistration(requiresRegistration);
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java 2006-12-28 02:59:43 UTC (rev 5938)
@@ -23,6 +23,12 @@
package org.jboss.portal.test.wsrp.framework;
+import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.core.LocalizedString;
+import org.jboss.portal.wsrp.core.MarkupType;
+import org.jboss.portal.wsrp.core.PortletDescription;
+
/**
* Provides a base class for Producer behavior used in Consumer testing.
*
@@ -43,4 +49,18 @@
{
callCount++;
}
+
+ protected PortletDescription createPortletDescription(String portletHandle, String suffix)
+ {
+ PortletDescription portletDesc = new PortletDescription();
+ portletDesc.setPortletHandle(portletHandle);
+ portletDesc.setMarkupTypes(new MarkupType[]{new MarkupType("text/html", new String[]{WSRPConstants.NORMAL_WINDOW_STATE},
+ new String[]{WSRPConstants.VIEW_MODE}, WSRPConstants.DEFAULT_LOCALES, null)});
+ portletDesc.setDescription(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_DESCRIPTION + suffix));
+ portletDesc.setTitle(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_TITLE + suffix));
+ portletDesc.setShortTitle(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_SHORTTITLE + suffix));
+ portletDesc.setDisplayName(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_DISPLAYNAME + suffix));
+ portletDesc.setKeywords(new LocalizedString[]{ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_KEYWORD + suffix)});
+ return portletDesc;
+ }
}
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 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-12-28 02:59:43 UTC (rev 5938)
@@ -26,6 +26,7 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
+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.NullMarkupBehavior;
@@ -305,13 +306,13 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
incrementBehaviorCallCount();
- return null;
+ return new BasicPortletManagementBehavior().getPortletDescription(getPortletDescription);
}
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws InvalidUserCategoryFault, AccessDeniedFault, OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault, InconsistentParametersFault, MissingParametersFault, RemoteException
{
incrementBehaviorCallCount();
- return null;
+ return new BasicPortletManagementBehavior().clonePortlet(clonePortlet);
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws InconsistentParametersFault, MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java 2006-12-28 02:59:43 UTC (rev 5938)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * 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.test.wsrp.v1.consumer;
+
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class PortletManagementTestCase extends V1ConsumerBaseTest
+{
+ public PortletManagementTestCase() throws Exception
+ {
+ }
+
+ public void testClone() throws Exception
+ {
+ PortletContext original = PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ PortletContext clone = consumer.createClone(original);
+ ExtendedAssert.assertNotNull(clone);
+ ExtendedAssert.assertFalse(original.equals(clone));
+
+ Portlet originalPortlet = consumer.getPortlet(original);
+ Portlet clonePortlet = consumer.getPortlet(clone);
+ ExtendedAssert.assertNotNull(clonePortlet);
+ ExtendedAssert.assertFalse(originalPortlet.getContext().equals(clonePortlet.getContext()));
+
+ // information about the portlet should be the same
+ MetaInfo originalInfo = originalPortlet.getInfo().getMeta();
+ MetaInfo cloneInfo = clonePortlet.getInfo().getMeta();
+ ExtendedAssert.assertEquals(originalInfo.getMetaValue(MetaInfo.TITLE), cloneInfo.getMetaValue(MetaInfo.TITLE));
+ ExtendedAssert.assertEquals(originalInfo.getMetaValue(MetaInfo.DESCRIPTION), cloneInfo.getMetaValue(MetaInfo.DESCRIPTION));
+ }
+
+ public void testGetProperties() throws Exception
+ {
+
+ }
+
+ public void testDestroyClones() throws Exception
+ {
+
+ }
+
+ public void testSetProperties() throws Exception
+ {
+
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestRunner.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestRunner.java 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestRunner.java 2006-12-28 02:59:43 UTC (rev 5938)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.test.wsrp.v1.consumer;
+
+import org.jboss.portal.test.framework.server.runner.ServerTestRunner;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class PortletManagementTestRunner extends ServerTestRunner
+{
+ public PortletManagementTestRunner()
+ {
+ super("test-wsrp-consumer-portletmanagement.sar");
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/PortletManagementTestRunner.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: 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 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2006-12-28 02:59:43 UTC (rev 5938)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * 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.test.wsrp.v1.consumer.behaviors;
+
+import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.WSRPUtils;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.ClonePortlet;
+import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PortletContext;
+import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class BasicPortletManagementBehavior extends PortletManagementBehavior
+{
+ public static final String CLONE_SUFFIX = "_clone";
+
+ public PortletContext clonePortlet(ClonePortlet clonePortlet) throws InvalidUserCategoryFault, AccessDeniedFault,
+ OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault, InconsistentParametersFault,
+ MissingParametersFault, RemoteException
+ {
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(clonePortlet, "ClonePortlet");
+ PortletContext portletContext = clonePortlet.getPortletContext();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "portlet context", "ClonePortlet");
+ String handle = portletContext.getPortletHandle();
+ if (handle == null || handle.length() == 0 || !BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ {
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, null);
+ }
+
+ return WSRPTypeFactory.createPortletContext(handle + CLONE_SUFFIX);
+ }
+
+
+ public PortletDescriptionResponse getPortletDescription(GetPortletDescription getPortletDescription)
+ throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault, InconsistentParametersFault,
+ MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
+ {
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletDescription, "GetPortletDescription");
+ PortletContext portletContext = getPortletDescription.getPortletContext();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "portlet context", "GetPortletDescription");
+ String handle = portletContext.getPortletHandle();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(handle, "portlet handle", "PortletContext");
+
+ String suffix;
+ if (handle.startsWith(BasicMarkupBehavior.PORTLET_HANDLE))
+ {
+ suffix = "";
+ }
+ else if (handle.startsWith(SessionMarkupBehavior.PORTLET_HANDLE))
+ {
+ suffix = "2";
+ }
+ else
+ {
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
+ new IllegalArgumentException("Unknown handle '" + handle + "'"));
+ }
+ return WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription(handle, suffix));
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/wsrp/src/resources/tests/test-wsrp-consumer-portletmanagement-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-wsrp-consumer-portletmanagement-sar/META-INF/jboss-service.xml 2006-12-28 02:58:09 UTC (rev 5937)
+++ trunk/wsrp/src/resources/tests/test-wsrp-consumer-portletmanagement-sar/META-INF/jboss-service.xml 2006-12-28 02:59:43 UTC (rev 5938)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<server>
+ <mbean
+ code="org.jboss.portal.test.wsrp.v1.consumer.PortletManagementTestCase"
+ name="portal.test:test=PortletManagement"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="TestDriverRegistry" proxy-type="attribute">portal.test:service=HttpTestDriverServer</depends>
+ <depends optional-attribute-name="Consumer" proxy-type="attribute">portal.wsrp:service=WSRPConsumer</depends>
+ <depends optional-attribute-name="Producer" proxy-type="attribute">portal.wsrp:service=WSRPProducer</depends>
+ </mbean>
+</server>
19 years
JBoss Portal SVN: r5937 - trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-27 21:58:09 -0500 (Wed, 27 Dec 2006)
New Revision: 5937
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- Now try to protect every method with an initialization of the producer. This could be optimized if we could detect producer changes...
- getPortlet now uses getPortletDescription if there's a cache miss.
- Renamed registerIfNeeded to initializeProducerInteractionAndRegisterIfPossible.
- Renamed checkRegistrationDataAgainstInitialServiceDescription to examineProducerMetadataAndGetRegistrationDataIfPossible.
- Now uses a special RegistrationData to specify that the associated producer didn't need registration.
- Minor other changes.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-28 02:35:15 UTC (rev 5936)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-28 02:58:09 UTC (rev 5937)
@@ -52,11 +52,14 @@
import org.jboss.portal.wsrp.core.DestroyFailed;
import org.jboss.portal.wsrp.core.DestroyPortlets;
import org.jboss.portal.wsrp.core.DestroyPortletsResponse;
+import org.jboss.portal.wsrp.core.GetPortletDescription;
import org.jboss.portal.wsrp.core.GetPortletProperties;
import org.jboss.portal.wsrp.core.GetServiceDescription;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
import org.jboss.portal.wsrp.core.LocalizedString;
import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.PortletDescription;
+import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.PropertyList;
@@ -132,6 +135,16 @@
/** The registration data used to register this consumer with the associated producer */
private RegistrationData registrationData;
+ /** A registration data element used to indicate when no registration was required by the producer */
+ private final static RegistrationData REGISTRATION_NOT_NEEDED = WSRPTypeFactory.createDefaultRegistrationData();
+
+ static
+ {
+ REGISTRATION_NOT_NEEDED.setConsumerAgent("INVALID AGENT");
+ REGISTRATION_NOT_NEEDED.setConsumerName("INVALID NAME");
+ REGISTRATION_NOT_NEEDED.setRegistrationProperties(null);
+ }
+
/** The default user scopes as per the specification (6.1.4) */
private static final Set WSRP_DEFAULT_USER_SCOPE = new HashSet(2);
@@ -176,28 +189,60 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletId, "portlet id", "PortletContext");
- Map portlets;
- try
+ Portlet portlet;
+
+ // if cache is still valid, use information from cached service description
+ if (useCache() && !isCacheExpired())
{
- portlets = getPortletMap();
+ log.debug("getPortlet from cached service description");
+ Map portlets;
+ try
+ {
+ portlets = getPortletMap();
+ }
+ catch (ServiceDescriptionUnavailableException e)
+ {
+ throw new InvokerUnavailableException(e.getMessage(), e.getCause());
+ }
+
+ portlet = (Portlet)portlets.get(portletId);
}
- catch (ServiceDescriptionUnavailableException e)
+ else // otherwise, retrieve just the information for the appropriate portlet
{
- throw new InvokerUnavailableException(e.getMessage(), e.getCause());
+ log.debug("getPortlet via getPortletDescription");
+ initializeProducerInteractionAndRegisterIfPossible();
+ GetPortletDescription gpd = WSRPTypeFactory.createGetPortletDescription(registrationContext, portletId);
+ gpd.setUserContext(null); // todo: deal with user context!!
+ try
+ {
+ PortletDescriptionResponse response = getPortletManagementService().getPortletDescription(gpd);
+ ParameterValidation.throwIllegalArgExceptionIfNull(response, "PortletDescriptionResponse");
+ portlet = createWSRPPortletFromPortletDescription(response.getPortletDescription());
+ }
+ catch (InvalidHandleFault invalidHandleFault)
+ {
+ throw new NoSuchPortletException(invalidHandleFault, portletId);
+ }
+ catch (Exception e)
+ {
+ throw new InvokerUnavailableException("Couldn't access remote producer '" + producerId + "'", e);
+ }
}
- Portlet portlet = (Portlet)portlets.get(portletId);
if (portlet == null)
{
throw new NoSuchPortletException(portletId);
}
-
- return portlet;
+ else
+ {
+ return portlet;
+ }
}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
{
InvocationHandler handler;
+ initializeProducerInteractionAndRegisterIfPossible();
if (invocation instanceof RenderInvocation)
{
@@ -219,7 +264,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
- registerIfNeeded();
+ initializeProducerInteractionAndRegisterIfPossible();
// todo: deal with user context
ClonePortlet clonePortlet = WSRPTypeFactory.createClonePortlet(registrationContext,
@@ -238,7 +283,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletIds, "Portlet identifiers");
- registerIfNeeded();
+ initializeProducerInteractionAndRegisterIfPossible();
DestroyPortlets destroyPortlets = WSRPTypeFactory.createDestroyPortlets(registrationContext,
(String[])portletIds.toArray(new String[0]));
@@ -279,7 +324,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
- registerIfNeeded();
+ initializeProducerInteractionAndRegisterIfPossible();
GetPortletProperties getPortletProperties = WSRPTypeFactory.createGetPortletProperties(registrationContext, portletContext.getId());
getPortletProperties.setNames(keys);
@@ -326,7 +371,7 @@
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(changes, "Property changes");
- registerIfNeeded();
+ initializeProducerInteractionAndRegisterIfPossible();
PropertyList propertyList = WSRPTypeFactory.createPropertyList();
int changesNumber = changes.length;
@@ -460,42 +505,12 @@
for (int i = 0; i < length; i++)
{
PortletDescription portletDescription = portletDescriptions[i];
- String portletHandle = portletDescription.getPortletHandle();
+ WSRPPortlet wsrpPortlet = createWSRPPortletFromPortletDescription(portletDescription);
- log.debug("Extracting info for '" + portletHandle + "' portlet");
- WSRPPortletInfo info = new WSRPPortletInfo(portletDescription);
- if (info.isUsesMethodGet())
+ if (wsrpPortlet != null)
{
- log.warn("Portlet '" + portletHandle
- + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
- "the list of offered portlets for producer " + getProducerId());
+ portlets.put(wsrpPortlet.getContext().getId(), wsrpPortlet);
}
- else if (info.isHasUserSpecificState())
- {
- log.warn("Portlet '" + portletHandle
- + "' will store persistent state for each user. To be handled properly, this would require " +
- "supporting portlet cloning, which we don't currently do. This portlet will be excluded from the " +
- "list of offered portlets for producer " + getProducerId());
- }
- else
- {
- WSRPPortlet wsrpPortlet = new WSRPPortlet(portletHandle, info);
-
- // add the portlet to the appropriate group if needed
- String portletGroupId = portletDescription.getGroupID();
- if (portletGroupId != null)
- {
- Set groupedPortlets = (Set)portletGroups.get(portletGroupId);
- if (groupedPortlets == null)
- {
- groupedPortlets = new HashSet();
- portletGroups.put(portletGroupId, groupedPortlets);
- }
- groupedPortlets.add(wsrpPortlet);
- }
-
- portlets.put(portletHandle, wsrpPortlet);
- }
}
return portlets;
@@ -506,6 +521,51 @@
}
}
+ /**
+ * @param portletDescription
+ * @return
+ * @since 2.6
+ */
+ private WSRPPortlet createWSRPPortletFromPortletDescription(PortletDescription portletDescription)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletDescription, "PortletDescription");
+ String portletHandle = portletDescription.getPortletHandle();
+ log.debug("Extracting info for '" + portletHandle + "' portlet");
+ WSRPPortletInfo info = new WSRPPortletInfo(portletDescription);
+ WSRPPortlet wsrpPortlet = null;
+ if (info.isUsesMethodGet())
+ {
+ log.warn("Portlet '" + portletHandle
+ + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
+ "the list of offered portlets for producer " + getProducerId());
+ }
+ else if (info.isHasUserSpecificState())
+ {
+ log.warn("Portlet '" + portletHandle
+ + "' will store persistent state for each user. To be handled properly, this would require " +
+ "supporting portlet cloning, which we don't currently do. This portlet will be excluded from the " +
+ "list of offered portlets for producer " + getProducerId());
+ }
+ else
+ {
+ wsrpPortlet = new WSRPPortlet(portletHandle, info);
+
+ // add the portlet to the appropriate group if needed
+ String portletGroupId = portletDescription.getGroupID();
+ if (portletGroupId != null)
+ {
+ Set groupedPortlets = (Set)portletGroups.get(portletGroupId);
+ if (groupedPortlets == null)
+ {
+ groupedPortlets = new HashSet();
+ portletGroups.put(portletGroupId, groupedPortlets);
+ }
+ groupedPortlets.add(wsrpPortlet);
+ }
+ }
+ return wsrpPortlet;
+ }
+
// Cache support ****************************************************************************************************
private boolean useCache()
@@ -516,7 +576,7 @@
private void updateCachesIfNeeded()
throws ServiceDescriptionUnavailableException, PortletInvokerException
{
- if (System.currentTimeMillis() > expirationTimeMillis || cachedPortletMap == null || portletGroups == null)
+ if (isCacheExpired())
{
cachedPortletMap = extractOfferedPortlets(getServiceDescriptionAndRegisterIfNeeded());
@@ -525,6 +585,15 @@
}
}
+ /**
+ * @return
+ * @since 2.6
+ */
+ private boolean isCacheExpired()
+ {
+ return System.currentTimeMillis() > expirationTimeMillis || cachedPortletMap == null || portletGroups == null;
+ }
+
public Integer getExpirationCacheSeconds()
{
return expirationCacheSeconds;
@@ -559,7 +628,7 @@
// reset registration data and try again
resetRegistration();
- registerIfNeeded();
+ initializeProducerInteractionAndRegisterIfPossible();
}
RegistrationContext getRegistrationContext()
@@ -648,7 +717,7 @@
private ServiceDescription getServiceDescriptionAndRegisterIfNeeded() throws ServiceDescriptionUnavailableException, PortletInvokerException
{
// try initial registration if needed
- registerIfNeeded();
+ initializeProducerInteractionAndRegisterIfPossible();
GetServiceDescription request = getServiceDescriptionRequest();
request.setRegistrationContext(registrationContext);
@@ -661,9 +730,6 @@
if (serviceDescription != null)
{
- // do we need to call initCookie or not?
- sessionHandler.setRequiresInitCookie(serviceDescription.getRequiresInitCookie());
-
// from now on (that is until getServiceDescription fails) use this successful request
setServiceDescriptionRequest(request);
return serviceDescription;
@@ -684,61 +750,59 @@
}
/**
- * Attempts to register if our producer configuration provides registration data and we don't have a valid
- * RegistrationContext yet.
+ * Examine the producer's metadata and attempts to register if required by the producer and possible.
*
* @throws org.jboss.portal.portlet.PortletInvokerException
*
* @since 2.6
*/
- private void registerIfNeeded() throws PortletInvokerException
+ private void initializeProducerInteractionAndRegisterIfPossible() throws PortletInvokerException
{
- // no registrationContext = we might need to register
- if (registrationContext == null)
+ // this could be optimized if we could ensure that the service description hadn't changed
+ // in particular with consumer.MarkupTestCase.testInitCookie, we change the cookie requirements
+ // and we need to be able to detect it... :( todo: use extensions for JBoss to JBoss?
+ ServiceDescription serviceDescription = getMinimalServiceDescription();
+
+ // do we need to call initCookie or not?
+ sessionHandler.setRequiresInitCookie(serviceDescription.getRequiresInitCookie());
+
+ //todo: could extract more information here...
+
+ // no registrationContext and the producer didn't already indicate that it didn't require registration
+ if (registrationContext == null && !REGISTRATION_NOT_NEEDED.equals(registrationData))
{
- // we don't have any registration data, check if need one and inform user if needed
- if (registrationData == null)
- {
- checkRegistrationDataAgainstInitialServiceDescription();
- }
+ examineProducerMetadataAndGetRegistrationDataIfPossible(serviceDescription);
- try
+ if (!REGISTRATION_NOT_NEEDED.equals(registrationData))
{
- registrationContext = getRegistrationService().register(registrationData);
- if (registrationContext == null)
+ try
{
- throw new PortletInvokerException("Received null response from producer '" + producerId + "'");
+ registrationContext = getRegistrationService().register(registrationData);
+ if (registrationContext == null)
+ {
+ throw new PortletInvokerException("Received null response from producer '" + producerId + "'");
+ }
+
+ log.info("Successfully registered with handle: '" + registrationContext.getRegistrationHandle() + "'");
}
-
- log.info("Successfully registered with handle: '" + registrationContext.getRegistrationHandle() + "'");
+ catch (Exception e)
+ {
+ resetRegistration();
+ throw new PortletInvokerException("Couldn't register with producer '" + producerId + "'", e);
+ }
}
- catch (Exception e)
- {
- resetRegistration();
- throw new PortletInvokerException("Couldn't register with producer '" + producerId + "'", e);
- }
}
}
/**
+ * @param serviceDescription
* @throws ServiceDescriptionUnavailableException
*
* @throws PortletInvokerException
* @since 2.6
*/
- private void checkRegistrationDataAgainstInitialServiceDescription() throws PortletInvokerException
+ private void examineProducerMetadataAndGetRegistrationDataIfPossible(ServiceDescription serviceDescription) throws PortletInvokerException
{
- ServiceDescription serviceDescription;
- try
- {
- serviceDescription = getServiceDescriptionService().getServiceDescription(getUnregisteredServiceDescriptionRequest());
- }
- catch (Exception e)
- {
- throw new PortletInvokerException("Couldn't access service description for producer '"
- + getProducerId() + "'", e);
- }
-
if (serviceDescription.isRequiresRegistration())
{
StringBuffer message = new StringBuffer("Producer '").append(producerId)
@@ -807,8 +871,34 @@
registrationData = WSRPTypeFactory.createDefaultRegistrationData();
}
}
+ else
+ {
+ // the producer doesn't need registration, let this consumer know for future reference
+ registrationData = REGISTRATION_NOT_NEEDED;
+ }
}
+ /**
+ * @return
+ * @throws PortletInvokerException
+ * @since 2.6
+ */
+ private ServiceDescription getMinimalServiceDescription()
+ throws PortletInvokerException
+ {
+ ServiceDescription serviceDescription;
+ try
+ {
+ serviceDescription = getServiceDescriptionService().getServiceDescription(getUnregisteredServiceDescriptionRequest());
+ }
+ catch (Exception e)
+ {
+ throw new PortletInvokerException("Couldn't access service description for producer '"
+ + getProducerId() + "'", e);
+ }
+ return serviceDescription;
+ }
+
/** @since 2.6 */
private void resetRegistration()
{
19 years
JBoss Portal SVN: r5936 - trunk/common/src/main/org/jboss/portal/common/util
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-27 21:35:15 -0500 (Wed, 27 Dec 2006)
New Revision: 5936
Modified:
trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java
Log:
Added equals and hashCode methods (minimally tested).
Modified: trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java 2006-12-27 01:02:13 UTC (rev 5935)
+++ trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java 2006-12-28 02:35:15 UTC (rev 5936)
@@ -24,11 +24,11 @@
import org.jboss.logging.Logger;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
-import java.util.Collections;
/**
* An immutable localized string.
@@ -52,7 +52,7 @@
/**
* Convenience constructor for simple localized strings with only one value using the default locale.
*
- * @param defaultValue the localized value using the specified default locale
+ * @param defaultValue the localized value using the specified default locale
* @param defaultLocale the default locale
* @since 2.4
*/
@@ -229,9 +229,7 @@
}
}
- /**
- * Return the default locale of this description.
- */
+ /** Return the default locale of this description. */
public Locale getDefaultLocale()
{
return defaultLocale;
@@ -240,12 +238,11 @@
/**
* Retrieves the localized value most appropriate based on the given desired locales.
*
- * @param desiredLocales an array of compound language tags (as defined by
- * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>) ordered according to
- * locale preferences.
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
* @return the most appropriate localized value based on locale preferences.
- * @throws IllegalArgumentException if the array is null or one of the array string
- * is null or invalid (see #getLocaleFromRFC3066LanguageTag(String))
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see
+ * #getLocaleFromRFC3066LanguageTag(String))
* @since 2.4
*/
public String getMostAppropriateValueFor(String[] desiredLocales) throws IllegalArgumentException
@@ -258,13 +255,12 @@
* Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered
* according to locale preferences.
*
- * @param desiredLocales an array of compound language tags (as defined by
- * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>) ordered according to
- * locale preferences.
- * @return a Map.Entry representing the most appropriate mapping between Locale and
- * localized value, based on locale preferences.
- * @throws IllegalArgumentException if the array is null or one of the array string
- * is null or invalid (see {@link LocaleInfo#decodeLocaleInfoFromRFC3066LanguageTag(String)}
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale
+ * preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see {@link
+ * LocaleInfo#decodeLocaleInfoFromRFC3066LanguageTag(String)}
* @since 2.4
*/
public Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
@@ -323,9 +319,7 @@
return value;
}
- /**
- * A localized value.
- */
+ /** A localized value. */
public static class Value
{
@@ -357,4 +351,30 @@
{
return "LocalizedString: '" + getMostAppropriateValueFor(new String[0]) + "' default: " + getDefaultLocale();
}
+
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ LocalizedString that = (LocalizedString)o;
+
+ return getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]))
+ && defaultLocale.equals(that.defaultLocale);
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = getMostAppropriateValueFor(new String[0]).hashCode();
+ result = 31 * result + defaultLocale.hashCode();
+ return result;
+ }
}
19 years
JBoss Portal SVN: r5935 - trunk/wsrp/src/resources/portal-wsrp-sar
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-26 20:02:13 -0500 (Tue, 26 Dec 2006)
New Revision: 5935
Modified:
trunk/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml
Log:
Reverted deployment of consumers for public producers (committed by mistake).
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml 2006-12-26 00:11:17 UTC (rev 5934)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml 2006-12-27 01:02:13 UTC (rev 5935)
@@ -40,7 +40,7 @@
<registration-data/>
</wsrp-producer>
</deployment>
- <deployment>
+ <!--<deployment>
<wsrp-producer>
<producer-id>NetUnity</producer-id>
<expiration-cache>120</expiration-cache>
@@ -88,5 +88,5 @@
<endpoint-wsdl-url>http://portalstandards.oracle.com/portletapp/portlets?WSDL</endpoint-wsdl-url>
<registration-data/>
</wsrp-producer>
- </deployment>
+ </deployment>-->
</deployments>
\ No newline at end of file
19 years
JBoss Portal SVN: r5934 - docs/trunk/referenceGuide/en/modules
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-25 19:11:17 -0500 (Mon, 25 Dec 2006)
New Revision: 5934
Modified:
docs/trunk/referenceGuide/en/modules/security.xml
Log:
added some security documentation in 2.6 docs
Modified: docs/trunk/referenceGuide/en/modules/security.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/security.xml 2006-12-23 12:45:48 UTC (rev 5933)
+++ docs/trunk/referenceGuide/en/modules/security.xml 2006-12-26 00:11:17 UTC (rev 5934)
@@ -6,6 +6,11 @@
<surname>Russo</surname>
<email>roy(a)jboss.org</email>
</author>
+ <author>
+ <firstname>Julien</firstname>
+ <surname>Viet</surname>
+ <email>julien(a)jboss.org</email>
+ </author>
</chapterinfo>
<title>Security</title>
<sect1 id="securing_objects">
@@ -104,4 +109,180 @@
<xref linkend="desc_example_portal"/>
</para>
</sect1>
+
+ <sect1 id="security_authentication">
+ <title>Authentication with JBoss Portal</title>
+ <para>JBoss Portal relies on Java EE for the authentication of users. The Java EE authentication has its advantages
+ and drawbacks. The main motivation for using Java EE security is the integration with the application server and the
+ operational environment in which the portal is deployed. The servlet layer provides already the authentication functionnality
+ and obviously it is not a responsibility of the portal. Whenever a user is authenticated by the servlet layer
+ its security identity is propagated throughout the call stack in the different layers of the Java EE stack. The weaknesses
+ are the lack of an explicit logout mechanism and the lack of dynamicity in the mapping of URL as security resources. However
+ JBoss Portal improves that behavior when it is possible to do so.</para>
+ <sect2>
+ <title>Authentication configuration</title>
+ <para>JBoss Portal can be seen before all as a web application and therefore inherits all the configuration mechanisms
+ related to web applications. The main entry point of the whole portal is the <emphasis>jboss-portal.sar/portal-server.war</emphasis>
+ deployment which is the web application that defines and maps the portal servlet. Here you can configure various things
+ <itemizedlist>
+ <listitem>In the <emphasis>WEB-INF/web.xml</emphasis> you can change the authentication mode. The default
+ authentication mechanism uses the form based authentication, however you can change it to any of the
+ mechanism provided by the servlet specification.</listitem>
+ <listitem>In the <emphasis>WEB-INF/jboss-web.xml</emphasis> you can change the security domain used by the portal.
+ The default security domain used by the portal is <emphasis>java:/jaas/portal</emphasis>. That setting is specific
+ to the JBoss Application Server and how it binds the Java EE security to the operational environment. A security domain
+ is a scope defined at the Application Server Level and defines usually a JAAS authentication stack. The portal
+ security domain authentication stack is defined in the <emphasis>jboss-portal.sar/conf/login-config.xml</emphasis>
+ and is dynamically deployed with the portal. The JBoss Application Server documentation is certainly the best
+ reference for that topic.
+ </listitem>
+ <listitem>The files <emphasis>login.jsp</emphasis> and <emphasis>error.jsp</emphasis> provide the pages used
+ the form based authentication process. More information can be found in any good servlet documentation.</listitem>
+ </itemizedlist>
+ </para>
+ </sect2>
+ <sect2>
+ <title>The portal servlet</title>
+ <para>The portal defines a single servlet to take care of all portal requests. The class name of that servlet is
+ <emphasis>org.jboss.portal.server.servlet.PortalServlet</emphasis>. That servlet needs to be declared two times with different
+ configurations otherwise the portal would not be able to know about some request details which are importants.
+ <itemizedlist>
+ <listitem><emphasis>PortalServletWithPathMapping</emphasis> is used for path mapping mappings.</listitem>
+ <listitem><emphasis>PortalServletWithDefaultServletMapping</emphasis> is used for the default servlet mapping.</listitem>
+ </itemizedlist>
+ The portal servlet is mapped for times with different semantics, the differences between the semantics are related to the transport layer.
+ Each one of those for mappings will have the same request meaning for the portal beside the transport aspect. By default
+ those mappings are
+ <itemizedlist>
+ <listitem><emphasis>/*</emphasis> : the default access, does not define any security constraint. This is the default
+ access that everybody uses.</listitem>
+ <listitem><emphasis>/sec/*</emphasis> : the secured access, requires https usage. It is triggered when
+ a portlet is defined as secure or when a secure portlet link is created. It requires the configuration
+ of the https connector in JBoss Web. The JBoss Application Server documentation provides more information
+ about it.</listitem>
+ <listitem><emphasis>/auth/*</emphasis> : the authenticated access, requires the user to be authenticated
+ to be used.</listitem>
+ <listitem>/authsec/*<emphasis></emphasis> : combine thet two previous options into a single one.</listitem>
+ </itemizedlist>
+ Usually ones should not care much about those mappings as the portal will by itself switch to the most appropriate mapping.
+ </para>
+ </sect2>
+ </sect1>
+
+ <sect1 id="security_authorization">
+ <title>Authorization with JBoss Portal</title>
+ <para>JBoss Portal defines a framework for authorization. The default implementation of that framework is based on
+ the Java Authorization Contract for Containers (JACC) which is implemented by J2EE 1.4 Application Servers. This section of
+ the documentation focuses on defining the framework and its usage and is not an attempt to define what authorization
+ is or is not because it is out of scope of this context. Instead we will try to straightforwardly describe the
+ framework and how it is used. No specific knowledge is expected about JACC although it is a recommanded read.</para>
+ <sect2>
+ <title>The portal permission</title>
+ <para>The <emphasis>org.jboss.portal.security.PortalPermission</emphasis> object is used to describe a permission for the portal. It extends the <emphasis>java.security.Permission</emphasis>
+ class and any permission checked in the portal should extend the <emphasis>PortalPermission</emphasis> as well. That permission
+ adds two fields to the <emphasis>Permission</emphasis> class
+ <itemizedlist>
+ <listitem>uri : is a string which represents an URI of the resource described by the permission.</listitem>
+ <listitem>collection : an object of class <emphasis>org.jboss.portal.security.PortalPermissionCollection</emphasis> which
+ is used when the permission act as a container for other permissions. If that object exists then the uri field should be null
+ as a portal permission represents an uri or acts as a container in an exclusive manner.</listitem>
+ </itemizedlist>
+ </para>
+ </sect2>
+ <sect2>
+ <title>The authorization provider</title>
+ <para>
+ The <emphasis>org.jboss.portal.security.spi.provider.AuthorizationDomain</emphasis> is an interface which provides access to several services.
+ <programlisting>
+ public interface AuthorizationDomain
+ {
+ String getType();
+ DomainConfigurator getConfigurator();
+ PermissionRepository getPermissionRepository();
+ PermissionFactory getPermissionFactory();
+ }
+ </programlisting>
+ <itemizedlist>
+ <listitem><emphasis>org.jboss.portal.security.spi.provider.DomainConfigurator</emphasis> provides configuration access
+ to an authorization domain. The authorization schema is very simple as it consists of bindings between URI, roles and permissions.</listitem>
+ <listitem><emphasis>org.jboss.portal.security.spi.provider.PermissionRepository</emphasis> provides runtime access to the authorization
+ domain. Usually it is used to retrieves the permissions for a specific role and URI. It is used at runtime by the framework
+ to take security decisions.</listitem>
+ <listitem><emphasis>org.jboss.portal.security.spi.provider.PermissionFactory</emphasis> is a factory to instantiate permissions
+ for the specific domain. It is used at runtime to create permissions objects of the appropriate type by the security framework.</listitem>
+ </itemizedlist>
+ </para>
+ </sect2>
+ <sect2>
+ </sect2>
+ <sect2>
+ <title>Making a programmatic security check</title>
+ <para>Making a security check is an easy thing as it consists in created a permission of the appropriate type and
+ make a check against the <emphasis>org.jboss.portal.spi.auth.PortalAuthorizationManager</emphasis> service. That
+ service is used by the portal to make security checks. It is connected to the different authorization providers
+ in order to take decisions at runtime based on the type of the permission. Access to that service is done
+ through the <emphasis>org.jboss.portal.spi.auth.PortalAuthorizationManagerFactory</emphasis>. The factory
+ is a portal service which is usually injected in other services like that</para>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ ...
+ <mbean
+ code='MyService"
+ name="portal:service=MyService">
+ <depends
+ optional-attribute-name="PortalAuthorizationManagerFactory"
+ proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
+ ...
+ </mbean>
+ ...
+</server>]]>
+ </programlisting>
+ <para>It be injected in the servlet context of a war file in the file <emphasis>WEB-INF/jboss-portlet.xml</emphasis></para>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app>
+ ...
+ <service>
+ <service-name>PortalAuthorizationManagerFactory</service-name>
+ <service-class>org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory</service-class>
+ <service-ref>:service=PortalAuthorizationManagerFactory</service-ref>
+ </service>
+ ...
+</portlet-app>]]>
+ </programlisting>
+ <para>Here is an example of how a security check is made for a specific page</para>
+ <programlisting>
+PortalAuthorizationManager pam = factory.getManager();
+PortalObjectId id = page.getId();
+PortalObjectPermission perm = new PortalObjectPermission(id, PortalObjectPermission.VIEW_MASK);
+if (pam.checkPermission(perm) == false)
+{
+ System.out.println("Current is not authorization to view page " + id);
+}
+ </programlisting>
+ </sect2>
+ <sect2>
+ <title>Configuring an authorization domain</title>
+ <para>Configuring a domain can be done through the <emphasis>DomainConfigurator</emphasis> interface</para>
+ <programlisting>
+ public interface DomainConfigurator
+ {
+ Set getSecurityBindings(String uri);
+ void setSecurityBindings(String uri, Set securityBindings) throws SecurityConfigurationException;
+ void removeSecurityBindings(String uri) throws SecurityConfigurationException;
+ }
+ </programlisting>
+ <para>The various methods of that interface allows to configure security bindings for a given resource where
+ a resource is naturally identified by an URI. The <emphasis>org.jboss.portal.security.RoleSecurityBinding</emphasis>
+ object is an object which encapsulate a role name and a set of actions bound to this role.
+ </para>
+ <programlisting>
+RoleSecurityBinding binding1 = new RoleSecurityBinding(Collections.singleton("view"), "Admin");
+RoleSecurityBinding binding2 = new RoleSecurityBinding(Collections.singleton("view"), "User");
+Set bindings = new HashSet();
+bindings.add(binding1);
+bindings.add(binding2);
+configurator.setSecurityBinding(pageURI, bindings);
+ </programlisting>
+ </sect2>
+ </sect1>
</chapter>
\ No newline at end of file
19 years
JBoss Portal SVN: r5933 - trunk/identity/src/main/org/jboss/portal/identity
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-12-23 07:45:48 -0500 (Sat, 23 Dec 2006)
New Revision: 5933
Modified:
trunk/identity/src/main/org/jboss/portal/identity/User.java
Log:
- correct User constants
Modified: trunk/identity/src/main/org/jboss/portal/identity/User.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/User.java 2006-12-23 00:24:47 UTC (rev 5932)
+++ trunk/identity/src/main/org/jboss/portal/identity/User.java 2006-12-23 12:45:48 UTC (rev 5933)
@@ -38,8 +38,8 @@
*/
public interface User
{
- public static final String INFO_USER_NAME_GIVEN = "portal.user.name.given";
- public static final String INFO_USER_NAME_FAMILY = "portal.user.name.family";
+ public static final String INFO_USER_NAME_GIVEN = P3PConstants.INFO_USER_NAME_GIVEN;
+ public static final String INFO_USER_NAME_FAMILY = P3PConstants.INFO_USER_NAME_FAMILY;
public static final String INFO_USER_LOCATION = "portal.user.location";
public static final String INFO_USER_OCCUPATION = "portal.user.occupation";
public static final String INFO_USER_EXTRA = "portal.user.extra";
19 years
JBoss Portal SVN: r5932 - in trunk/wsrp/src/main/org/jboss/portal/wsrp: deployment endpoints services
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-22 19:24:47 -0500 (Fri, 22 Dec 2006)
New Revision: 5932
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
Log:
- JBPORTAL-1169: Improve handling of unavailable producers when deploying -wsrp.xml files.
- As a consequence, ServiceFactories should now provide better validation of input data.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.wsrp.deployment;
+import org.jboss.logging.Logger;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.consumer.WSRPConsumerImpl;
import org.jboss.portal.wsrp.core.Property;
@@ -46,6 +47,7 @@
*/
public class WSRPDeploymentFactory implements ObjectModelFactory
{
+ private final Logger log = Logger.getLogger(getClass());
private static final boolean DEBUG = false;
/** . */
@@ -304,6 +306,15 @@
System.out.println("addchild deployment service " + localName);
}
- deployment.getServices().add(service);
+ if (service.getConsumer().getServiceFactory().isAvailable())
+ {
+ log.info("Added consumer for producer '" + service.getId() + "'");
+ deployment.getServices().add(service);
+ }
+ else
+ {
+ log.info("There was a problem initializing the WSRP interface for producer '"
+ + service.getId() + "'. The consumer will NOT be available.");
+ }
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -41,14 +41,6 @@
public void init(Object object) throws ServiceException
{
context = (ServletEndpointContext)object; // per init javadoc
-
- /*
- // put the request and response in ServletAccess... not working, using a filter for now
- MessageContext messageContext = context.getMessageContext();
- HttpServletRequest request = (HttpServletRequest)messageContext.getProperty("transport.http.servletRequest");
- HttpServletResponse response = (HttpServletResponse)messageContext.getProperty("transport.http.servletResponse");
- ServletAccess.setRequestAndResponse(request, response);
- */
}
public void destroy()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -85,6 +85,11 @@
throw new IllegalArgumentException("Null class not accepted to perform lookup");
}
+ if (!isAvailable())
+ {
+ throw new IllegalStateException("This ServiceFactory is not ready to service clients!");
+ }
+
//
String key = serviceClass.getName();
if (!portJNDIMapping.containsKey(key))
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -76,4 +76,10 @@
{
this.delegate = delegate;
}
+
+
+ public boolean isAvailable()
+ {
+ return delegate != null && delegate.isAvailable();
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.wsrp.services;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
@@ -58,6 +59,7 @@
public void setServiceDescriptionURL(String serviceDescriptionURL)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(serviceDescriptionURL, "Mandatory Service Description interface", null);
this.serviceDescriptionURL = serviceDescriptionURL;
}
@@ -68,6 +70,7 @@
public void setMarkupURL(String markupURL)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(markupURL, "Mandatory Markup interface", null);
this.markupURL = markupURL;
}
@@ -99,13 +102,16 @@
//
String portAddress = null;
+ boolean isMandatoryInterface = false;
if (WSRP_v1_ServiceDescription_PortType.class.equals(serviceClass))
{
portAddress = serviceDescriptionURL;
+ isMandatoryInterface = true;
}
else if (WSRP_v1_Markup_PortType.class.equals(serviceClass))
{
portAddress = markupURL;
+ isMandatoryInterface = true;
}
else if (WSRP_v1_Registration_PortType.class.equals(serviceClass))
{
@@ -124,11 +130,25 @@
}
else
{
- throw new IllegalStateException("Service URLs were not properly initialized: no proper service URL for "
- + serviceClass.getName());
+ if (isMandatoryInterface)
+ {
+ throw new IllegalStateException("Mandatory interface URLs were not properly initialized: no proper service URL for "
+ + serviceClass.getName());
+ }
+ else
+ {
+ throw new IllegalStateException("No URL was provided for optional interface "
+ + serviceClass.getName());
+ }
}
//
return stub;
}
+
+
+ public boolean isAvailable()
+ {
+ return markupURL != null && serviceDescriptionURL != null;
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -45,4 +45,10 @@
portJNDIMapping.put(WSRP_v1_Registration_PortType.class.getName(), "wsrp/invoker/RegistrationService");
portJNDIMapping.put(WSRP_v1_PortletManagement_PortType.class.getName(), "wsrp/invoker/PortletManagementService");
}
+
+
+ public boolean isAvailable()
+ {
+ return true;
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -69,7 +69,7 @@
return wsdlDefinitionURL;
}
- public void setWsdlDefinitionURL(String wsdlDefinitionURL)
+ public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws RuntimeException
{
if (wsdlDefinitionURL == null || wsdlDefinitionURL.length() == 0)
{
@@ -102,9 +102,9 @@
iae.initCause(e);
throw iae;
}
- catch (WSDLException e)
+ catch (Exception e)
{
- log.info("WSDL Exception", e);
+ log.info("Couldn't initialize services for WSDL at '" + wsdlDefinitionURL + "'", e);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.services;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
@@ -63,6 +64,7 @@
public void setEndpointURL(String endpointURL)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(endpointURL, "Mandatory endpoint URL", null);
this.endpointURL = endpointURL;
}
@@ -81,4 +83,10 @@
}
return stub;
}
+
+
+ public boolean isAvailable()
+ {
+ return endpointURL != null;
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2006-12-23 00:24:47 UTC (rev 5932)
@@ -33,4 +33,6 @@
public interface ServiceFactory extends Service
{
Object getService(Class clazz) throws Exception;
+
+ boolean isAvailable();
}
19 years
JBoss Portal SVN: r5931 - trunk/core/src/resources/portal-cms-sar/META-INF
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2006-12-22 16:18:22 -0500 (Fri, 22 Dec 2006)
New Revision: 5931
Modified:
trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
[JBPORTAL-931],[JBPORTAL-372] - Deactivating the CMS Approval Workflow by default
Modified: trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-22 21:16:44 UTC (rev 5930)
+++ trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-22 21:18:22 UTC (rev 5931)
@@ -60,7 +60,7 @@
<depends>portal:service=Module,type=IdentityServiceController</depends>
<!--depends optional-attribute-name="UserModule" proxy-type="attribute">portal:service=Module,type=User</depends-->
<!-- add this to activate publish/approval workflow integration -->
- <depends optional-attribute-name="ApprovePublishWorkflow" proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends>
+ <!--depends optional-attribute-name="ApprovePublishWorkflow" proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends-->
<depends optional-attribute-name="StackFactory" proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
<attribute name="DoChecking">true</attribute>
<attribute name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
19 years