JBoss Portal SVN: r7238 - in trunk: core-admin/src/main/org/jboss/portal/core/admin/ui/common and 2 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-10 11:04:30 -0400 (Thu, 10 May 2007)
New Revision: 7238
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/theme/src/main/org/jboss/portal/theme/LayoutService.java
trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
Log:
Define a default renderSet.
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10 15:02:01 UTC (rev 7237)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10 15:04:30 UTC (rev 7238)
@@ -394,6 +394,7 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="DefaultLayoutName">generic</attribute>
+ <attribute name="DefaultRenderSetName">divRenderer</attribute>
</mbean>
<mbean
code="org.jboss.portal.theme.impl.PageServiceImpl"
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-05-10 15:02:01 UTC (rev 7237)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-05-10 15:04:30 UTC (rev 7238)
@@ -438,7 +438,7 @@
{
// Get the layout
String layoutId = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
- PortalLayout layout = layoutService.getLayout(layoutId, false);
+ PortalLayout layout = layoutService.getLayout(layoutId, true);
//
LinkedHashMap windows = new LinkedHashMap();
Modified: trunk/theme/src/main/org/jboss/portal/theme/LayoutService.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/LayoutService.java 2007-05-10 15:02:01 UTC (rev 7237)
+++ trunk/theme/src/main/org/jboss/portal/theme/LayoutService.java 2007-05-10 15:04:30 UTC (rev 7238)
@@ -58,6 +58,10 @@
/** Register a renderSet with this service */
void addRenderSet(RuntimeContext runtimeContext, RenderSetMetaData renderSet) throws LayoutException;
+ public void setDefaultRenderSetName(String name);
+
+ public String getDefaultRenderSetName();
+
/**
* Remove all rendersets that are hosted in the provided application.
*
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-05-10 15:02:01 UTC (rev 7237)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-05-10 15:04:30 UTC (rev 7238)
@@ -87,6 +87,8 @@
/** . */
private String defaultName;
+ private String defaultRenderSetName;
+
public LayoutServiceImpl()
{
log.debug("LayoutServiceImpl instantiated.");
@@ -161,7 +163,7 @@
}
}
- public void setDefaultLayoutName(String name) throws LayoutException
+ public void setDefaultLayoutName(String name)
{
log.debug("setting default: " + name);
defaultName = name;
@@ -449,6 +451,17 @@
return Collections.unmodifiableCollection((renderSetNames.values()));
}
+ public void setDefaultRenderSetName(String name)
+ {
+ log.debug("setting default render set: " + name);
+ defaultRenderSetName = name;
+ }
+
+ public String getDefaultRenderSetName()
+ {
+ return defaultRenderSetName;
+ }
+
/**
* Get the PortalRenderSet to use for the provided layout, page and media type. <p>The render set can be defined
* specifically for a layout, a page, or a portal. The one defined for the layout overwrites the one defined for the
@@ -457,6 +470,10 @@
*/
public PortalRenderSet getRenderSet(LayoutInfo info, ContentInfo streamInfo, String renderSetName)
{
+ if (renderSetName == null)
+ {
+ renderSetName = getDefaultRenderSetName();
+ }
if (info == null || renderSetName == null || streamInfo == null)
{
throw new IllegalArgumentException("No null arguments allowed [" + info + "] [" + renderSetName + "] [" + streamInfo + "]");
18 years, 12 months
JBoss Portal SVN: r7237 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-10 11:02:01 -0400 (Thu, 10 May 2007)
New Revision: 7237
Modified:
docs/trunk/referenceGuide/en/modules/xmldescriptors.xml
Log:
Update doc example
Modified: docs/trunk/referenceGuide/en/modules/xmldescriptors.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/xmldescriptors.xml 2007-05-10 14:55:41 UTC (rev 7236)
+++ docs/trunk/referenceGuide/en/modules/xmldescriptors.xml 2007-05-10 15:02:01 UTC (rev 7237)
@@ -1618,7 +1618,7 @@
<!-- see also portal-themes.xml -->
<property>
<name>theme.id</name>
- <value>Nphalanx</value>
+ <value>renaissance</value>
</property>
<!-- set the default render set name (used by the render tag in layouts) -->
<!-- see also portal-renderSet.xml -->
@@ -1626,12 +1626,6 @@
<name>theme.renderSetId</name>
<value>divRenderer</value>
</property>
- <!-- set the default strategy name (used by the strategy interceptor) -->
- <!-- see also portal-strategies.xml -->
- <property>
- <name>layout.strategyId</name>
- <value>maximizedRegion</value>
- </property>
</properties>
<security-constraint>
<policy-permission>
18 years, 12 months
JBoss Portal SVN: r7236 - trunk/core/src/main/org/jboss/portal/core/portlet/user.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-10 10:55:41 -0400 (Thu, 10 May 2007)
New Revision: 7236
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
Log:
Order locales
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-05-10 12:07:08 UTC (rev 7235)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-05-10 14:55:41 UTC (rev 7236)
@@ -29,6 +29,10 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -297,7 +301,11 @@
//
//String selectedLocale = (String)user.getProfile().get(User.INFO_USER_LOCALE);
String selectedLocale = (String)getProperty(user, User.INFO_USER_LOCALE);
- for (Iterator i = LocaleManager.getLocales().iterator(); i.hasNext();)
+
+ ArrayList locales = new ArrayList(LocaleManager.getLocales());
+ Collections.sort(locales, new LocaleComparator());
+
+ for (Iterator i = locales.iterator(); i.hasNext();)
{
Locale locale = (Locale)i.next();
DelegateContext localeCtx = ctx.next("locale");
@@ -1291,6 +1299,23 @@
return null;
}
+ private class LocaleComparator implements Comparator
+ {
+
+ public int compare(Object arg0, Object arg1)
+ {
+ Locale locale1 = (Locale)arg0;
+ Locale locale2 = (Locale)arg1;
+ int compare = locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage());
+ if (compare == 0)
+ {
+ compare = locale1.getDisplayCountry().compareTo(locale2.getDisplayCountry());
+ }
+ return compare;
+ }
+
+ }
+
/*
* private String getTimezoneOffsetString(short timezoneOffset) {
* StringBuffer timeZone = new StringBuffer(); for (int i = 0; i <
18 years, 12 months
JBoss Portal SVN: r7235 - trunk/security/src/main/org/jboss/portal/security/impl/jacc.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-10 08:07:08 -0400 (Thu, 10 May 2007)
New Revision: 7235
Modified:
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java
Log:
nano optimization : avoid to create identical instances of the same object
Modified: trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java 2007-05-10 09:11:17 UTC (rev 7234)
+++ trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java 2007-05-10 12:07:08 UTC (rev 7235)
@@ -46,6 +46,9 @@
/** . */
private AuthorizationDomainRegistry authorizationDomainRegistry;
+ /** . */
+ private final JACCPortalAuthorizationManager manager = new JACCPortalAuthorizationManager(this);
+
/** The configured roles. */
final Map configuredRoles = new HashMap();
@@ -61,7 +64,7 @@
public PortalAuthorizationManager getManager()
{
- return new JACCPortalAuthorizationManager(this);
+ return manager;
}
/** Set the PolicyContext subject security handler and the delegating policy. */
18 years, 12 months
JBoss Portal SVN: r7234 - in trunk: core and 11 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-10 05:11:17 -0400 (Thu, 10 May 2007)
New Revision: 7234
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml
Removed:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml
Modified:
trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
trunk/core/src/resources/portal-core-sar/portal-aop.xml
trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java
Log:
- improved instance container implementation with a cleaner separation between the logic and the hibernate persistence
- improved instance container test cases
Modified: trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -45,6 +45,19 @@
}
/**
+ * Factory method to create a collection builder using a singleton.
+ *
+ * @param o the object to add
+ * @return the builder created
+ */
+ public static CollectionBuilder singleton(Object o)
+ {
+ CollectionBuilder builder = new CollectionBuilder();
+ builder.collection.add(o);
+ return builder;
+ }
+
+ /**
* Add the object to the collection.
*
* @param o the object to add
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/build.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -252,7 +252,7 @@
<include name="org/jboss/portal/core/aspects/portlet/TransactionInterceptor.class"/>
<include name="org/jboss/portal/core/deployment/jboss/ObjectDeployment.class"/>
<include name="org/jboss/portal/core/deployment/jboss/PortletAppDeployment.class"/>
- <include name="org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.class"/>
+ <include name="org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.class"/>
<include name="org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.class"/>
<include name="org/jboss/portal/core/impl/portlet/state/ProducerPortletInvoker.class"/>
<include name="org/jboss/portal/core/hibernate/SessionFactoryBinder.class"/>
@@ -555,43 +555,53 @@
</x-sysproperty>
<x-test>
-<!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
- <parameter name="ConfigLocation" value="org/jboss/portal/test/core/model/portal/persistent-jboss-beans.xml"/>
+ <parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
--->
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
- <parameter name="ConfigLocation" value="org/jboss/portal/test/core/model/portal/transient-jboss-beans.xml"/>
+ <parameter name="Config" value="transient-jboss-beans.xml"/>
</zest>
-<!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="true"/>
<parameter name="CloneOnCreate" value="true"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-NotPersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="false"/>
<parameter name="CloneOnCreate" value="true"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-PersistedLocally-NotClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="true"/>
<parameter name="CloneOnCreate" value="false"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-NotPersistedLocally-NotClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="false"/>
<parameter name="CloneOnCreate" value="false"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
+<!--
+ <zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
+ outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
+ <parameter name="PersistLocally" value="true"/>
+ <parameter name="CloneOnCreate" value="true"/>
+ <parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config" value="transient-jboss-beans.xml"/>
+ </zest>
+-->
<zest todir="${test.reports}" name="org.jboss.portal.test.core.state.ProducerTestCase"
outfile="TEST-ProducerTestCase-WithoutRegistration">
<parameter name="UseRegistration" value="false"/>
@@ -609,7 +619,6 @@
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectIdTestCase"/>
--->
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-core-lib.jar"/>
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java (from rev 7225, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,340 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceCustomization;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.InstanceDefinition;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.List;
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractInstance implements Instance
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(AbstractInstance.class);
+
+ /** . */
+ protected String portletRef;
+
+ /** . */
+ protected byte[] state;
+
+ /** Composite representation of portletRef + state. */
+ protected PortletContext portletContext;
+
+ protected AbstractInstance()
+ {
+ }
+
+ public String getPortletRef()
+ {
+ return portletRef;
+ }
+
+ public void setPortletRef(String portletRef)
+ {
+ this.portletRef = portletRef;
+
+ // Invalidate
+ this.portletContext = null;
+ }
+
+ public byte[] getState()
+ {
+ return state;
+ }
+
+ public void setState(byte[] state)
+ {
+ this.state = state;
+
+ // Invalidate
+ this.portletContext = null;
+ }
+
+ public final PortletContext getPortletContext()
+ {
+ if (portletContext == null)
+ {
+ portletContext = PortletContext.createPortletContext(portletRef, state);
+ }
+ return portletContext;
+ }
+
+ public final void setPortletContext(PortletContext portletContext)
+ {
+ this.portletRef = portletContext.getId();
+ this.state = portletContext.getState();
+ this.portletContext = portletContext;
+ }
+
+ public final boolean isModifiable()
+ {
+ return isMutable();
+ }
+
+ protected abstract boolean isMutable();
+
+ protected abstract void setMutable(boolean modifiable);
+
+ protected abstract Logger getLogger();
+
+ protected abstract String getInstanceId();
+
+ protected abstract AccessMode getAccessMode();
+
+ protected abstract void cloned(PortletContext portletContext);
+
+ protected abstract void modified(PortletContext portletContext);
+
+ protected abstract AbstractInstanceDefinition getOwner();
+
+ protected abstract ContainerContext getContainerContext();
+
+ public final InstanceDefinition getDefinition()
+ {
+ return getOwner();
+ }
+
+ public final Portlet getPortlet() throws PortletInvokerException
+ {
+ PortletInvoker invoker = getContainer().getPortletInvoker();
+ PortletContext ctx = getOwner().getPortletContext();
+ return invoker.getPortlet(ctx);
+ }
+
+ public final InstanceContainer getContainer()
+ {
+ return getContainerContext().getContainer();
+ }
+
+ public final void setProperties(PropertyChange[] changes) throws PortletInvokerException
+ {
+ if (changes == null)
+ {
+ throw new IllegalArgumentException("No null changes accepted");
+ }
+ boolean debug = getLogger().isDebugEnabled();
+
+ // Get the invoker
+ PortletInvoker portletInvoker = getContainer().getPortletInvoker();
+
+ //
+ PortletContext portletContext = getPortletContext();
+
+ //
+ if (isModifiable() == false)
+ {
+ // Clone the portlet
+ if (debug)
+ {
+ getLogger().debug("Need to clone non modifiable instance before setting properties " /*+ instanceId + "/"*/ + portletContext);
+ }
+ portletContext = portletInvoker.createClone(portletContext);
+ if (debug)
+ {
+ getLogger().debug("Received updated portlet context " + portletContext + " for instance " /*+ instanceId*/ + " after explicit clone");
+ }
+
+ // Update the state
+ setPortletContext(portletContext);
+ setMutable(true);
+
+ //
+ getContainerContext().updateInstance(this);
+ }
+
+ //
+ if (debug)
+ {
+ getLogger().debug("Setting properties on " + /*instanceId + "/" +*/ portletContext + " : " + Arrays.asList(changes));
+ }
+ portletContext = portletInvoker.setProperties(portletContext, changes);
+ if (debug)
+ {
+ getLogger().debug("Received updated portlet context " + portletContext + " for instance " + /*instanceId +*/ " after setting properties");
+ }
+ setPortletContext(portletContext);
+
+ //
+ getContainerContext().updateInstance(this);
+ }
+
+ public final PropertyMap getProperties() throws PortletInvokerException
+ {
+ PortletInvoker invoker = getContainer().getPortletInvoker();
+ PortletContext portletContext = getPortletContext();
+ return invoker.getProperties(portletContext);
+ }
+
+ public final PropertyMap getProperties(Set keys) throws PortletInvokerException
+ {
+ PortletInvoker invoker = getContainer().getPortletInvoker();
+ PortletContext portletContext = getPortletContext();
+ return invoker.getProperties(portletContext, keys);
+ }
+
+ public final PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ {
+ boolean debug = getLogger().isDebugEnabled();
+ InstanceContainerImpl container = getContainerContext().getContainer();
+
+ //
+ AbstractInstance instance = this;
+ AccessMode accessMode = getAccessMode();
+
+ //
+ PortletContext portletContext = instance.getPortletContext();
+
+ // The instance context for the invocation
+ InstanceContextImpl instanceContext = new InstanceContextImpl(this, accessMode);
+
+ try
+ {
+ invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE, INSTANCE_ID_ATTRIBUTE, getInstanceId());
+ invocation.setTarget(portletContext);
+ invocation.setInstanceContext(instanceContext);
+
+ // Perform invocation
+ PortletInvocationResponse response = container.invoke(invocation);
+
+ // Create user instance if a clone operation occured
+ if (instanceContext.accessMode == AccessMode.CLONE_BEFORE_WRITE)
+ {
+ if (instanceContext.clonedContext != null)
+ {
+ if (debug)
+ {
+// log.debug("About to reference clone of (" + instanceId + "," + portletContext +
+// ") having id " + instanceContext.clonedContext + " for user " + userId);
+ }
+ cloned(instanceContext.clonedContext);
+ }
+ else
+ {
+ // Does not make sense
+ }
+ }
+ else if (instanceContext.accessMode == AccessMode.READ_WRITE)
+ {
+ if (instanceContext.modifiedContext != null)
+ {
+ if (debug)
+ {
+// log.debug("About to update portlet context (" + instanceId + "," + portletContext +
+// ") having id " + instanceContext.clonedContext + " for user " + userId);
+ }
+ modified(instanceContext.modifiedContext);
+ }
+ else
+ {
+ // Does not make sense
+ }
+ }
+
+ //
+ return response;
+ }
+ finally
+ {
+ // Reset state before invocation
+ invocation.removeAttribute(PortletInvocation.INVOCATION_SCOPE, INSTANCE_ID_ATTRIBUTE);
+ invocation.setTarget(null);
+ invocation.setInstanceContext(null);
+ }
+ }
+
+ public final InstanceCustomization getCustomization(String customizationId)
+ {
+ if (customizationId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ // Check if we have an instance for this particular customized id
+ AbstractInstanceCustomization customization = getContainerContext().getCustomization(getOwner(), customizationId);
+
+ //
+ if (customization == null)
+ {
+ AbstractInstanceDefinition def = getOwner();
+ customization = getContainerContext().newInstanceCustomization(def, customizationId, getPortletContext());
+ }
+
+ //
+ return customization;
+ }
+
+ public final void destroyCustomization(String customizationId)
+ {
+ AbstractInstanceCustomization customization = getContainerContext().getCustomization(getOwner(), customizationId);
+
+ //
+ if (customization != null)
+ {
+ try
+ {
+ PortletContext customizationPortletContext = customization.getPortletContext();
+ List toDestroy = Collections.singletonList(customizationPortletContext);
+ PortletInvoker portletInvoker = getContainer().getPortletInvoker();
+
+ //
+ List failures = portletInvoker.destroyClones(toDestroy);
+ if (failures.size() > 0)
+ {
+ for (Iterator i = failures.iterator();i.hasNext();)
+ {
+ DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
+ log.error("Was not able to destroy " + failure.getPortletId() + " for customization " +
+ customizationId + ", reason is : " + failure.getMessage());
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Could not destroy customization " + customizationId, e);
+ }
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.jboss.portal.core.model.instance.InstanceCustomization;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.PortletContext;
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractInstanceCustomization extends AbstractInstance implements InstanceCustomization
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(AbstractInstanceCustomization.class);
+
+ protected abstract boolean isPersistent();
+
+ protected AccessMode getAccessMode()
+ {
+ return isPersistent() ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE;
+ }
+
+ protected boolean isMutable()
+ {
+ return false;
+ }
+
+ protected void setMutable(boolean modifiable)
+ {
+ throw new IllegalStateException("Modifiable field is immutable");
+ }
+
+ protected final Logger getLogger()
+ {
+ return log;
+ }
+
+ protected final void cloned(PortletContext portletContext)
+ {
+ setPortletContext(portletContext);
+
+ //
+ getContainerContext().createInstanceCustomizaton(this);
+ }
+
+ protected final void modified(PortletContext portletContext)
+ {
+ setPortletContext(portletContext);
+
+ //
+ getContainerContext().updateInstance(this);
+ }
+
+ protected final String getInstanceId()
+ {
+ return getOwner().getInstanceId();
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.jboss.portal.core.model.instance.InstanceDefinition;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.PortletContext;
+import org.apache.log4j.Logger;
+
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6736 $
+ */
+public abstract class AbstractInstanceDefinition extends AbstractInstance implements InstanceDefinition
+{
+
+ /** The logger. */
+ protected static final Logger log = Logger.getLogger(AbstractInstanceDefinition.class);
+
+ // AbstractInstance implementation **********************************************************************************
+
+ protected AccessMode getAccessMode()
+ {
+/*
+ if (Mode.EDIT_DEFAULTS.equals(ctxabc.getMode()))
+ {
+ // Implement it by using the shared portlet id, but a security check should be made on using this
+ // mode first
+ // Another idea is to shove that in the security interceptor
+ throw new UnsupportedOperationException("Implement me");
+ }
+*/
+ return AccessMode.READ_ONLY;
+ }
+
+ protected Logger getLogger()
+ {
+ return log;
+ }
+
+ protected void cloned(PortletContext portletContext)
+ {
+ throw new IllegalStateException();
+ }
+
+ protected void modified(PortletContext portletContext)
+ {
+ getContainerContext().updateInstance(this);
+ }
+
+ protected AbstractInstanceDefinition getOwner()
+ {
+ return this;
+ }
+
+ protected abstract Collection getCustomizations();
+
+ public abstract Map getSecurityBindings();
+}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -22,36 +22,46 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.instance;
-import org.hibernate.Session;
-import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.portlet.PortletContext;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class ContainerContext
+public abstract class ContainerContext
{
/** . */
- final PersistentInstanceContainer container;
+ private InstanceContainerImpl container;
- public ContainerContext(PersistentInstanceContainer container)
+ public InstanceContainerImpl getContainer()
{
- if (container == null)
- {
- throw new IllegalArgumentException();
- }
- this.container = container;
+ return container;
}
- protected Session getCurrentSession()
+ public void setContainer(InstanceContainerImpl container)
{
- return container.sessionFactory.getCurrentSession();
+ this.container = container;
}
- public PortletInvoker getPortletInvoker()
- {
- return container.getPortletInvoker();
- }
+ public abstract Collection getInstanceDefinitions();
+ public abstract AbstractInstanceDefinition getInstanceDefinition(String id);
+
+ public abstract AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef);
+
+ public abstract void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws DuplicateInstanceException;
+
+ public abstract void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef);
+
+ public abstract AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef, String customizationId);
+
+ public abstract AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext portletContext);
+
+ public abstract void createInstanceCustomizaton(AbstractInstanceCustomization customization);
+
+ public abstract void updateInstance(AbstractInstance instanceDef);
}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java (from rev 7225, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,517 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.jboss.portal.common.invocation.InvocationHandler;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.common.invocation.Invocation;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.InstanceDefinition;
+import org.jboss.portal.core.model.instance.InstancePermission;
+import org.jboss.portal.core.model.instance.NoSuchInstanceException;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+import org.jboss.portal.security.PortalPermission;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.security.RoleSecurityBinding;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.PortalPermissionCollection;
+import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.security.spi.provider.AuthorizationDomain;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.security.spi.provider.PermissionFactory;
+import org.jboss.portal.security.spi.provider.PermissionRepository;
+import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Collections;
+
+/**
+ * Instance Container that is persistent
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author Anil.Saldhana(a)jboss.org
+ * @version $Revision$
+ */
+public class InstanceContainerImpl extends AbstractJBossService
+ implements InstanceContainer, AuthorizationDomain, DomainConfigurator,
+ PermissionRepository, PermissionFactory
+{
+
+
+ /** . */
+ protected InterceptorStackFactory stackFactory;
+
+ /** . */
+ protected PortletInvoker portletInvoker;
+
+ /** . */
+ protected PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+
+ /** . */
+ protected JBossAuthorizationDomainRegistry authorizationDomainRegistry;
+
+ /** . */
+ protected InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(Invocation invocation) throws Exception, InvocationException
+ {
+ PortletInvocation portletInvocation = (PortletInvocation)invocation;
+ try
+ {
+ portletInvocation.setHandler(null);
+ return portletInvoker.invoke(portletInvocation);
+ }
+ finally
+ {
+ portletInvocation.setHandler(this);
+ }
+ }
+ };
+
+ /** If true clone the portlet on an instance creation. */
+ protected boolean cloneOnCreate;
+
+ /** The container context. */
+ protected ContainerContext containerContext;
+
+ public InterceptorStackFactory getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public void setStackFactory(InterceptorStackFactory stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public JBossAuthorizationDomainRegistry getAuthorizationDomainRegistry()
+ {
+ return authorizationDomainRegistry;
+ }
+
+ public void setAuthorizationDomainRegistry(JBossAuthorizationDomainRegistry authorizationDomainRegistry)
+ {
+ this.authorizationDomainRegistry = authorizationDomainRegistry;
+ }
+
+ public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
+ {
+ return portalAuthorizationManagerFactory;
+ }
+
+ public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
+ {
+ this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
+ }
+
+ protected void startService() throws Exception
+ {
+ // Add ourself as the authorization domain
+ if (authorizationDomainRegistry != null)
+ {
+ authorizationDomainRegistry.addDomain(this);
+ }
+
+ //
+ containerContext.setContainer(this);
+ }
+
+ protected void stopService() throws Exception
+ {
+ //
+ containerContext.setContainer(null);
+
+ //
+ if (authorizationDomainRegistry != null)
+ {
+ authorizationDomainRegistry.removeDomain(this);
+ }
+ }
+
+ public PortalPermission createPermissionContainer(PortalPermissionCollection collection) throws PortalSecurityException
+ {
+ return new InstancePermission(collection);
+ }
+
+ public PortalPermission createPermission(String uri, String action) throws PortalSecurityException
+ {
+ return new InstancePermission(uri, action);
+ }
+
+ public PortalPermission createPermission(String uri, Collection actions) throws PortalSecurityException
+ {
+ return new InstancePermission(uri, actions);
+ }
+
+ public AuthorizationDomain getAuthorizationDomain()
+ {
+ return this;
+ }
+
+ public boolean getCloneOnCreate()
+ {
+ return cloneOnCreate;
+ }
+
+ public void setCloneOnCreate(boolean cloneOnCreate)
+ {
+ this.cloneOnCreate = cloneOnCreate;
+ }
+
+ public ContainerContext getContainerContext()
+ {
+ return containerContext;
+ }
+
+ public void setContainerContext(ContainerContext containerContext)
+ {
+ this.containerContext = containerContext;
+ }
+
+ public InstanceDefinition getDefinition(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ return containerContext.getInstanceDefinition(id);
+ }
+
+ public InstanceDefinition createDefinition(String id, String portletId) throws DuplicateInstanceException, IllegalArgumentException, PortletInvokerException
+ {
+ return internalCreateDefinition(id, portletId, cloneOnCreate);
+ }
+
+ public InstanceDefinition createDefinition(String id, String portletId, boolean clone) throws DuplicateInstanceException, PortletInvokerException
+ {
+ return internalCreateDefinition(id, portletId, clone);
+ }
+
+ private InstanceDefinition internalCreateDefinition(String id, String portletId, boolean clone) throws DuplicateInstanceException, PortletInvokerException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ boolean debug = log.isDebugEnabled();
+
+ //
+ if (debug)
+ {
+ log.debug("Creating instance " + id + " of portlet " + portletId);
+ }
+
+ // Create the portlet context we'll use
+ PortletContext portletContext = PortletContext.createPortletContext(portletId);
+
+ // Check that the portlet exist before creating an instance of it
+ portletInvoker.getPortlet(portletContext);
+
+ //
+ AbstractInstanceDefinition instance = containerContext.newInstanceDefinition(id, portletId);
+
+ //
+ containerContext.createInstanceDefinition(instance);
+
+ // Clone the portlet if required
+ if (clone)
+ {
+ // Clone the portlet state now and update the instance
+ if (debug)
+ {
+ log.debug("Cloning instance " + instance.getId() + "/" + portletContext);
+ }
+ portletContext = portletInvoker.createClone(portletContext);
+ if (debug)
+ {
+ log.debug("Instance " + instance.getId() + " succesfully cloned " + portletContext);
+ }
+
+ //
+ instance.setPortletContext(portletContext);
+ instance.setMutable(true);
+
+ //
+ containerContext.updateInstance(instance);
+ }
+
+ //
+ return instance;
+ }
+
+ public void destroyDefinition(String id) throws PortletInvokerException, NoSuchInstanceException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+
+ // Lookup instance
+ AbstractInstanceDefinition definition = containerContext.getInstanceDefinition(id);
+ if (definition == null)
+ {
+ throw new NoSuchInstanceException(id);
+ }
+
+ // Get customizations
+ Collection customizations = definition.getCustomizations();
+
+ // Collect portlet info to destroy for logging purpose
+ StringBuffer destroyLog = new StringBuffer("About to destroy portlets for instance=").
+ append(definition.getInstanceId()).
+ append(" [");
+
+ //
+ List toDestroy = new ArrayList(customizations.size());
+ for (Iterator i = customizations.iterator(); i.hasNext();)
+ {
+ InstanceCustomizationImpl customization = (InstanceCustomizationImpl)i.next();
+
+ // Get the user portlet context
+ PortletContext customizationPortletContext = customization.getPortletContext();
+
+ // Add the portlet context
+ toDestroy.add(customizationPortletContext);
+
+ //
+ destroyLog.append(customizationPortletContext);
+ if (i.hasNext())
+ {
+ destroyLog.append(',');
+ }
+ }
+
+ //
+ if (definition.isModifiable())
+ {
+ // Destroy the state only if it is not a producer offered portlet
+ PortletContext sharedPortletContext = definition.getPortletContext();
+ toDestroy.add(sharedPortletContext);
+ destroyLog.append(sharedPortletContext);
+ }
+ destroyLog.append(']');
+ log.debug(destroyLog);
+
+ // Perform destruction
+ List failures = portletInvoker.destroyClones(toDestroy);
+
+ // Log failures if any
+ if (failures.size() > 0)
+ {
+ StringBuffer failureLog = new StringBuffer("Some portlet were not properly destroyed for instance=").
+ append(definition.getInstanceId()).
+ append(" [");
+ for (Iterator i = failures.iterator(); i.hasNext();)
+ {
+ DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
+ failureLog.append(failure.getPortletId());
+ if (i.hasNext())
+ {
+ failureLog.append(',');
+ }
+ }
+ failureLog.append(']');
+ log.debug(failureLog);
+ }
+
+ //
+ containerContext.destroyInstanceDefinition(definition);
+ }
+
+ public Collection getDefinitions()
+ {
+ //
+// PortalAuthorizationManager mgr = portalAuthorizationManagerFactory.getManager();
+
+ //
+ Collection list = containerContext.getInstanceDefinitions();
+
+ // Filter the list
+ for (Iterator i = list.iterator();i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ InstancePermission perm = new InstancePermission(instance.getId(), InstancePermission.VIEW_ACTION);
+// if (mgr.checkPermission(perm) == false)
+// {
+// i.remove();
+// }
+ }
+
+ //
+ return list;
+ }
+
+ PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ {
+ InvocationHandler prevHandler = invocation.getHandler();
+ try
+ {
+ invocation.setHandler(handler);
+ return (PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
+ }
+ catch (Exception e)
+ {
+ if (e instanceof PortletInvokerException)
+ {
+ throw (PortletInvokerException)e;
+ }
+ else if (e instanceof RuntimeException)
+ {
+ throw (RuntimeException)e;
+ }
+ else
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+ finally
+ {
+ invocation.setHandler(prevHandler);
+ }
+ }
+
+ //**********************************************************************
+ // AuthorizationDomain Interface
+ //**********************************************************************
+
+ public String getType()
+ {
+ return InstancePermission.PERMISSION_TYPE;
+ }
+
+ public DomainConfigurator getConfigurator()
+ {
+ return this;
+ }
+
+ public PermissionRepository getPermissionRepository()
+ {
+ return this;
+ }
+
+ public PermissionFactory getPermissionFactory()
+ {
+ return this;
+ }
+
+ public Set getSecurityBindings(String uri)
+ {
+ Set constraints = null;
+ AbstractInstanceDefinition instance = containerContext.getInstanceDefinition(uri);
+ if (instance != null)
+ {
+ constraints = new HashSet();
+ Collection onscs = instance.getSecurityBindings().values();
+ for (Iterator i = onscs.iterator(); i.hasNext();)
+ {
+ InstanceSecurityBinding isc = (InstanceSecurityBinding)i.next();
+ RoleSecurityBinding sc = new RoleSecurityBinding(isc.getActions(), isc.getRole());
+ constraints.add(sc);
+ }
+ }
+ return constraints;
+ }
+
+ public void setSecurityBindings(String uri, Set securityBindings) throws SecurityConfigurationException
+ {
+ AbstractInstanceDefinition instanceDef = containerContext.getInstanceDefinition(uri);
+
+ //
+ if (instanceDef == null)
+ {
+ throw new SecurityConfigurationException("The object should exist prior its security is configured : fixme");
+ }
+
+ //
+ instanceDef.getSecurityBindings().clear();
+
+ //
+ HashMap map = new HashMap();
+ for (Iterator i = securityBindings.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
+
+ // Optimize
+ if (sc.getActions().size() > 0)
+ {
+ InstanceSecurityBinding isc = new InstanceSecurityBinding(sc.getActions(), sc.getRoleName());
+ isc.setInstance(instanceDef);
+ map.put(sc.getRoleName(), isc);
+ }
+ }
+ instanceDef.getSecurityBindings().putAll(map);
+
+ //
+ containerContext.updateInstance(instanceDef);
+ }
+
+ public void removeSecurityBindings(String uri) throws SecurityConfigurationException
+ {
+ setSecurityBindings(uri, Collections.EMPTY_SET);
+ }
+
+ public PortalPermission getPermission(String roleName, String uri) throws PortalSecurityException
+ {
+ Set set = getSecurityBindings(uri);
+ if (set != null && !set.isEmpty())
+ {
+ for (Iterator i = set.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
+ String constraintRoleName = sc.getRoleName();
+ if (constraintRoleName.equals(roleName) || SecurityConstants.UNCHECKED_ROLE_NAME.equals(constraintRoleName))
+ {
+ return createPermission(uri, sc.getActions());
+ }
+ }
+ }
+ return null;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -1,171 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Session;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceCustomization;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.state.AccessMode;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceCustomizationImpl extends InstanceImpl implements InstanceCustomization
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(InstanceCustomizationImpl.class);
-
- // Persistent fields
-
- protected InstanceDefinitionImpl def;
- protected String customizationId;
-
- // Runtime fields
-
- protected boolean persistent;
-
- /** Used to build transient instances. */
- public InstanceCustomizationImpl(InstanceDefinitionImpl def, String customizationId, ContainerContext containerContext, PortletContext portletContext)
- {
- super(containerContext);
-
- //
- if (def == null)
- {
- throw new IllegalArgumentException();
- }
- if (customizationId == null)
- {
- throw new IllegalArgumentException();
- }
- if (portletContext == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.def = def;
- this.customizationId = customizationId;
- this.persistent = false;
-
- //
- setPortletContext(portletContext);
- }
-
- /** Used by hibernate. */
- public InstanceCustomizationImpl()
- {
- this.customizationId = null;
- this.persistent = true;
- }
-
- public String getId()
- {
- return customizationId;
- }
-
- public Portlet getPortlet() throws PortletInvokerException
- {
- return def.getPortlet(getPortletContext());
- }
-
- public InstanceContainer getContainer()
- {
- return containerContext.container;
- }
-
- public InstanceDefinition getDefinition()
- {
- return def;
- }
-
- public String getCustomizationId()
- {
- return customizationId;
- }
-
- public void setCustomizationId(String customizationId)
- {
- this.customizationId = customizationId;
- }
-
- public InstanceDefinitionImpl getDef()
- {
- return def;
- }
-
- public void setDef(InstanceDefinitionImpl def)
- {
- this.def = def;
- }
-
- // AbstractInstance implementation **********************************************************************************
-
- protected String getInstanceId()
- {
- return def.getInstanceId();
- }
-
- protected void cloned(PortletContext portletContext)
- {
- Session session = containerContext.getCurrentSession();
- setPortletContext(portletContext);
- session.persist(this);
- def.customizations.add(this);
- session.update(def);
- }
-
- protected void modified(PortletContext portletContext)
- {
- Session session = containerContext.getCurrentSession();
- setPortletContext(portletContext);
- session.update(this);
- }
-
- protected AccessMode getAccessMode()
- {
- return persistent ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE;
- }
-
- protected boolean isModifiable()
- {
- return true;
- }
-
- protected void setModifiable(boolean modifiable)
- {
- throw new IllegalStateException("Unmodifiable");
- }
-
- protected Logger getLogger()
- {
- return log;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -1,183 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Session;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.state.AccessMode;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceDefinitionImpl extends InstanceImpl implements InstanceDefinition
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(InstanceDefinitionImpl.class);
-
- // Persistent fields
-
- protected String instanceId;
- protected boolean modifiable;
- protected Map securityBindings;
- protected Set customizations;
-
- public InstanceDefinitionImpl()
- {
- this.modifiable = false;
- this.portletRef = null;
- this.instanceId = null;
- this.securityBindings = null;
- this.customizations = null;
- this.state = null;
- }
-
- public InstanceDefinitionImpl(ContainerContext ctx, String id, String portletRef)
- {
- super(ctx);
- this.modifiable = false;
- this.portletRef = portletRef;
- this.instanceId = id;
- this.securityBindings = new HashMap();
- this.customizations = new HashSet();
- this.state = null;
- }
-
- // Hibernate ********************************************************************************************************
-
- public String getInstanceId()
- {
- return instanceId;
- }
-
- public void setInstanceId(String instanceId)
- {
- this.instanceId = instanceId;
- }
-
- public Map getSecurityBindings()
- {
- return securityBindings;
- }
-
- public void setSecurityBindings(Map securityBindings)
- {
- this.securityBindings = securityBindings;
- }
-
- public Set getCustomizations()
- {
- return customizations;
- }
-
- public void setCustomizations(Set customizations)
- {
- this.customizations = customizations;
- }
-
- public void setModifiable(boolean modifiable)
- {
- this.modifiable = modifiable;
- }
-
- // AbstractInstance implementation **********************************************************************************
-
-
- protected AccessMode getAccessMode()
- {
-/*
- if (Mode.EDIT_DEFAULTS.equals(ctxabc.getMode()))
- {
- // Implement it by using the shared portlet id, but a security check should be made on using this
- // mode first
- // Another idea is to shove that in the security interceptor
- throw new UnsupportedOperationException("Implement me");
- }
-*/
- return AccessMode.READ_ONLY;
- }
-
- protected Logger getLogger()
- {
- return log;
- }
-
- // Instance implementation ******************************************************************************************
-
- public String getId()
- {
- return instanceId;
- }
-
- public InstanceContainer getContainer()
- {
- return containerContext.container;
- }
-
- public boolean isModifiable()
- {
- return modifiable;
- }
-
- public Portlet getPortlet() throws PortletInvokerException
- {
- return getPortlet(getPortletContext());
- }
-
- Portlet getPortlet(PortletContext portletContext) throws PortletInvokerException
- {
- PersistentInstanceContainer container = containerContext.container;
- PortletInvoker invoker = container.getPortletInvoker();
- return invoker.getPortlet(portletContext);
- }
-
-
- protected void cloned(PortletContext portletContext)
- {
- throw new IllegalStateException();
- }
-
- protected void modified(PortletContext portletContext)
- {
- Session session = containerContext.getCurrentSession();
- setPortletContext(portletContext);
- session.update(this);
- }
-
- protected InstanceDefinitionImpl getDef()
- {
- return this;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -1,351 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.instance.InstanceCustomization;
-import org.jboss.portal.jems.hibernate.ContextObject;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.state.AccessMode;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.state.PropertyMap;
-import org.jboss.portal.portlet.state.DestroyCloneFailure;
-
-import java.util.Arrays;
-import java.util.Set;
-import java.util.List;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class InstanceImpl implements ContextObject, Instance
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(InstanceImpl.class);
-
- /** . */
- protected Long key;
-
- /** . */
- protected String portletRef;
-
- /** . */
- protected byte[] state;
-
- // Runtime fields
-
- /** . */
- protected ContainerContext containerContext;
-
- protected InstanceImpl(ContainerContext context)
- {
- if (context == null)
- {
- throw new IllegalArgumentException();
- }
- this.containerContext = context;
- }
-
- protected InstanceImpl()
- {
- }
-
- public Long getKey()
- {
- return key;
- }
-
- public void setKey(Long key)
- {
- this.key = key;
- }
-
- public String getPortletRef()
- {
- return portletRef;
- }
-
- public void setPortletRef(String portletRef)
- {
- this.portletRef = portletRef;
- }
-
- public byte[] getState()
- {
- return state;
- }
-
- public void setState(byte[] state)
- {
- this.state = state;
- }
-
- public PortletContext getPortletContext()
- {
- return PortletContext.createPortletContext(portletRef, state);
- }
-
- public void setPortletContext(PortletContext portletContext)
- {
- portletRef = portletContext.getId();
- state = portletContext.getState();
- }
-
- protected abstract boolean isModifiable();
-
- protected abstract void setModifiable(boolean modifiable);
-
- protected abstract Logger getLogger();
-
- protected abstract String getInstanceId();
-
- protected abstract AccessMode getAccessMode();
-
- protected abstract void cloned(PortletContext portletContext);
-
- protected abstract void modified(PortletContext portletContext);
-
- protected abstract InstanceDefinitionImpl getDef();
-
- public void setProperties(PropertyChange[] changes) throws PortletInvokerException
- {
- if (changes == null)
- {
- throw new IllegalArgumentException("No null changes accepted");
- }
- boolean debug = getLogger().isDebugEnabled();
-
- // Get the invoker
- PortletInvoker portletInvoker = containerContext.getPortletInvoker();
-
- //
- PortletContext portletContext = getPortletContext();
-
- //
- if (isModifiable() == false)
- {
- // Clone the portlet
- if (debug)
- {
- getLogger().debug("Need to clone non modifiable instance before setting properties " /*+ instanceId + "/"*/ + portletContext);
- }
- portletContext = portletInvoker.createClone(portletContext);
- if (debug)
- {
- getLogger().debug("Received updated portlet context " + portletContext + " for instance " /*+ instanceId*/ + " after explicit clone");
- }
-
- // Update the state
- setPortletContext(portletContext);
- setModifiable(true);
-
- //
- Session session = containerContext.getCurrentSession();
- session.update(this);
- }
-
- //
- if (debug)
- {
- getLogger().debug("Setting properties on " + /*instanceId + "/" +*/ portletContext + " : " + Arrays.asList(changes));
- }
- portletContext = portletInvoker.setProperties(portletContext, changes);
- if (debug)
- {
- getLogger().debug("Received updated portlet context " + portletContext + " for instance " + /*instanceId +*/ " after setting properties");
- }
- setPortletContext(portletContext);
-
- //
- Session session = containerContext.getCurrentSession();
- session.update(this);
- }
-
- public PropertyMap getProperties() throws PortletInvokerException
- {
- PersistentInstanceContainer container = containerContext.container;
- PortletInvoker invoker = container.getPortletInvoker();
- PortletContext portletContext = getPortletContext();
- return invoker.getProperties(portletContext);
- }
-
- public PropertyMap getProperties(Set keys) throws PortletInvokerException
- {
- PersistentInstanceContainer container = containerContext.container;
- PortletInvoker invoker = container.getPortletInvoker();
- PortletContext portletContext = getPortletContext();
- return invoker.getProperties(portletContext, keys);
- }
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
- {
- boolean debug = getLogger().isDebugEnabled();
- PersistentInstanceContainer container = this.containerContext.container;
-
- //
- InstanceImpl instance = this;
- AccessMode accessMode = getAccessMode();
-
- //
- PortletContext portletContext = instance.getPortletContext();
-
- // The instance context for the invocation
- InstanceContextImpl instanceContext = new InstanceContextImpl(this, accessMode);
-
- try
- {
- invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE, INSTANCE_ID_ATTRIBUTE, getInstanceId());
- invocation.setTarget(portletContext);
- invocation.setInstanceContext(instanceContext);
-
- // Perform invocation
- PortletInvocationResponse response = container.invoke(invocation);
-
- // Create user instance if a clone operation occured
- if (instanceContext.accessMode == AccessMode.CLONE_BEFORE_WRITE)
- {
- if (instanceContext.clonedContext != null)
- {
- if (debug)
- {
-// log.debug("About to reference clone of (" + instanceId + "," + portletContext +
-// ") having id " + instanceContext.clonedContext + " for user " + userId);
- }
- cloned(instanceContext.clonedContext);
- }
- else
- {
- // Does not make sense
- }
- }
- else if (instanceContext.accessMode == AccessMode.READ_WRITE)
- {
- if (instanceContext.modifiedContext != null)
- {
- if (debug)
- {
-// log.debug("About to update portlet context (" + instanceId + "," + portletContext +
-// ") having id " + instanceContext.clonedContext + " for user " + userId);
- }
- modified(instanceContext.modifiedContext);
- }
- else
- {
- // Does not make sense
- }
- }
-
- //
- return response;
- }
- finally
- {
- // Reset state before invocation
- invocation.removeAttribute(PortletInvocation.INVOCATION_SCOPE, INSTANCE_ID_ATTRIBUTE);
- invocation.setTarget(null);
- invocation.setInstanceContext(null);
- }
- }
-
- public InstanceCustomization getCustomization(String customizationId)
- {
- if (customizationId == null)
- {
- throw new IllegalArgumentException();
- }
-
- // Check if we have an instance for this particular customized id
- InstanceCustomizationImpl customization = loadCustomization(customizationId);
-
- //
- if (customization == null)
- {
- InstanceDefinitionImpl def = getDef();
- customization = new InstanceCustomizationImpl(def, customizationId, containerContext, getPortletContext());
- }
-
- //
- return customization;
- }
-
- public void destroyCustomization(String customizationId)
- {
- InstanceCustomizationImpl customization = loadCustomization(customizationId);
-
- //
- if (customization != null)
- {
- try
- {
- PortletContext customizationPortletContext = customization.getPortletContext();
- List toDestroy = Collections.singletonList(customizationPortletContext);
- PortletInvoker portletInvoker = containerContext.getPortletInvoker();
-
- //
- List failures = portletInvoker.destroyClones(toDestroy);
- if (failures.size() > 0)
- {
- for (Iterator i = failures.iterator();i.hasNext();)
- {
- DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
- log.error("Was not able to destroy " + failure.getPortletId() + " for customization " +
- customizationId + ", reason is : " + failure.getMessage());
- }
- }
- }
- catch (PortletInvokerException e)
- {
- log.error("Could not destroy customization " + customizationId, e);
- }
- }
- }
-
- private InstanceCustomizationImpl loadCustomization(String customizationId)
- {
- // Check if we have an instance for this particular customized id
- Session session = containerContext.getCurrentSession();
- Query query = session.createQuery("from InstanceCustomizationImpl where def.key=:defKey and customizationId=:customizationId");
- query.setParameter("defKey", key);
- query.setParameter("customizationId", customizationId);
- query.setCacheable(true);
- return (InstanceCustomizationImpl)query.uniqueResult();
- }
-
- // ContextObject implementation *************************************************************************************
-
- public void setContext(Object context)
- {
- this.containerContext = (ContainerContext)context;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -1,689 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.common.invocation.Invocation;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.invocation.InvocationHandler;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.core.model.instance.DuplicateInstanceException;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.core.model.instance.InstancePermission;
-import org.jboss.portal.core.model.instance.NoSuchInstanceException;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.jems.hibernate.ObjectContextualizer;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.state.DestroyCloneFailure;
-import org.jboss.portal.security.PortalPermission;
-import org.jboss.portal.security.PortalPermissionCollection;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.RoleSecurityBinding;
-import org.jboss.portal.security.SecurityConstants;
-import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.security.spi.provider.AuthorizationDomain;
-import org.jboss.portal.security.spi.provider.DomainConfigurator;
-import org.jboss.portal.security.spi.provider.PermissionFactory;
-import org.jboss.portal.security.spi.provider.PermissionRepository;
-import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
-
-import javax.naming.InitialContext;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Instance Container that is persistent
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author Anil.Saldhana(a)jboss.org
- * @version $Revision$
- */
-public class PersistentInstanceContainer extends AbstractJBossService
- implements InstanceContainer, AuthorizationDomain, DomainConfigurator,
- PermissionRepository, PermissionFactory
-{
-
- /** . */
- private static final String BY_INSTANCE_ID_QUERY = "from " + Tools.getShortNameOf(InstanceDefinitionImpl.class) + " where instanceId=:instanceId";
-
- /** . */
- protected InterceptorStackFactory stackFactory;
-
- /** . */
- protected SessionFactory sessionFactory;
-
- /** If true clone the portlet on an instance creation. */
- protected boolean cloneOnCreate;
-
- /** . */
- protected PortletInvoker portletInvoker;
-
- /** . */
- protected ContainerContext ctx;
-
- /** . */
- protected PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
-
- /** . */
- protected JBossAuthorizationDomainRegistry authorizationDomainRegistry;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- /** . */
- protected ObjectContextualizer contextualizer;
-
- /** . */
- protected InvocationHandler handler = new InvocationHandler()
- {
- public Object invoke(Invocation invocation) throws Exception, InvocationException
- {
- PortletInvocation portletInvocation = (PortletInvocation)invocation;
- try
- {
- portletInvocation.setHandler(null);
- return portletInvoker.invoke(portletInvocation);
- }
- finally
- {
- portletInvocation.setHandler(this);
- }
- }
- };
-
- /** . */
- protected ConcurrentReaderHashMap cache;
-
- /** . */
- protected boolean cacheNaturalId;
-
- public PersistentInstanceContainer()
- {
- ctx = new ContainerContext(this);
-
- //
- contextualizer = new ObjectContextualizer(ctx);
- cache = new ConcurrentReaderHashMap();
- }
-
- public void flushNaturalIdCache()
- {
- cache.clear();
- }
-
- public int getNaturalIdCacheSize()
- {
- return cache.size();
- }
-
- public boolean getCacheNaturalId()
- {
- return cacheNaturalId;
- }
-
- public void setCacheNaturalId(boolean cacheNaturalId)
- {
- this.cacheNaturalId = cacheNaturalId;
- }
-
- public boolean getCloneOnCreate()
- {
- return cloneOnCreate;
- }
-
- public void setCloneOnCreate(boolean cloneOnCreate)
- {
- this.cloneOnCreate = cloneOnCreate;
- }
-
- public InterceptorStackFactory getStackFactory()
- {
- return stackFactory;
- }
-
- public void setStackFactory(InterceptorStackFactory stackFactory)
- {
- this.stackFactory = stackFactory;
- }
-
- public PortletInvoker getPortletInvoker()
- {
- return portletInvoker;
- }
-
- public void setPortletInvoker(PortletInvoker portletInvoker)
- {
- this.portletInvoker = portletInvoker;
- }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public ContainerContext getContainerContext()
- {
- return ctx;
- }
-
- public void startService() throws Exception
- {
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- //
- contextualizer.attach(sessionFactory);
-
- // Add ourself as the authorization domain
- if (authorizationDomainRegistry != null)
- {
- authorizationDomainRegistry.addDomain(this);
- }
-
- //
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
- super.stopService();
-
- //
- if (authorizationDomainRegistry != null)
- {
- authorizationDomainRegistry.removeDomain(this);
- }
-
- //
- sessionFactory = null;
- }
-
- public InstanceDefinition getDefinition(String id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- Session session = ctx.getCurrentSession();
- return lookup(session, id);
- }
-
- public InstanceDefinition createDefinition(String id, String portletId) throws DuplicateInstanceException, IllegalArgumentException, PortletInvokerException
- {
- return internalCreateDefinition(id, portletId, cloneOnCreate);
- }
-
- public InstanceDefinition createDefinition(String id, String portletId, boolean clone) throws DuplicateInstanceException, PortletInvokerException
- {
- return internalCreateDefinition(id, portletId, clone);
- }
-
- private InstanceDefinition internalCreateDefinition(String id, String portletId, boolean clone) throws DuplicateInstanceException, PortletInvokerException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- boolean debug = log.isDebugEnabled();
-
- //
- if (debug)
- {
- log.debug("Creating instance " + id + " of portlet " + portletId);
- }
-
- // Create the portlet context we'll use
- PortletContext portletContext = PortletContext.createPortletContext(portletId);
-
- // Check that the portlet exist before creating an instance of it
- portletInvoker.getPortlet(portletContext);
-
- // Prevent duplicate
- Session session = ctx.getCurrentSession();
- if (lookup(session, id) != null)
- {
- throw new DuplicateInstanceException("An instance with id " + id + " already exist");
- }
-
- //
- InstanceDefinitionImpl instance;
- try
- {
- instance = new InstanceDefinitionImpl(ctx, id, portletId);
- session.persist(instance);
- }
- catch (ConstraintViolationException e)
- {
- // May raise a constraint violation exception if it is has been inserted between the lookup
- // and the insert and the isolation level is not serializable
- throw new DuplicateInstanceException("An instance with id " + id + " already exist");
- }
-
- // Clone the portlet if required
- if (clone)
- {
- // Clone the portlet state now and update the instance
- if (debug)
- {
- log.debug("Cloning instance " + instance.instanceId + "/" + portletContext);
- }
- portletContext = portletInvoker.createClone(portletContext);
- if (debug)
- {
- log.debug("Instance " + instance.instanceId + " succesfully cloned " + portletContext);
- }
-
- //
- instance.setPortletContext(portletContext);
- instance.setModifiable(true);
-
- //
- session.update(instance);
- }
-
- //
- return instance;
- }
-
- public void destroyDefinition(String id) throws PortletInvokerException, NoSuchInstanceException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
-
- // Get an hibernate session
- Session session = ctx.getCurrentSession();
-
- // Lookup instance
- InstanceDefinitionImpl definition = lookup(session, id);
- if (definition == null)
- {
- throw new NoSuchInstanceException(id);
- }
- Set customizations = definition.getCustomizations();
-
- // Collect portlet info to destroy for logging purpose
- StringBuffer destroyLog = new StringBuffer("About to destroy portlets for instance=").
- append(definition.getInstanceId()).
- append(" [");
-
- //
- List toDestroy = new ArrayList(customizations.size());
- for (Iterator i = customizations.iterator(); i.hasNext();)
- {
- InstanceCustomizationImpl customization = (InstanceCustomizationImpl)i.next();
-
- // Get the user portlet context
- PortletContext customizationPortletContext = customization.getPortletContext();
-
- // Add the portlet context
- toDestroy.add(customizationPortletContext);
-
- //
- destroyLog.append(customizationPortletContext);
- if (i.hasNext())
- {
- destroyLog.append(',');
- }
- }
-
- //
- if (definition.isModifiable())
- {
- // Destroy the state only if it is not a producer offered portlet
- PortletContext sharedPortletContext = definition.getPortletContext();
- toDestroy.add(sharedPortletContext);
- destroyLog.append(sharedPortletContext);
- }
- destroyLog.append(']');
- log.debug(destroyLog);
-
- // Perform destruction
- List failures = portletInvoker.destroyClones(toDestroy);
-
- // Log failures if any
- if (failures.size() > 0)
- {
- StringBuffer failureLog = new StringBuffer("Some portlet were not properly destroyed for instance=").
- append(definition.getInstanceId()).
- append(" [");
- for (Iterator i = failures.iterator(); i.hasNext();)
- {
- DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
- failureLog.append(failure.getPortletId());
- if (i.hasNext())
- {
- failureLog.append(',');
- }
- }
- failureLog.append(']');
- log.debug(failureLog);
- }
-
- // Destroy the user instances
- for (Iterator i = customizations.iterator(); i.hasNext();)
- {
- InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)i.next();
- i.remove();
- userInstance.def = null;
- session.delete(userInstance);
- }
-
- // Delete instance
- removeBindings(session, definition);
- session.delete(definition);
-
- //
- session.flush();
- }
-
- public Collection getDefinitions()
- {
- //
- PortalAuthorizationManager mgr = portalAuthorizationManagerFactory.getManager();
-
- //
- Session session = ctx.getCurrentSession();
- List list = session.createQuery("from InstanceDefinitionImpl").list();
-
- // Filter the list
- for (Iterator i = list.iterator();i.hasNext();)
- {
- Instance instance = (Instance)i.next();
- InstancePermission perm = new InstancePermission(instance.getId(), InstancePermission.VIEW_ACTION);
- if (mgr.checkPermission(perm) == false)
- {
- i.remove();
- }
- }
-
- //
- return list;
- }
-
- PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
- {
- InvocationHandler prevHandler = invocation.getHandler();
- try
- {
- invocation.setHandler(handler);
- return (PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
- }
- catch (Exception e)
- {
- if (e instanceof PortletInvokerException)
- {
- throw (PortletInvokerException)e;
- }
- else if (e instanceof RuntimeException)
- {
- throw (RuntimeException)e;
- }
- else
- {
- throw new PortletInvokerException(e);
- }
- }
- finally
- {
- invocation.setHandler(prevHandler);
- }
- }
-
- public JBossAuthorizationDomainRegistry getAuthorizationDomainRegistry()
- {
- return authorizationDomainRegistry;
- }
-
- public void setAuthorizationDomainRegistry(JBossAuthorizationDomainRegistry authorizationDomainRegistry)
- {
- this.authorizationDomainRegistry = authorizationDomainRegistry;
- }
-
- public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
- {
- return portalAuthorizationManagerFactory;
- }
-
- public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
- {
- this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
- }
-
- private InstanceDefinitionImpl lookup(Session session, String id)
- {
- // Get cached pk from natural id
- Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
-
- //
- InstanceDefinitionImpl instance;
-
- //
- if (pk == null)
- {
- // No pk
- instance = lookupNoCache(session, id);
- }
- else
- {
- // Try lookup using the cached pk
- instance = (InstanceDefinitionImpl)session.get(InstanceDefinitionImpl.class, pk);
-
- // The pk may be invalid if the instance has been recreted under the same path with a different pk
- if (instance == null)
- {
- // In that case we try a no cache
- instance = lookupNoCache(session, id);
- }
- }
-
- //
- if (cacheNaturalId)
- {
- if (instance != null)
- {
- cache.put(id, instance.getKey());
- }
- else
- {
- cache.remove(id);
- }
- }
-
- //
- return instance;
- }
-
- private InstanceDefinitionImpl lookupNoCache(Session session, String id)
- {
- Query q = session.createQuery(BY_INSTANCE_ID_QUERY);
- q.setString("instanceId", id);
- return (InstanceDefinitionImpl)q.uniqueResult();
- }
-
- //**********************************************************************
- // AuthorizationDomain Interface
- //**********************************************************************
-
- public String getType()
- {
- return InstancePermission.PERMISSION_TYPE;
- }
-
- public DomainConfigurator getConfigurator()
- {
- return this;
- }
-
- public PermissionRepository getPermissionRepository()
- {
- return this;
- }
-
- public PermissionFactory getPermissionFactory()
- {
- return this;
- }
-
- public Set getSecurityBindings(String uri)
- {
- Set constraints = null;
- InstanceDefinitionImpl instance = lookup(sessionFactory.getCurrentSession(), uri);
- if (instance != null)
- {
- constraints = new HashSet();
- Collection onscs = instance.getSecurityBindings().values();
- for (Iterator i = onscs.iterator(); i.hasNext();)
- {
- InstanceSecurityBinding isc = (InstanceSecurityBinding)i.next();
- RoleSecurityBinding sc = new RoleSecurityBinding(isc.getActions(), isc.getRole());
- constraints.add(sc);
- }
- }
- return constraints;
- }
-
- public void setSecurityBindings(String uri, Set securityBindings) throws SecurityConfigurationException
- {
- Session session = sessionFactory.getCurrentSession();
- InstanceDefinitionImpl instance = lookup(session, uri);
-
- //
- if (instance == null)
- {
- throw new SecurityConfigurationException("The object should exist prior its security is configured : fixme");
- }
-
- //
- removeBindings(session, instance);
-
- //
- HashMap map = new HashMap();
- for (Iterator i = securityBindings.iterator(); i.hasNext();)
- {
- RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
-
- // Optimize
- if (sc.getActions().size() > 0)
- {
- InstanceSecurityBinding isc = new InstanceSecurityBinding(sc.getActions(), sc.getRoleName());
- isc.setInstance(instance);
- map.put(sc.getRoleName(), isc);
- session.save(isc);
- }
- }
- instance.setSecurityBindings(map);
-
- //
- session.flush();
- }
-
- public void removeSecurityBindings(String uri) throws SecurityConfigurationException
- {
- Session session = sessionFactory.getCurrentSession();
- InstanceDefinitionImpl instance = lookup(session, uri);
-
- //
- if (instance == null)
- {
- throw new SecurityConfigurationException("The object should exist prior its security is configured : fixme");
- }
-
- removeBindings(session, instance);
- session.flush();
- }
-
- public PortalPermission getPermission(String roleName, String uri) throws PortalSecurityException
- {
- Set set = getSecurityBindings(uri);
- if (set != null && !set.isEmpty())
- {
- for (Iterator i = set.iterator(); i.hasNext();)
- {
- RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
- String constraintRoleName = sc.getRoleName();
- if (constraintRoleName.equals(roleName) || SecurityConstants.UNCHECKED_ROLE_NAME.equals(constraintRoleName))
- {
- return createPermission(uri, sc.getActions());
- }
- }
- }
- return null;
- }
-
- public PortalPermission createPermissionContainer(PortalPermissionCollection collection) throws PortalSecurityException
- {
- return new InstancePermission(collection);
- }
-
- public PortalPermission createPermission(String uri, String action) throws PortalSecurityException
- {
- return new InstancePermission(uri, action);
- }
-
- public PortalPermission createPermission(String uri, Collection actions) throws PortalSecurityException
- {
- return new InstancePermission(uri, actions);
- }
-
- public AuthorizationDomain getAuthorizationDomain()
- {
- return this;
- }
-
- private void removeBindings(Session session, InstanceDefinitionImpl instance)
- {
- if (instance.getSecurityBindings() != null)
- {
- for (Iterator i = instance.getSecurityBindings().values().iterator(); i.hasNext();)
- {
- InstanceSecurityBinding insc = (InstanceSecurityBinding)i.next();
- session.delete(insc);
- }
- instance.getSecurityBindings().clear();
- }
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java (from rev 7225, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.ContainerContext;
+import org.jboss.portal.portlet.PortletContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InstanceCustomizationImpl extends AbstractInstanceCustomization
+{
+
+ // Persistent fields
+
+ protected Long key;
+ protected InstanceDefinitionImpl relatedDefinition;
+ protected String customizationId;
+
+ // Runtime fields
+
+ protected InstanceDefinitionImpl owner;
+ protected boolean persistent;
+
+ /** Used to build transient instances. */
+ public InstanceCustomizationImpl(InstanceDefinitionImpl owner, String customizationId, PortletContext portletContext)
+ {
+ if (owner == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (customizationId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.owner = owner;
+ this.persistent = false;
+
+ //
+ setCustomizationId(customizationId);
+ setPortletContext(portletContext);
+ }
+
+ /** Used by hibernate. */
+ public InstanceCustomizationImpl()
+ {
+ this.owner = null;
+ this.persistent = true;
+ }
+
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ public String getId()
+ {
+ return customizationId;
+ }
+
+ public String getCustomizationId()
+ {
+ return customizationId;
+ }
+
+ public void setCustomizationId(String customizationId)
+ {
+ this.customizationId = customizationId;
+ }
+
+ public AbstractInstanceDefinition getOwner()
+ {
+ return owner;
+ }
+
+ public InstanceDefinitionImpl getRelatedDefinition()
+ {
+ return relatedDefinition;
+ }
+
+ public void setRelatedDefinition(InstanceDefinitionImpl relatedDefinition)
+ {
+ this.relatedDefinition = relatedDefinition;
+ this.owner = relatedDefinition;
+ }
+
+ protected boolean isPersistent()
+ {
+ return persistent;
+ }
+
+ protected ContainerContext getContainerContext()
+ {
+ return owner.containerContext;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java (from rev 7225, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.impl.model.instance.ContainerContext;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.jems.hibernate.ContextObject;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InstanceDefinitionImpl extends AbstractInstanceDefinition implements ContextObject
+{
+
+ // Persistent fields
+
+ protected Long key;
+ protected String instanceId;
+ protected boolean mutable;
+ protected Map securityBindings;
+ protected Map customizationMap;
+
+ // Runtime fields
+
+ /** . */
+ protected ContainerContext containerContext;
+
+ public InstanceDefinitionImpl()
+ {
+ this.mutable = false;
+ this.portletRef = null;
+ this.instanceId = null;
+ this.securityBindings = null;
+ this.customizationMap = null;
+ this.state = null;
+ }
+
+ public InstanceDefinitionImpl(String id, String portletRef)
+ {
+ this.mutable = false;
+ this.portletRef = portletRef;
+ this.instanceId = id;
+ this.securityBindings = new HashMap();
+ this.customizationMap = new HashMap();
+ this.state = null;
+ }
+
+ // Hibernate ********************************************************************************************************
+
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId)
+ {
+ this.instanceId = instanceId;
+ }
+
+ public Map getSecurityBindings()
+ {
+ return securityBindings;
+ }
+
+ public void setSecurityBindings(Map securityBindings)
+ {
+ this.securityBindings = securityBindings;
+ }
+
+ public Map getCustomizationMap()
+ {
+ return customizationMap;
+ }
+
+ public void setCustomizationMap(Map customizationMap)
+ {
+ this.customizationMap = customizationMap;
+ }
+
+ public boolean isMutable()
+ {
+ return mutable;
+ }
+
+ public void setMutable(boolean mutable)
+ {
+ this.mutable = mutable;
+ }
+
+ // Instance implementation ******************************************************************************************
+
+ public String getId()
+ {
+ return instanceId;
+ }
+
+ // AbstractInstanceDefinition implementation ************************************************************************
+
+ protected Collection getCustomizations()
+ {
+ return customizationMap.values();
+ }
+
+ // ContextObject implementation *************************************************************************************
+
+ public void setContext(Object context)
+ {
+ this.containerContext = (ContainerContext)context;
+ }
+
+ protected ContainerContext getContainerContext()
+ {
+ return containerContext;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance.persistent;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.exception.ConstraintViolationException;
+import org.jboss.portal.jems.hibernate.ObjectContextualizer;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.core.impl.model.instance.ContainerContext;
+import org.jboss.portal.core.impl.model.instance.AbstractInstance;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.PortletContext;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+import javax.naming.InitialContext;
+import java.util.Iterator;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PersistentInstanceContext extends ContainerContext
+{
+
+ /** . */
+ private static final String BY_INSTANCE_ID_QUERY = "from " + Tools.getShortNameOf(InstanceDefinitionImpl.class) + " where instanceId=:instanceId";
+
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ /** . */
+ protected ObjectContextualizer contextualizer;
+
+ /** . */
+ protected ConcurrentReaderHashMap cache;
+
+ /** . */
+ protected boolean cacheNaturalId;
+
+ public PersistentInstanceContext()
+ {
+ this.contextualizer = new ObjectContextualizer(this);
+ this.cache = new ConcurrentReaderHashMap();
+ }
+
+ public void flushNaturalIdCache()
+ {
+ cache.clear();
+ }
+
+ public int getNaturalIdCacheSize()
+ {
+ return cache.size();
+ }
+
+ public boolean getCacheNaturalId()
+ {
+ return cacheNaturalId;
+ }
+
+ public void setCacheNaturalId(boolean cacheNaturalId)
+ {
+ this.cacheNaturalId = cacheNaturalId;
+ }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+ public void start() throws Exception
+ {
+ sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+ //
+ contextualizer.attach(sessionFactory);
+ }
+
+ public void stop() throws Exception
+ {
+ sessionFactory = null;
+ }
+
+ public Collection getInstanceDefinitions()
+ {
+ Session session = sessionFactory.getCurrentSession();
+ return session.createQuery("from InstanceDefinitionImpl").list();
+ }
+
+ public AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext portletContext)
+ {
+ return new InstanceCustomizationImpl((InstanceDefinitionImpl)def, id, portletContext);
+ }
+
+ public AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef)
+ {
+ return new InstanceDefinitionImpl(id, portletRef);
+ }
+
+ public AbstractInstanceDefinition getInstanceDefinition(String id)
+ {
+ // Get cached pk from natural id
+ Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
+
+ //
+ InstanceDefinitionImpl instance;
+
+ //
+ Session session = sessionFactory.getCurrentSession();
+
+ //
+ if (pk == null)
+ {
+ // No pk
+ instance = lookupNoCache(session, id);
+ }
+ else
+ {
+ // Try lookup using the cached pk
+ instance = (InstanceDefinitionImpl)session.get(InstanceDefinitionImpl.class, pk);
+
+ // The pk may be invalid if the instance has been recreted under the same path with a different pk
+ if (instance == null)
+ {
+ // In that case we try a no cache
+ instance = lookupNoCache(session, id);
+ }
+ }
+
+ //
+ if (cacheNaturalId)
+ {
+ if (instance != null)
+ {
+ cache.put(id, instance.getKey());
+ }
+ else
+ {
+ cache.remove(id);
+ }
+ }
+
+ //
+ return instance;
+ }
+
+ public AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef, String customizationId)
+ {
+ InstanceDefinitionImpl _instanceDef = (InstanceDefinitionImpl)instanceDef;
+ return (InstanceCustomizationImpl)_instanceDef.customizationMap.get(customizationId);
+ }
+
+ private InstanceDefinitionImpl lookupNoCache(Session session, String id)
+ {
+ Query q = session.createQuery(BY_INSTANCE_ID_QUERY);
+ q.setString("instanceId", id);
+ return (InstanceDefinitionImpl)q.uniqueResult();
+ }
+
+ public void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws DuplicateInstanceException
+ {
+ String id = instanceDef.getId();
+
+ //
+ if (getInstanceDefinition(id) != null)
+ {
+ throw new DuplicateInstanceException("An instance with id " + id + " already exist");
+ }
+
+ //
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.persist(instanceDef);
+ }
+ catch (ConstraintViolationException e)
+ {
+ // May raise a constraint violation exception if it is has been inserted between the lookup
+ // and the insert and the isolation level is not serializable
+ throw new DuplicateInstanceException("An instance with id " + id + " already exist");
+ }
+ }
+
+ public void createInstanceCustomizaton(AbstractInstanceCustomization customization)
+ {
+ createInstanceCustomizaton((InstanceCustomizationImpl)customization);
+ }
+
+ private void createInstanceCustomizaton(InstanceCustomizationImpl customization)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Persist in db
+ session.persist(customization);
+
+ // Get owner that will become the related definition
+ InstanceDefinitionImpl relatedDefinition = customization.owner;
+
+ // Create one to many assoication
+ relatedDefinition.customizationMap.put(customization.customizationId, customization);
+ customization.relatedDefinition = relatedDefinition;
+
+ // Update state
+ session.update(customization.relatedDefinition);
+
+ // Mark state as persistent
+ customization.persistent = true;
+ }
+
+ public void updateInstance(AbstractInstance instanceDef)
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.update(instanceDef);
+ }
+
+ public void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef)
+ {
+ destroyInstanceDefinition((InstanceDefinitionImpl)instanceDef);
+ }
+
+ private void destroyInstanceDefinition(InstanceDefinitionImpl instanceDef)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Destroy the user instances
+ Collection customizations = instanceDef.getCustomizationMap().values();
+ for (Iterator i = customizations.iterator(); i.hasNext();)
+ {
+ InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)i.next();
+ i.remove();
+ userInstance.relatedDefinition = null;
+ session.delete(userInstance);
+ }
+
+ // Delete instance
+ session.delete(instanceDef);
+
+ //
+ session.flush();
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -38,15 +38,17 @@
import org.apache.log4j.SimpleLayout;
import org.hibernate.Session;
import org.jboss.portal.Mode;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.common.junit.TransactionAssert;
import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.test.junit.POJOJUnitTest;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import org.jboss.portal.common.test.TestParametrization;
-import org.jboss.portal.core.impl.model.instance.InstanceCustomizationImpl;
-import org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl;
-import org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer;
+import org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl;
+import org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl;
+import org.jboss.portal.core.impl.model.instance.InstanceContainerImpl;
import org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceDefinition;
@@ -76,8 +78,9 @@
import org.jboss.portal.test.framework.embedded.HibernateSupport;
import java.net.URL;
-import java.util.List;
import java.util.Set;
+import java.util.Collections;
+import java.util.Collection;
/**
* Test Case that tests the authorization for instances via the instance container
@@ -155,6 +158,9 @@
private boolean cloneOnCreate;
/** . */
+ private boolean cacheNaturalId;
+
+ /** . */
private DataSourceSupport.Config dataSourceConfigParameter;
/** . */
@@ -167,7 +173,7 @@
private HibernateSupport portletHibernateSupport;
/** . */
- private PersistentInstanceContainer instanceContainer;
+ private InstanceContainerImpl instanceContainer;
/** . */
private PersistentPortletStatePersistenceManager persistenceManager;
@@ -178,9 +184,12 @@
/** . */
private PortletInvokerSupport portletContainer;
+ /** . */
+ private String config;
+
public String getName()
{
- return super.getName() + ",persistLocally=" + persistLocally + ",cloneOnCreate=" + cloneOnCreate + ",ds=" + dataSourceConfigParameter.getName();
+ return super.getName() + ",persistLocally=" + persistLocally + ",cacheNaturalId=" + cacheNaturalId + ",cloneOnCreate=" + cloneOnCreate + ",ds=" + dataSourceConfigParameter.getName() + ",config=" + config;
}
public String getPersistLocallyParameter()
@@ -203,6 +212,16 @@
this.cloneOnCreate = Boolean.valueOf(cloneOnCreateParameter).booleanValue();
}
+ public String getCacheNaturalIdParameter()
+ {
+ return Boolean.toString(cacheNaturalId);
+ }
+
+ public void setCacheNaturalIdParameter(String cacheNaturalIdParameter)
+ {
+ this.cacheNaturalId = Boolean.valueOf(cacheNaturalIdParameter).booleanValue();
+ }
+
public DataSourceSupport.Config getDataSourceConfigParameter()
{
return dataSourceConfigParameter;
@@ -213,6 +232,16 @@
this.dataSourceConfigParameter = dataSourceConfigParameter;
}
+ public String getConfigParameter()
+ {
+ return config;
+ }
+
+ public void setConfigParameter(String configParameter)
+ {
+ this.config = configParameter;
+ }
+
public boolean isPersistLocally()
{
return persistLocally;
@@ -223,6 +252,11 @@
return cloneOnCreate;
}
+ public boolean isCacheNaturalId()
+ {
+ return cacheNaturalId;
+ }
+
public TestRuntimeContext getRuntimeContext()
{
return runtimeContext;
@@ -253,12 +287,12 @@
this.portletHibernateSupport = portletHibernateSupport;
}
- public PersistentInstanceContainer getInstanceContainer()
+ public InstanceContainerImpl getInstanceContainer()
{
return instanceContainer;
}
- public void setInstanceContainer(PersistentInstanceContainer instanceContainer)
+ public void setInstanceContainer(InstanceContainerImpl instanceContainer)
{
this.instanceContainer = instanceContainer;
}
@@ -295,8 +329,7 @@
public void setUp() throws Exception
{
- //
- runtimeContext = new TestRuntimeContext("org/jboss/portal/test/core/model/instance/jboss-beans.xml");
+ runtimeContext = new TestRuntimeContext("org/jboss/portal/test/core/model/instance/" + config);
runtimeContext.addBean("TestCaseConfig", this);
runtimeContext.addBean("TestBean", this);
runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
@@ -319,25 +352,33 @@
internalPortlet.addPreference("abc", new StringValue("def"));
//
+ TransactionAssert.beginTransaction();
Instance instance = instanceContainer.createDefinition("MyInstance", "MyPortlet", true);
assertNotNull(instance);
+ TransactionAssert.commitTransaction();
//
TransactionAssert.beginTransaction();
- Session session = instanceHibernateSupport.getCurrentSession();
- List instances = session.createQuery("from InstanceDefinitionImpl").list();
- assertEquals(1, instances.size());
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// Session session = instanceHibernateSupport.getCurrentSession();
+// List instances = session.createQuery("from InstanceDefinitionImpl").list();
+// assertEquals(1, instances.size());
+// InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// assertEquals(true, instanceImpl.isModifiable());
+ assertEquals(1, instanceContainer.getDefinitions().size());
+ InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ assertNotNull(instanceImpl);
assertEquals(true, instanceImpl.isModifiable());
TransactionAssert.commitTransaction();
//
TransactionAssert.beginTransaction();
+ instance = instanceContainer.getDefinition("MyInstance");
instance.setProperties(new PropertyChange[]{PropertyChange.newUpdate("abc", new StringValue("_def")), PropertyChange.newUpdate("ghi", new StringValue("_jkl"))});
TransactionAssert.commitTransaction();
//
TransactionAssert.beginTransaction();
+ instance = instanceContainer.getDefinition("MyInstance");
PropertyMap props = instance.getProperties(new CollectionBuilder().add("abc").add("ghi").toHashSet());
PropertyMap expectedProps = new SimplePropertyMap();
expectedProps.setProperty("abc", new StringValue("_def"));
@@ -347,10 +388,14 @@
//
TransactionAssert.beginTransaction();
- session = instanceHibernateSupport.getCurrentSession();
- instances = session.createQuery("from InstanceDefinitionImpl").list();
- assertEquals(1, instances.size());
- instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// session = instanceHibernateSupport.getCurrentSession();
+// instances = session.createQuery("from InstanceDefinitionImpl").list();
+// assertEquals(1, instances.size());
+// instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// assertEquals(true, instanceImpl.isModifiable());
+ assertEquals(1, instanceContainer.getDefinitions().size());
+ instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ assertNotNull(instanceImpl);
assertEquals(true, instanceImpl.isModifiable());
TransactionAssert.commitTransaction();
}
@@ -490,7 +535,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -520,7 +565,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -543,7 +588,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)userInstances.iterator().next();
@@ -578,7 +623,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)userInstances.iterator().next();
@@ -614,7 +659,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -636,7 +681,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -658,7 +703,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -680,7 +725,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -717,7 +762,7 @@
PortletContext sharedPortletContext = instanceImpl.getPortletContext();
assertNotNull(producer.getPortlet(sharedPortletContext));
assertNotNull(instance);
- Set children = instanceImpl.getCustomizations();
+ Collection children = instanceImpl.getCustomizationMap().values();
assertNotNull(children);
assertEquals(1, children.size());
InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)children.iterator().next();
@@ -807,6 +852,86 @@
}
}
+ /** . */
+ private final Set securityBindings1 = Collections.unmodifiableSet(CollectionBuilder.singleton(new RoleSecurityBinding("a,b", "admin")).add(new RoleSecurityBinding("a", "user")).toHashSet());
+
+ /** . */
+ private final Set securityBindings2 = Collections.unmodifiableSet(CollectionBuilder.singleton(new RoleSecurityBinding("a,b", "user")).toHashSet());
+
+ public void testSecurityConfiguration() throws Exception
+ {
+ portletContainer.addInternalPortlet("MyPortlet", new TestPortletSupport());
+
+ //
+ TransactionAssert.beginTransaction();
+ String instanceId = instanceContainer.createDefinition("MyInstance", "MyPortlet").getId();
+ TransactionAssert.commitTransaction();
+
+ //
+ DomainConfigurator configurator = instanceContainer.getConfigurator();
+ assertNotNull(configurator);
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.setSecurityBindings(instanceId, securityBindings1);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ Set bindings = configurator.getSecurityBindings(instanceId);
+ assertNotNull(bindings);
+ assertEquals(securityBindings1, bindings);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.setSecurityBindings(instanceId, securityBindings2);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ bindings = configurator.getSecurityBindings(instanceId);
+ assertNotNull(bindings);
+ assertEquals(securityBindings2, bindings);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.removeSecurityBindings(instanceId);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ bindings = configurator.getSecurityBindings(instanceId);
+ assertNotNull(bindings);
+ assertEquals(0, bindings.size());
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testDestroyInstanceWithSecurityConfiguration() throws Exception
+ {
+ portletContainer.addInternalPortlet("MyPortlet", new TestPortletSupport());
+
+ //
+ TransactionAssert.beginTransaction();
+ String instanceId = instanceContainer.createDefinition("MyInstance", "MyPortlet").getId();
+ TransactionAssert.commitTransaction();
+
+ //
+ DomainConfigurator configurator = instanceContainer.getConfigurator();
+ assertNotNull(configurator);
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.setSecurityBindings(instanceId, securityBindings1);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ instanceContainer.destroyDefinition(instanceId);
+ TransactionAssert.commitTransaction();
+ }
+
//
//// /**Tests the authorization of portal objects */
//// public void testInstanceAuthorization() throws Exception
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -75,11 +75,17 @@
return suite;
}
+ public String getName()
+ {
+ TestParametrization parametrization = JUnitAdapter.getParametrization();
+ return super.getName() + ",ds=" + dataSourceConfigParameter.getName() + ",Config=" + parametrization.getParameterValue("Config").get();
+ }
+
protected String getConfigLocation()
{
TestParametrization parametrization = JUnitAdapter.getParametrization();
- TestParameterValue paramValue = parametrization.getParameterValue("ConfigLocation");
- return (String)paramValue.get();
+ TestParameterValue paramValue = parametrization.getParameterValue("Config");
+ return "org/jboss/portal/test/core/model/portal/" + paramValue.get();
}
public PortalObjectContainer getPortalObjectContainer()
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -561,7 +561,7 @@
<!-- The different containers -->
<mbean
- code="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer"
+ code="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl"
name="portal:container=Instance"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -27,7 +27,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
- name="org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl"
+ name="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
table="JBP_INSTANCE">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -51,7 +51,7 @@
not-null="false"
unique="false"/>
<property
- name="modifiable"
+ name="mutable"
column="MODIFIABLE"
not-null="true"
unique="false"/>
@@ -65,27 +65,30 @@
name="securityBindings"
sort="unsorted"
inverse="true"
- cascade="none"
+ cascade="all-delete-orphan"
fetch="join">
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="INSTANCE_PK"/>
<index column="ROLE" type="string"/>
<one-to-many class="org.jboss.portal.core.impl.model.instance.InstanceSecurityBinding"/>
</map>
- <set
- name="customizations"
+ <map
+ name="customizationMap"
inverse="true"
cascade="save-update"
fetch="select"
lazy="extra">
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="INSTANCE_PK"/>
- <one-to-many class="org.jboss.portal.core.impl.model.instance.InstanceCustomizationImpl"/>
- </set>
+ <map-key
+ type="string"
+ column="USER_ID"/>
+ <one-to-many class="org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl"/>
+ </map>
</class>
<class
- name="org.jboss.portal.core.impl.model.instance.InstanceCustomizationImpl"
+ name="org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl"
table="JBP_INSTANCE_PER_USER">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -97,9 +100,9 @@
</generator>
</id>
<many-to-one
- name="def"
+ name="relatedDefinition"
column="INSTANCE_PK"
- class="org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl"
+ class="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
cascade="none"
fetch="select"/>
<property
@@ -144,7 +147,7 @@
<set
name="actions"
table="JBP_INSTANCE_SECURITY_ACTIONS"
- cascade="none"
+ cascade="all-delete-orphan"
fetch="join">
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="PK"/>
@@ -153,7 +156,7 @@
<many-to-one
name="instance"
column="INSTANCE_PK"
- class="org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl"
+ class="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
cascade="none"
fetch="select"/>
</class>
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -54,7 +54,8 @@
name="children"
inverse="true"
cascade="none"
- fetch="select">
+ fetch="select"
+ lazy="extra">
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="PARENT_KEY"/>
<map-key
Modified: trunk/core/src/resources/portal-core-sar/portal-aop.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/portal-aop.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-sar/portal-aop.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -94,7 +94,7 @@
</metadata>
<metadata
tag="transaction"
- class="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer">
+ class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
<method name="getDefinition">
<trans-attribute>Required</trans-attribute>
</method>
Deleted: trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml
===================================================================
--- trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -1,124 +0,0 @@
-<?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. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
- xmlns="urn:jboss:bean-deployer">
-
- <bean name="TestCaseConfig" class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>TestCaseConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DataSourceConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>HibernateConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
- <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
- </bean>
-
- <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- </bean>
-
- <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
- <property name="config"><inject bean="DataSourceConfig"/></property>
- </bean>
-
- <bean name="InstanceHibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject bean="HibernateConfig"/></property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>conf/hibernate/instance/domain.hbm.xml</value>
- </list>
- </property>
- <property name="jNDIName">java:/InstanceSessionFactory</property>
- </bean>
-
- <bean name="PortletHibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject bean="HibernateConfig"/></property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>conf/hibernate/portlet/domain.hbm.xml</value>
- </list>
- </property>
- <property name="jNDIName">java:/PortletSessionFactory</property>
- </bean>
-
- <bean name="StateConverter" class="org.jboss.portal.portlet.impl.state.StateConverterV0">
- </bean>
- <bean name="StateManagementPolicy" class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
- <property name="persistLocally"><inject bean="TestCaseConfig" property="persistLocally"/></property>
- </bean>
- <bean name="PersistenceManager" class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
- <property name="sessionFactoryJNDIName">java:/PortletSessionFactory</property>
- </bean>
- <bean name="PortletContainer" class="org.jboss.portal.portlet.test.support.PortletInvokerSupport">
- </bean>
- <bean name="Producer" class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
- <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
- <property name="portletInvoker"><inject bean="PortletContainer"/></property>
- <property name="stateManagementPolicy"><inject bean="StateManagementPolicy"/></property>
- <property name="stateConverter"><inject bean="StateConverter"/></property>
- </bean>
-
- <bean name="StackFactory" class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
- </bean>
- <bean name="InstanceContainer" class="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer">
- <property name="cloneOnCreate"><inject bean="TestCaseConfig" property="cloneOnCreate"/></property>
- <property name="portletInvoker"><inject bean="Producer"/></property>
- <property name="sessionFactoryJNDIName">java:/InstanceSessionFactory</property>
- <property name="stackFactory"><inject bean="StackFactory"/></property>
- </bean>
-
- <bean name="TestBean" class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>TestBean</parameter>
- </constructor>
- <property name="instanceHibernateSupport"><inject bean="InstanceHibernateSupport"/></property>
- <property name="portletHibernateSupport"><inject bean="PortletHibernateSupport"/></property>
- <property name="instanceContainer"><inject bean="InstanceContainer"/></property>
- <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
- <property name="producer"><inject bean="Producer"/></property>
- <property name="portletContainer"><inject bean="PortletContainer"/></property>
- </bean>
-</deployment>
Added: trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
===================================================================
--- trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml (rev 0)
+++ trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,128 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TestCaseConfig" class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestCaseConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>DataSourceConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
+ </bean>
+
+ <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
+ </bean>
+
+ <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
+ <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
+ </bean>
+
+ <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
+ <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
+ <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
+ <property name="config"><inject bean="DataSourceConfig"/></property>
+ </bean>
+
+ <bean name="InstanceHibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/instance/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property name="jNDIName">java:/InstanceSessionFactory</property>
+ </bean>
+
+ <bean name="PortletHibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/portlet/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property name="jNDIName">java:/PortletSessionFactory</property>
+ </bean>
+
+ <bean name="StateConverter" class="org.jboss.portal.portlet.impl.state.StateConverterV0">
+ </bean>
+ <bean name="StateManagementPolicy" class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
+ <property name="persistLocally"><inject bean="TestCaseConfig" property="persistLocally"/></property>
+ </bean>
+ <bean name="PersistenceManager" class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
+ <property name="sessionFactoryJNDIName">java:/PortletSessionFactory</property>
+ </bean>
+ <bean name="PortletContainer" class="org.jboss.portal.portlet.test.support.PortletInvokerSupport">
+ </bean>
+ <bean name="Producer" class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ <property name="portletInvoker"><inject bean="PortletContainer"/></property>
+ <property name="stateManagementPolicy"><inject bean="StateManagementPolicy"/></property>
+ <property name="stateConverter"><inject bean="StateConverter"/></property>
+ </bean>
+
+ <bean name="StackFactory" class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
+ </bean>
+ <bean name="ContainerContext" class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceContext">
+ <property name="sessionFactoryJNDIName">java:/InstanceSessionFactory</property>
+ <property name="cacheNaturalId"><inject bean="TestCaseConfig" property="cacheNaturalId"/></property>
+ </bean>
+ <bean name="InstanceContainer" class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
+ <property name="cloneOnCreate"><inject bean="TestCaseConfig" property="cloneOnCreate"/></property>
+ <property name="portletInvoker"><inject bean="Producer"/></property>
+ <property name="containerContext"><inject bean="ContainerContext"/></property>
+ <property name="stackFactory"><inject bean="StackFactory"/></property>
+ </bean>
+
+ <bean name="TestBean" class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestBean</parameter>
+ </constructor>
+ <property name="instanceHibernateSupport"><inject bean="InstanceHibernateSupport"/></property>
+ <property name="portletHibernateSupport"><inject bean="PortletHibernateSupport"/></property>
+ <property name="instanceContainer"><inject bean="InstanceContainer"/></property>
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ <property name="producer"><inject bean="Producer"/></property>
+ <property name="portletContainer"><inject bean="PortletContainer"/></property>
+ </bean>
+</deployment>
Added: trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml
===================================================================
--- trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml (rev 0)
+++ trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -0,0 +1,126 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TestCaseConfig" class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestCaseConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>DataSourceConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
+ </bean>
+
+ <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
+ </bean>
+
+ <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
+ <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
+ </bean>
+
+ <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
+ <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
+ <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
+ <property name="config"><inject bean="DataSourceConfig"/></property>
+ </bean>
+
+ <bean name="InstanceHibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/instance/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property name="jNDIName">java:/InstanceSessionFactory</property>
+ </bean>
+
+ <bean name="PortletHibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/portlet/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property name="jNDIName">java:/PortletSessionFactory</property>
+ </bean>
+
+ <bean name="StateConverter" class="org.jboss.portal.portlet.impl.state.StateConverterV0">
+ </bean>
+ <bean name="StateManagementPolicy" class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
+ <property name="persistLocally"><inject bean="TestCaseConfig" property="persistLocally"/></property>
+ </bean>
+ <bean name="PersistenceManager" class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
+ <property name="sessionFactoryJNDIName">java:/PortletSessionFactory</property>
+ </bean>
+ <bean name="PortletContainer" class="org.jboss.portal.portlet.test.support.PortletInvokerSupport">
+ </bean>
+ <bean name="Producer" class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ <property name="portletInvoker"><inject bean="PortletContainer"/></property>
+ <property name="stateManagementPolicy"><inject bean="StateManagementPolicy"/></property>
+ <property name="stateConverter"><inject bean="StateConverter"/></property>
+ </bean>
+
+ <bean name="StackFactory" class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
+ </bean>
+ <bean name="ContainerContext" class="org.jboss.portal.core.impl.model.instance.TransientContainerContext">
+ </bean>
+ <bean name="InstanceContainer" class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
+ <property name="cloneOnCreate"><inject bean="TestCaseConfig" property="cloneOnCreate"/></property>
+ <property name="portletInvoker"><inject bean="Producer"/></property>
+ <property name="containerContext"><inject bean="ContainerContext"/></property>
+ <property name="stackFactory"><inject bean="StackFactory"/></property>
+ </bean>
+
+ <bean name="TestBean" class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestBean</parameter>
+ </constructor>
+ <property name="instanceHibernateSupport"><inject bean="InstanceHibernateSupport"/></property>
+ <property name="portletHibernateSupport"><inject bean="PortletHibernateSupport"/></property>
+ <property name="instanceContainer"><inject bean="InstanceContainer"/></property>
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ <property name="producer"><inject bean="Producer"/></property>
+ <property name="portletContainer"><inject bean="PortletContainer"/></property>
+ </bean>
+</deployment>
Deleted: trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml
===================================================================
--- trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -1,102 +0,0 @@
-<?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. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
- xmlns="urn:jboss:bean-deployer">
-
- <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DataSourceConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>HibernateConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
- <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
- </bean>
-
- <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- </bean>
-
- <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
- <property name="config"><inject bean="DataSourceConfig"/></property>
- </bean>
-
- <bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject bean="HibernateConfig"/></property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>conf/hibernate/portal/domain.hbm.xml</value>
- </list>
- </property>
- <property name="jNDIName">java:/SessionFactory</property>
- </bean>
-
- <bean name="AuthorizationDomainRegistry" class="org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl">
- </bean>
-
- <bean name="AuthorizationManagerFactory" class="org.jboss.portal.security.impl.jacc.JACCPortalAuthorizationManagerFactory">
- <property name="authorizationDomainRegistry"><inject bean="AuthorizationDomainRegistry"/></property>
- </bean>
-
- <bean name="ContentProviderRegistry" class="org.jboss.portal.test.core.model.content.SimpleContentProviderRegistry">
- </bean>
-
- <bean name="PortletContentProvider" class="org.jboss.portal.test.core.model.content.SimpleContentProvider">
- <constructor>
- <parameter>portlet</parameter>
- </constructor>
- <property name="registry"><inject bean="ContentProviderRegistry"/></property>
- </bean>
-
- <bean name="PortalObjectContainer" class="org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer">
- <property name="sessionFactoryJNDIName">java:/SessionFactory</property>
- <property name="authorizationDomainRegistry"><inject bean="AuthorizationDomainRegistry"/></property>
- <property name="portalAuthorizationManagerFactory"><inject bean="AuthorizationManagerFactory"/></property>
- <property name="contentProviderRegistry"><inject bean="ContentProviderRegistry"/></property>
- </bean>
-
- <bean name="TestBean" class="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>TestBean</parameter>
- </constructor>
- <property name="hibernate"><inject bean="HibernateSupport"/></property>
- <property name="portalObjectContainer"><inject bean="PortalObjectContainer"/></property>
- </bean>
-</deployment>
Modified: trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java 2007-05-10 09:11:17 UTC (rev 7234)
@@ -174,14 +174,18 @@
if (toString == null)
{
StringBuffer tmp = new StringBuffer("SecurityConstraint: actions [");
- for (Iterator i = actions.iterator(); i.hasNext();)
+ for (Iterator i = actions.iterator();;)
{
String action = (String)i.next();
+ tmp.append(action);
if (i.hasNext())
{
tmp.append(", ");
}
- tmp.append(action);
+ else
+ {
+ break;
+ }
}
tmp.append("] role [").append(roleName).append("]");
toString = tmp.toString();
18 years, 12 months
JBoss Portal SVN: r7233 - in trunk: portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-09 23:10:55 -0400 (Wed, 09 May 2007)
New Revision: 7233
Modified:
trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
Log:
- Added check for null jbossPortletMD.
- Typo.
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-05-09 23:16:23 UTC (rev 7232)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-05-10 03:10:55 UTC (rev 7233)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.info;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.info.CacheInfo;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
@@ -31,7 +32,6 @@
import org.jboss.portal.portlet.info.SecurityInfo;
import org.jboss.portal.portlet.info.SessionInfo;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-import org.jboss.portal.common.i18n.ResourceBundleManager;
/**
* For now implementation that use the portlet container directly.
@@ -62,7 +62,7 @@
this.security = new ContainerSecurityInfo(portletMD);
this.cache = new ContainerCacheInfo(portletMD, jbossPortletMD);
this.session = new ContainerSessionInfo(jbossPortletMD);
- this.remotable = jbossPortletMD.getRemotable() != null ? jbossPortletMD.getRemotable() : Boolean.FALSE;
+ this.remotable = (jbossPortletMD != null && jbossPortletMD.getRemotable() != null) ? jbossPortletMD.getRemotable() : Boolean.FALSE;
}
public CapabilitiesInfo getCapabilities()
Modified: trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
===================================================================
--- trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java 2007-05-09 23:16:23 UTC (rev 7232)
+++ trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java 2007-05-10 03:10:55 UTC (rev 7233)
@@ -25,10 +25,10 @@
import org.jboss.deployment.DeploymentException;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.xml.NullEntityResolver;
-import org.jboss.portal.portlet.impl.container.PortletApplicationContextImpl;
import org.jboss.portal.portlet.deployment.JBossApplicationMetaDataFactory;
import org.jboss.portal.portlet.deployment.PortletApplicationMetaDataFactory;
import org.jboss.portal.portlet.deployment.ValueTrimmingFilter;
+import org.jboss.portal.portlet.impl.container.PortletApplicationContextImpl;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
@@ -295,7 +295,7 @@
EntityResolver entityResolver = this.factory.getJBossPortletEntityResolver();
if (entityResolver == null)
{
- log.debug("Coult not obtain entity resolver for jboss-portlet.xml");
+ log.debug("Could not obtain entity resolver for jboss-portlet.xml");
entityResolver = new NullEntityResolver();
}
else
18 years, 12 months
JBoss Portal SVN: r7232 - in trunk/core-cms/src: resources/portal-cms-war/WEB-INF/jsp/cms/admin and 1 other directory.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-05-09 19:16:23 -0400 (Wed, 09 May 2007)
New Revision: 7232
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp
Log:
Bug Fix: Access denied while viewing document in CMSAdmin Portlet - JBPORTAL-1378
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java 2007-05-09 19:44:47 UTC (rev 7231)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java 2007-05-09 23:16:23 UTC (rev 7232)
@@ -28,9 +28,19 @@
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.IdentityServiceController;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import javax.naming.InitialContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -45,6 +55,9 @@
/** The serialVersionUID */
private static final long serialVersionUID = 1676227756085242093L;
+ /**
+ *
+ */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException
{
String path = (String)request.getParameter("p");
@@ -55,6 +68,11 @@
{
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
CMS CMSService = (CMS)MBeanProxy.get(CMS.class, new ObjectName("portal:service=CMS"), mbeanServer);
+ IdentityServiceController identityService = (IdentityServiceController)MBeanProxy.get(
+ IdentityServiceController.class, new ObjectName("portal:service=Module,type=IdentityServiceController"), mbeanServer);
+
+ //Setup the Identity of the user accessing this servlet
+ this.setupUser(request, identityService);
Command getCMD = CMSService.getCommandFactory().createFileGetCommand(path, version, new Locale(language));
File file = (File)CMSService.execute(getCMD);
@@ -85,8 +103,76 @@
}
}
+ /**
+ *
+ */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
{
doGet(request, response);
}
+
+ /**
+ *
+ * @param identityService
+ */
+ private void setupUser(HttpServletRequest request,IdentityServiceController identityService) throws Exception
+ {
+ String remoteUser = (String)request.getSession().getAttribute("remoteUser");
+ if(remoteUser != null && remoteUser.trim().length() > 0)
+ {
+ User user = (User)request.getSession().getAttribute("cmsIdentity");
+
+ if( user == null ||
+ !user.getUserName().equals(remoteUser) //This happens if another user is now logged in to the same session...rare scenario
+ )
+ {
+ user = this.getUser(remoteUser, identityService);
+ request.getSession().setAttribute("cmsIdentity", user);
+ }
+
+ JCRCMS.getUserInfo().set(user);
+ }
+ }
+
+ /**
+ *
+ * @param identityService
+ * @return
+ * @throws Exception
+ */
+ private User getUser(String remoteUser,IdentityServiceController identityService) throws Exception
+ {
+ User user = null;
+ SessionFactory identitySessionFactory = (SessionFactory)new InitialContext().lookup("java:/portal/IdentitySessionFactory");
+ Session session = identitySessionFactory.openSession();
+ Transaction transaction = session.beginTransaction();
+ boolean success = false;
+ try
+ {
+ UserModule userModule = (UserModule)
+ identityService.getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
+ user = userModule.findUserByUserName(remoteUser);
+ success = true;
+ }
+ finally
+ {
+ if(transaction != null)
+ {
+ if(success)
+ {
+ transaction.commit();
+ }
+ else
+ {
+ transaction.rollback();
+ }
+ }
+
+ if(session != null)
+ {
+ session.close();
+ }
+ }
+ return user;
+ }
}
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2007-05-09 19:44:47 UTC (rev 7231)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2007-05-09 23:16:23 UTC (rev 7232)
@@ -249,6 +249,9 @@
<% }
else
{
+ //save the principal for the preview servlet
+ String remoteUser = request.getRemoteUser();
+ request.getSession().setAttribute("remoteUser",remoteUser);
%>
<a target="_blank"
href="<%= request.getContextPath() %>/cmspreview?v=<%= version.getVersionNumber() %>&l=<%= content.getLocale().getLanguage() %>&p=<%= sCurrPath %>"><%=
18 years, 12 months
JBoss Portal SVN: r7231 - in docs/trunk: quickstartuser and 3 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-05-09 15:44:47 -0400 (Wed, 09 May 2007)
New Revision: 7231
Added:
docs/trunk/userGuide/en/images/admincms/workflow_file_view.jpg
docs/trunk/userGuide/en/images/admincms/workflow_pending_items.jpg
Modified:
docs/trunk/
docs/trunk/quickstartuser/
docs/trunk/userGuide/
docs/trunk/userGuide/en/modules/admincmsPortlet.xml
Log:
workflow documentation in the userguide
Property changes on: docs/trunk
___________________________________________________________________
Name: svn:ignore
+ *.classpath
*.project
Property changes on: docs/trunk/quickstartuser
___________________________________________________________________
Name: svn:ignore
+ build
Property changes on: docs/trunk/userGuide
___________________________________________________________________
Name: svn:ignore
+ build
Added: docs/trunk/userGuide/en/images/admincms/workflow_file_view.jpg
===================================================================
(Binary files differ)
Property changes on: docs/trunk/userGuide/en/images/admincms/workflow_file_view.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: docs/trunk/userGuide/en/images/admincms/workflow_pending_items.jpg
===================================================================
(Binary files differ)
Property changes on: docs/trunk/userGuide/en/images/admincms/workflow_pending_items.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: docs/trunk/userGuide/en/modules/admincmsPortlet.xml
===================================================================
--- docs/trunk/userGuide/en/modules/admincmsPortlet.xml 2007-05-09 19:24:04 UTC (rev 7230)
+++ docs/trunk/userGuide/en/modules/admincmsPortlet.xml 2007-05-09 19:44:47 UTC (rev 7231)
@@ -93,6 +93,11 @@
<xref linkend="secure"/>
</para>
</listitem>
+ <listitem>
+ <para>
+ <xref linkend="workflow"/>
+ </para>
+ </listitem>
</itemizedlist>
</para>
<sect2 id="viewdir">
@@ -364,5 +369,31 @@
Users you want to allow to have a specific permission.
</para>
</sect2>
+ <sect2 id="workflow">
+ <title>Content Publish/Approval Workflow</title>
+ <para>
+ When the Publish/Approval Workflow service is activated on the CMS, any requests for publishing new content or making updates to existing content
+ requires an Approval process before going "Live". You can specify a list of Portal Roles that can act as Approvers who can authorize/deny the publishing
+ of content in the CMS.
+ </para>
+ <para>
+ When a content is created in the CMS, the screen should show an Pending Queue of Approvals for that particular content as shown below in the screen.
+ The content waiting in this queue is not accessible for "Live" usage.
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/admincms/workflow_file_view.jpg" format="gif" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ <para>
+ The user's who are designated as Approvers can view the CMS pending queue by clicking the <emphasis role="bold">Pending Items</emphasis> link
+ in the flyout menu. The Pending Queue screen is as follows:
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/admincms/workflow_pending_items.jpg" format="gif" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
+ </para>
+ </sect2>
</sect1>
</chapter>
18 years, 12 months
JBoss Portal SVN: r7230 - trunk/common/src/main/org/jboss/portal/common/test.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-09 15:24:04 -0400 (Wed, 09 May 2007)
New Revision: 7230
Modified:
trunk/common/src/main/org/jboss/portal/common/test/TestParametrization.java
Log:
- Typo.
Modified: trunk/common/src/main/org/jboss/portal/common/test/TestParametrization.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/test/TestParametrization.java 2007-05-09 17:00:11 UTC (rev 7229)
+++ trunk/common/src/main/org/jboss/portal/common/test/TestParametrization.java 2007-05-09 19:24:04 UTC (rev 7230)
@@ -71,7 +71,7 @@
}
/**
- * Set a paraemeter value, using a null value will remove the parameter.
+ * Set a parameter value, using a null value will remove the parameter.
*
* @param parameterName the parameter name
* @param parameterValue the parameter value
18 years, 12 months
JBoss Portal SVN: r7229 - in docs/trunk/referenceGuide: en and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-05-09 13:00:11 -0400 (Wed, 09 May 2007)
New Revision: 7229
Added:
docs/trunk/referenceGuide/en/modules/workflow.xml
Modified:
docs/trunk/referenceGuide/
docs/trunk/referenceGuide/en/master.xml
docs/trunk/referenceGuide/en/modules/cmsPortlet.xml
docs/trunk/referenceGuide/en/modules/security.xml
Log:
cms security/workflow documentation
Property changes on: docs/trunk/referenceGuide
___________________________________________________________________
Name: svn:ignore
+ build
Modified: docs/trunk/referenceGuide/en/master.xml
===================================================================
--- docs/trunk/referenceGuide/en/master.xml 2007-05-09 16:47:57 UTC (rev 7228)
+++ docs/trunk/referenceGuide/en/master.xml 2007-05-09 17:00:11 UTC (rev 7229)
@@ -13,6 +13,7 @@
<!ENTITY xmldescriptors SYSTEM "modules/xmldescriptors.xml">
<!ENTITY urls SYSTEM "modules/urls.xml">
<!ENTITY CMS SYSTEM "modules/cmsPortlet.xml">
+ <!ENTITY workflow SYSTEM "modules/workflow.xml">
<!ENTITY navtabs SYSTEM "modules/navtabs.xml">
<!ENTITY themeandlayouts SYSTEM "modules/themeandlayouts.xml">
<!ENTITY ajax SYSTEM "modules/ajax.xml">
@@ -76,6 +77,7 @@
<!-- LDAP --> &ldap;
<!-- SSO --> &sso;
<!-- CMS --> &CMS;
+ <!-- Workflow --> &workflow;
<!-- NavTabs --> &navtabs;
<!-- theme/layout api --> &themeandlayouts;
<!-- ajax --> &ajax;
Modified: docs/trunk/referenceGuide/en/modules/cmsPortlet.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/cmsPortlet.xml 2007-05-09 16:47:57 UTC (rev 7228)
+++ docs/trunk/referenceGuide/en/modules/cmsPortlet.xml 2007-05-09 17:00:11 UTC (rev 7229)
@@ -336,14 +336,8 @@
or the command will never be executed.
</para>
<para>
- JBoss Portal provides two CMS interceptors out of the box, a very basic Log interceptor
- (
- <literal>org.jboss.portal.cms.impl.interceptors.LogInterceptor</literal>
- ) that prints all the commands called.
- And a cache interceptor to enable distributed caching or content (
- <literal>org.jboss.portal.cms.impl.interceptors.CacheInterceptor</literal>
- ).
- For more information about the cache interceptor, see below.
+ JBoss Portal relies on the interceptor mechanism to integrate its Fine Grained Security Service and
+ the Publish/Approve Workflow Service
</para>
<para>
To add or remove an interceptor, you just need to edit the following file:
@@ -352,32 +346,81 @@
to the cms interceptor stack. For example, if you have the 2 default interceptors, you should have the following
lines in the jboss-service.xml file:
<programlisting><![CDATA[
-<mbean
- code="org.jboss.portal.cms.impl.interceptors.LogInterceptor"
- name="portal:service=Interceptor,type=Cms,name=Log"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
-</mbean>
-<mbean
- code="org.jboss.portal.cms.impl.interceptors.CacheInterceptor"
- name="portal:service=Interceptor,type=Cms,name=Cache"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends>portal:service=CMSTreeCache</depends>
-</mbean>
-<mbean
- code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack"
- name="portal:service=InterceptorStack,type=Cms"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends-list optional-attribute-name="InterceptorNames">
- <depends-list-element>portal:service=Interceptor,type=Cms,name=Log</depends-list-element>
- <depends-list-element>portal:service=Interceptor,type=Cms,name=Cache</depends-list-element>
- </depends-list>
-</mbean>]]>
+ <!-- ACL Security Interceptor -->
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.ACLInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=ACL"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:/portal/cms/ACLInterceptor</attribute>
+ <attribute name="CmsSessionFactory">java:/portal/cms/CMSSessionFactory</attribute>
+ <attribute name="IdentitySessionFactory">java:/portal/IdentitySessionFactory</attribute>
+ <attribute name="DefaultPolicy">
+ <policy>
+ <!-- permissions on the root cms node -->
+ <criteria name="path" value="/">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the default cms node -->
+ <criteria name="path" value="/default">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the private/protected node -->
+ <criteria name="path" value="/default/private">
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ </policy>
+ </attribute>
+ <depends optional-attribute-name="AuthorizationManager" proxy-type="attribute">
+ portal:service=AuthorizationManager,type=cms
+ </depends>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
+ </mbean>
+
+ <!-- Approval Workflow Interceptor -->
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.ApprovalWorkflowInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=ApprovalWorkflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:/portal/cms/ApprovalWorkflowInterceptor</attribute>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ </mbean>
+
+ <!-- CMS Interceptor Registration -->
+ <mbean
+ code="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory"
+ name="portal:service=InterceptorStackFactory,type=Cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends-list optional-attribute-name="InterceptorNames">
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ACL</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ApprovalWorkflow</depends-list-element>
+ </depends-list>
+ </mbean>
+ ]]>
</programlisting>
The first two mbeans define the interceptors and the third mbean, define which interceptors to add to
the CMS service.
@@ -385,46 +428,105 @@
<para>
If you create your own interceptor <literal>org.example.myCMSInterceptor</literal>, the service descriptor file will look like:
<programlisting><![CDATA[
-<mbean
- code="org.example.myCMSInterceptor"
- name="portal:service=Interceptor,type=Cms,name=MyName"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
-</mbean>
-<mbean
- code="org.jboss.portal.cms.impl.interceptors.LogInterceptor"
- name="portal:service=Interceptor,type=Cms,name=Log"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
-</mbean>
-<mbean
- code="org.jboss.portal.cms.impl.interceptors.CacheInterceptor"
- name="portal:service=Interceptor,type=Cms,name=Cache"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends>portal:service=CMSTreeCache</depends>
-</mbean>
-<mbean
- code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack"
- name="portal:service=InterceptorStack,type=Cms"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends-list optional-attribute-name="InterceptorNames">
- <depends-list-element>portal:service=Interceptor,type=Cms,name=Log</depends-list-element>
- <depends-list-element>portal:service=Interceptor,type=Cms,name=Cache</depends-list-element>
- <depends-list-element>portal:service=Interceptor,type=Cms,name=MyName</depends-list-element>
- </depends-list>
-</mbean>]]></programlisting>
+ <mbean
+ code="org.example.myCMSInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=MyName"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
+ <!-- ACL Security Interceptor -->
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.ACLInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=ACL"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:/portal/cms/ACLInterceptor</attribute>
+ <attribute name="CmsSessionFactory">java:/portal/cms/CMSSessionFactory</attribute>
+ <attribute name="IdentitySessionFactory">java:/portal/IdentitySessionFactory</attribute>
+ <attribute name="DefaultPolicy">
+ <policy>
+ <!-- permissions on the root cms node -->
+ <criteria name="path" value="/">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the default cms node -->
+ <criteria name="path" value="/default">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the private/protected node -->
+ <criteria name="path" value="/default/private">
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ </policy>
+ </attribute>
+ <depends optional-attribute-name="AuthorizationManager" proxy-type="attribute">
+ portal:service=AuthorizationManager,type=cms
+ </depends>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
+ </mbean>
+
+ <!-- Approval Workflow Interceptor -->
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.ApprovalWorkflowInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=ApprovalWorkflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:/portal/cms/ApprovalWorkflowInterceptor</attribute>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory"
+ name="portal:service=InterceptorStackFactory,type=Cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends-list optional-attribute-name="InterceptorNames">
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ACL</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ApprovalWorkflow</depends-list-element>
+ </depends-list>
+ </mbean>
+
+ <!-- CMS Interceptor Registration -->
+ <mbean
+ code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack"
+ name="portal:service=InterceptorStack,type=Cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends-list optional-attribute-name="InterceptorNames">
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ACL</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ApprovalWorkflow</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=MyName</depends-list-element>
+ </depends-list>
+ </mbean>
+]]></programlisting>
</para>
<note>
<para>
- The interceptor order is important ! For example the cache interceptor may stop the call, so if you place
- the
- log interceptor after the call you wouldn't see all the commands that have been executed by the portlets.
+ The interceptor order is important !
</para>
</note>
<para>
@@ -432,41 +534,6 @@
<literal>http://localhost.localdomain:8080/jmx-console/HtmlAdaptor?action=inspectM...</literal>
You should notice all the interceptors in the attribute "interceptors".
</para>
- </section>
- <section>
- <title>CMS Cache</title>
- <para>
- The CMS cache is implemented as an interceptor, it makes it easy to be added or removed as you saw above.
- The CMS cache is available by default only if you precised
- <literal>portal.clustered = true</literal>
- in local.properties then cleaned, built and deployed the corresponding portal.
- </para>
- <!--section>
- <title>Activate caching in the "default" configuration</title>
- <para>
- To activate the caching in the default configuration you will need to have the <literal>jboss-cache.jar</literal> library
- that you can either download from www.jboss.org or get from the sources of jboss-portal. Place jboss-cache.jar in the
- server/default/lib directory or JBoss application server then add in portal-cms-sar/META-INF/jboss-service.xml the following section:
- <programlisting>
- <![CDATA[
- <mbean
- code="org.jboss.portal.cms.impl.cache.CMSTreeCacheServiceImpl"
- name="portal:service=CMSTreeCache"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
- <attribute name="CacheMode">LOCAL</attribute>
- <attribute name="JNDIName">java:/portal/cms/CMSTreeCache</attribute>
- </mbean>
- ]]>
- </programlisting>
- then remember to add the Cache interceptor as explained before.
- If it succeded you should see in server.log the following line:
- <literal>added interceptor type: org.jboss.portal.cms.impl.interceptors.CacheInterceptor</literal>
- </para>
- </section-->
- </section>
+ </section>
</section>
</chapter>
Modified: docs/trunk/referenceGuide/en/modules/security.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/security.xml 2007-05-09 16:47:57 UTC (rev 7228)
+++ docs/trunk/referenceGuide/en/modules/security.xml 2007-05-09 17:00:11 UTC (rev 7229)
@@ -121,6 +121,144 @@
<xref linkend="desc_example_portal"/>
</para>
</sect1>
+
+ <sect1 id="security.security_cms">
+ <title>Securing the Content Management System</title>
+ <para>
+ The JBoss Portal CMS system consists of a directory structure of Files organized unto their respective Folders. Both Files and Folders are
+ considered to be CMS resources that can be secured based on portal Roles and/or Users.
+ </para>
+ <para>
+ The following features are supported by the fine grained security system of Portal CMS:
+ <itemizedlist>
+ <listitem>
+ You can associate "Read", "Write", and "Manage" Permissions at the CMS node level. (Both Files and Folders are treated as CMS nodes)
+ </listitem>
+ <listitem>
+ The Permissions are propagated recursively down a folder hierarchy
+ </listitem>
+ <listitem>
+ Any Permissions specified explicitly on the CMS Node overrides the policy inherited via recursive propagation
+ </listitem>
+ <listitem>
+ You can manage the Permissions using the CMS Admin GUI tool via the newly added "Secure Node" feature
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ <emphasis role="bold">Portal CMS Permission Matrix:</emphasis>
+ <table class="wikitable" border="1">
+ <tr><th>Permission</th><th>Allowed Actions</th><th>Implies</th></tr>
+ <tr>
+ <td>Read</td>
+ <td><itemizedlist><listitem>Ability to read the contents of a Folder</listitem><listitem>Ability to read a File and its versions</listitem></itemizedlist></td>
+ <td> N/A</td>
+ </tr>
+ <tr>
+ <td>Write</td>
+ <td><itemizedlist><listitem>Ability to Create a New Folder</listitem><listitem>Ability to Update an existing Folder</listitem><listitem>Ability to Create a new File</listitem><listitem>Ability to Update an existing File</listitem></itemizedlist></td>
+ <td>Read Access</td>
+ </tr>
+ <tr>
+ <td>Manage</td>
+ <td><itemizedlist><listitem>Ability to Delete/Copy/Move/Rename Files/Folders</listitem></itemizedlist></td>
+ <td>Write and Read Access</td>
+ </tr>
+ </table>
+ </para>
+ <sect2 id="security.security_cms_configuration">
+ <title>CMS Security Configuration</title>
+ <para>
+ The configuration for the CMS Security service is specified in the jboss-portal.sar/portal-cms.sar/META-INF/jboss-service.xml file. The portion of
+ the configuration relevant for securing the CMS service is listed as follows:
+ <programlisting><![CDATA[<!-- interceptor factory where all cms interceptors are registered -->
+ <mbean
+ code="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory"
+ name="portal:service=InterceptorStackFactory,type=Cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends-list optional-attribute-name="InterceptorNames">
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ACL</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ApprovalWorkflow</depends-list-element>
+ </depends-list>
+ </mbean>
+
+ <!-- CMS Authorization Security Service -->
+ <mbean
+ code="org.jboss.portal.cms.security.AuthorizationManagerImpl"
+ name="portal:service=AuthorizationManager,type=cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:portal/cms/AuthorizationManager</attribute>
+ <depends optional-attribute-name="Provider" proxy-type="attribute">
+ portal:service=AuthorizationProvider,type=cms
+ </depends>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.cms.security.AuthorizationProviderImpl"
+ name="portal:service=AuthorizationProvider,type=cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="IdentityServiceController" proxy-type="attribute">portal:service=Module,type=IdentityServiceController</depends>
+ </mbean>
+
+ <!-- ACL Security Interceptor -->
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.ACLInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=ACL"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:/portal/cms/ACLInterceptor</attribute>
+ <attribute name="CmsSessionFactory">java:/portal/cms/CMSSessionFactory</attribute>
+ <attribute name="IdentitySessionFactory">java:/portal/IdentitySessionFactory</attribute>
+ <attribute name="DefaultPolicy">
+ <policy>
+ <!-- permissions on the root cms node -->
+ <criteria name="path" value="/">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the default cms node -->
+ <criteria name="path" value="/default">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the private/protected node -->
+ <criteria name="path" value="/default/private">
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ </policy>
+ </attribute>
+ <depends optional-attribute-name="AuthorizationManager" proxy-type="attribute">
+ portal:service=AuthorizationManager,type=cms
+ </depends>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
+ </mbean>]]>
+ </programlisting>
+ </para>
+ </sect2>
+ </sect1>
<sect1 id="security.security_authentication">
<title>Authentication with JBoss Portal</title>
Added: docs/trunk/referenceGuide/en/modules/workflow.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/workflow.xml (rev 0)
+++ docs/trunk/referenceGuide/en/modules/workflow.xml 2007-05-09 17:00:11 UTC (rev 7229)
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter id="workflow">
+ <chapterinfo>
+ <author>
+ <firstname>Sohil</firstname>
+ <surname>Shah</surname>
+ <email>sshah @ redhat dot com</email>
+ </author>
+ </chapterinfo>
+ <title>Portal Workflow</title>
+ <para>
+ JBoss Portal packages a Workflow Service based on JBPM. This service provides you with the JBPM services that your portal can use
+ to build out the end-user/application workflows that should meet your portal's requirements.
+ </para>
+ <section>
+ <title>JBPM Workflow Engine Integration</title>
+ <para>
+ The JBPM Workflow service is packaged as an mbean and takes care of all the low-level JBPM related functions. The configuration is found in
+ jboss-portal.sar/portal-cms.sar/portal-workflow.sar/META-INF/jboss-service.xml. The mbean service configuration is as follows:
+ <programlisting>
+ <![CDATA[
+ <!-- Hibernate service -->
+ <mbean
+ code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
+ name="portal:service=Hibernate,type=Workflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
+ <attribute name="DoChecking">true</attribute>
+ <attribute name="ConfigLocation">conf/hibernate/workflow/hibernate.cfg.xml</attribute>
+ <attribute name="JNDIName">java:/portal/workflow/WorkFlowSessionFactory</attribute>
+ </mbean>
+
+ <!-- Workflow service -->
+ <mbean
+ code="org.jboss.portal.workflow.service.WorkflowServiceImpl"
+ name="portal:service=Workflow,type=WorkflowService"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends>portal:service=Hibernate,type=Workflow</depends>
+ <attribute name="JbpmConfigurationXml">
+ <jbpm-configuration>
+ <jbpm-context>
+ <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory"/>
+ </jbpm-context>
+ <string name="resource.hibernate.cfg.xml" value="conf/hibernate/workflow/hibernate.cfg.xml"/>
+ <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties"/>
+ <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties"/>
+ <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties"/>
+ <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml"/>
+ <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml"/>
+ <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml"/>
+ </jbpm-configuration>
+ </attribute>
+ </mbean>
+ ]]>
+ </programlisting>
+ </para>
+ </section>
+ <section>
+ <title>CMS Publish/Approve Workflow Service</title>
+ <para>
+ The CMS Publish/Approval Workflow feature can be optionally turned on so that, every file that is created or updated needs to go through an <emphasis role="bold">Approval process</emphasis>
+ before it can be published to go Live. The current implementation, creates a pending queue for managers. The managers can then either approve or reject the publishing of the document in question.
+ </para>
+ <sect1>
+ <title>How activate this feature?</title>
+ <para>
+ In the following file, jboss-portal.sar/portal-cms.sar/META-INF/jboss-service.xml, activate this feature on the org.jboss.portal.cms.impl.jcr.JCRCMS MBean
+ <programlisting>
+ <![CDATA[
+ <mbean
+ code="org.jboss.portal.cms.impl.jcr.JCRCMS"
+ name="portal:service=CMS"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <!-- The datasource hibernate depends on, it can be commented when the file store is used -->
+ <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends>
+ <depends>portal:service=JAASLoginModule</depends>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
+ <!--depends optional-attribute-name="UserModule" proxy-type="attribute">portal:service=Module,type=User</depends-->
+
+
+
+ <!-- Uncomment 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="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>
+ <attribute name="DefaultLocale">en</attribute>
+ <attribute name="RepositoryName">PortalRepository</attribute>
+ <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
+ <attribute name="Config">
+ ]]>
+ </programlisting>
+ </para>
+ </sect1>
+ <sect1>
+ <title>How to configure this feature?</title>
+ <para>
+ The configuration for this workflow service is found in the jboss-portal.sar/portal-cms.sar/portal-workflow.sar/META-INF/jboss-service.xml
+ file
+ <programlisting>
+ <![CDATA[
+ <!-- ApprovePublish workflow service -->
+ <mbean
+ code="org.jboss.portal.workflow.cms.ApprovePublishImpl"
+ name="portal:service=ApprovePublish,type=Workflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="WorkflowService" proxy-type="attribute">
+ portal:service=Workflow,type=WorkflowService
+ </depends>
+ <depends optional-attribute-name="IdentityServiceController" proxy-type="attribute">
+ portal:service=Module,type=IdentityServiceController
+ </depends>
+ <!-- JBPM process definition -->
+ <attribute name="Process">
+ <!-- cms approval workflow -->
+ <process-definition name="approval_workflow">
+ <start-state>
+ <transition to="request_approval"/>
+ </start-state>
+ <task-node name="request_approval" signal="first">
+ <task name="approve_publish">
+ <assignment class="org.jboss.portal.cms.workflow.PublishAssignmentHandler"/>
+ <event type="task-start">
+ <action class="org.jboss.portal.cms.workflow.FinalizePublish"/>
+ </event>
+ <exception-handler>
+ <action class="org.jboss.portal.workflow.cms.TaskExceptionHandler"/>
+ </exception-handler>
+ </task>
+ <transition name="approval" to="end"/>
+ <transition name="rejection" to="end"/>
+ </task-node>
+ <end-state name="end"/>
+ </process-definition>
+ </attribute>
+ <!--
+ overwrite = false creates the process first time if does not exist, for
+ subsequent server restarts, this process definition remains in tact
+
+ overwrite = true creates the process first time if does not exist,
+ for subsequent server restarts, it creates a new version of the process definition
+ which will be used for processes created from then onwards. Old processes created
+ for an older version of the definition remain in tact and use their corresponding
+ process definition.
+
+ Typically use overwrite=false and overwrite=true only when a new process definition
+ related to this workflow needs to be deployed
+ -->
+ <attribute name="Overwrite">false</attribute>
+ <!--
+ a comma separated list of portal roles that are designated
+ to act as workflow managers. They are allowed to
+ approve/reject content publish requests
+ -->
+ <attribute name="ManagerRoles">Admin</attribute>
+ <attribute name="JNDIName">java:portal/ApprovePublishWorkflow</attribute>
+ </mbean>
+ ]]>
+ </programlisting>
+ </para>
+ </sect1>
+ </section>
+</chapter>
Property changes on: docs/trunk/referenceGuide/en/modules/workflow.xml
___________________________________________________________________
Name: svn:executable
+ *
18 years, 12 months