Author: chris.laprun(a)jboss.com
Date: 2010-10-06 18:59:10 -0400 (Wed, 06 Oct 2010)
New Revision: 4563
Added:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java
Modified:
portal/trunk/component/wsrp/pom.xml
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java
portal/trunk/pom.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
Log:
- Merged from wsrp2-integration, ignoring temporary fix (rev. 4466) for issue with commit
4242 (svn merge -r4466:4562
https://svn.jboss.org/repos/gatein/portal/branches/wsrp2-integration)
+ Udated to use PC 2.2.0-Beta05 and WSRP 2.0.0-Beta01
+ Use AbstractWindowContext instead of ExoWindowContext since there wasn't any
discernible advantage to using a custom implementation at this point.
+ Adapted for API changes
+ GTNPORTAL-1529: Fixed inconsitent parameters in JCRPersister.delete method
+ Introduced BaseMapping to gather common behavior and possibly extends JCRPersister
with more generic methods down the road
Modified: portal/trunk/component/wsrp/pom.xml
===================================================================
--- portal/trunk/component/wsrp/pom.xml 2010-10-06 21:35:50 UTC (rev 4562)
+++ portal/trunk/component/wsrp/pom.xml 2010-10-06 22:59:10 UTC (rev 4563)
@@ -21,7 +21,8 @@
~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component</artifactId>
@@ -125,6 +126,17 @@
<build>
<plugins>
+ <!--<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <excludes>
+
<exclude>org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java</exclude>
+
<exclude>org/gatein/portal/wsrp/MOPPortalStructureProvider.java</exclude>
+
<exclude>org/gatein/portal/wsrp/state/migration/**/*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -41,7 +41,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.StatefulPortletContext;
-import org.gatein.wsrp.api.PortalStructureProvider;
+import org.gatein.wsrp.api.context.ConsumerStructureProvider;
import java.util.Collection;
import java.util.Collections;
@@ -54,7 +54,7 @@
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
*/
-public class MOPPortalStructureProvider implements PortalStructureProvider
+public class MOPPortalStructureProvider implements ConsumerStructureProvider
{
private final POMSessionManager pomManager;
private Map<String, PageInfo> pageInfos;
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -26,9 +26,9 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.listener.Event;
import org.exoplatform.services.listener.Listener;
-import org.gatein.wsrp.api.SessionEvent;
-import org.gatein.wsrp.api.SessionEventBroadcaster;
-import org.gatein.wsrp.api.SessionEventListener;
+import org.gatein.wsrp.api.session.SessionEvent;
+import org.gatein.wsrp.api.session.SessionEventBroadcaster;
+import org.gatein.wsrp.api.session.SessionEventListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -22,6 +22,7 @@
package org.gatein.portal.wsrp.state;
+import EDU.oswego.cs.dl.util.concurrent.FJTask;
import org.chromattic.api.Chromattic;
import org.chromattic.api.ChromatticBuilder;
import org.chromattic.api.ChromatticSession;
@@ -33,11 +34,17 @@
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.common.SessionProvider;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.portal.wsrp.state.mapping.BaseMapping;
import javax.jcr.Credentials;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -50,6 +57,7 @@
public static final String PORTLET_STATES_WORKSPACE_NAME = "pc-system";
private static final String REPOSITORY_NAME = "repository";
private String workspaceName;
+ private Map<Class, Class<? extends BaseMapping>> modelToMapping;
public JCRPersister(ExoContainer container, String workspaceName)
{
@@ -73,8 +81,18 @@
throw new IllegalArgumentException("Unknown workspace name: '" +
workspaceName + "'");
}
+ modelToMapping = new HashMap<Class, Class<? extends
BaseMapping>>(mappingClasses.size());
for (Class mappingClass : mappingClasses)
{
+ if (BaseMapping.class.isAssignableFrom(mappingClass))
+ {
+ Type[] interfaces = mappingClass.getGenericInterfaces();
+ if(ParameterValidation.existsAndIsNotEmpty(interfaces))
+ {
+ Class type =
(Class)((ParameterizedType)interfaces[0]).getActualTypeArguments()[0];
+ modelToMapping.put(type, mappingClass);
+ }
+ }
builder.add(mappingClass);
}
@@ -102,9 +120,16 @@
public <T> boolean delete(T toDelete, StoresByPathManager<T> manager)
{
+ Class<? extends Object> modelClass = toDelete.getClass();
+ Class<? extends BaseMapping> baseMappingClass =
modelToMapping.get(modelClass);
+ if(baseMappingClass == null)
+ {
+ throw new IllegalArgumentException("Cannot find a mapping class for "
+ modelClass.getName());
+ }
+
ChromatticSession session = getSession();
- Object old = session.findByPath(toDelete.getClass(),
manager.getChildPath(toDelete));
+ Object old = session.findByPath(baseMappingClass, manager.getChildPath(toDelete));
if (old != null)
{
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -205,7 +205,7 @@
public ProducerInfo next()
{
- return mappings.next().toProducerInfo();
+ return mappings.next().toModel(null);
}
public void remove()
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -24,6 +24,7 @@
package org.gatein.portal.wsrp.state.consumer.mapping;
import org.chromattic.api.annotations.*;
+import org.gatein.portal.wsrp.state.mapping.BaseMapping;
import org.gatein.wsrp.consumer.EndpointConfigurationInfo;
import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.RegistrationInfo;
@@ -33,7 +34,7 @@
* @version $Revision$
*/
@PrimaryType(name = ProducerInfoMapping.NODE_NAME)
-public abstract class ProducerInfoMapping
+public abstract class ProducerInfoMapping implements BaseMapping<ProducerInfo>
{
public static final String NODE_NAME = "wsrp:producerinfo";
@@ -84,7 +85,7 @@
rim.initFrom(regInfo);
}
- public ProducerInfo toProducerInfo()
+ public ProducerInfo toModel(ProducerInfo initial)
{
// todo: should probably use a ProducerInfo implementation backed by mapping at
some point
ProducerInfo info = new ProducerInfo();
Copied:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java
(from rev 4562,
portal/branches/wsrp2-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java)
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java
(rev 0)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -0,0 +1,34 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.gatein.portal.wsrp.state.mapping;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public interface BaseMapping<T>
+{
+ void initFrom(T model);
+
+ T toModel(T initial);
+}
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -32,7 +32,7 @@
import org.gatein.portal.wsrp.state.migration.mapping.ExportInfoMapping;
import org.gatein.portal.wsrp.state.migration.mapping.ExportInfosMapping;
import org.gatein.portal.wsrp.state.migration.mapping.ExportedStateMapping;
-import org.gatein.wsrp.api.PortalStructureProvider;
+import org.gatein.wsrp.api.context.ConsumerStructureProvider;
import org.gatein.wsrp.consumer.migration.ExportInfo;
import org.gatein.wsrp.consumer.migration.MigrationService;
@@ -46,7 +46,7 @@
*/
public class JCRMigrationService implements MigrationService,
StoresByPathManager<ExportInfo>
{
- private PortalStructureProvider structureProvider;
+ private ConsumerStructureProvider structureProvider;
private JCRPersister persister;
private static final String EXPORT_INFOS_PATH = ExportInfosMapping.NODE_NAME;
private int exportInfosCount = -1;
@@ -61,12 +61,12 @@
persister.initializeBuilderFor(mappingClasses);
}
- public PortalStructureProvider getStructureProvider()
+ public ConsumerStructureProvider getStructureProvider()
{
return structureProvider;
}
- public void setStructureProvider(PortalStructureProvider structureProvider)
+ public void setStructureProvider(ConsumerStructureProvider structureProvider)
{
ParameterValidation.throwIllegalArgExceptionIfNull(structureProvider,
"PortalStructureProvider");
this.structureProvider = structureProvider;
@@ -82,7 +82,7 @@
List<ExportInfo> exportInfos = new
ArrayList<ExportInfo>(exportInfoMappings.size());
for (ExportInfoMapping eim : exportInfoMappings)
{
- exportInfos.add(eim.toExportInfo());
+ exportInfos.add(eim.toModel(null));
}
persister.closeSession(session, false);
@@ -112,7 +112,7 @@
if(eim != null)
{
- return eim.toExportInfo();
+ return eim.toModel(null);
}
else
{
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java
===================================================================
---
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -29,6 +29,7 @@
import org.chromattic.api.annotations.Property;
import org.exoplatform.commons.utils.Safe;
import org.gatein.portal.wsrp.state.JCRPersister;
+import org.gatein.portal.wsrp.state.mapping.BaseMapping;
import org.gatein.wsrp.consumer.migration.ExportInfo;
import javax.xml.namespace.QName;
@@ -44,7 +45,7 @@
* @version $Revision$
*/
@PrimaryType(name = ExportInfoMapping.NODE_NAME)
-public abstract class ExportInfoMapping
+public abstract class ExportInfoMapping implements BaseMapping<ExportInfo>
{
public static final String NODE_NAME = "wsrp:exportinfo";
@@ -118,7 +119,7 @@
}
}
- public ExportInfo toExportInfo()
+ public ExportInfo toModel(ExportInfo initial)
{
List<ExportedStateMapping> exportedStates = getExportedStates();
SortedMap<String, byte[]> states = new TreeMap<String,byte[]>();
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-10-06 21:35:50 UTC (rev 4562)
+++ portal/trunk/pom.xml 2010-10-06 22:59:10 UTC (rev 4563)
@@ -46,9 +46,9 @@
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.3-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.2-GA</org.gatein.wci.version>
- <org.gatein.pc.version>2.2.0-Beta04</org.gatein.pc.version>
+ <org.gatein.pc.version>2.2.0-Beta05</org.gatein.pc.version>
<org.picketlink.idm>1.1.6.GA</org.picketlink.idm>
- <org.gatein.wsrp.version>2.0.0-Alpha03</org.gatein.wsrp.version>
+ <org.gatein.wsrp.version>2.0.0-Beta01</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
<rhino.version>1.6R5</rhino.version>
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -1,16 +1,16 @@
/**
* Copyright (C) 2009 eXo Platform SAS.
- *
+ *
* 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
@@ -19,18 +19,15 @@
package org.exoplatform.portal.webui.application;
-import org.gatein.pc.api.spi.WindowContext;
+import org.gatein.pc.portlet.impl.spi.AbstractWindowContext;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ExoWindowContext implements WindowContext
+public class ExoWindowContext extends AbstractWindowContext
{
- /** . */
- private final String windowId;
-
/**
* Create a new window context.
*
@@ -39,15 +36,6 @@
*/
public ExoWindowContext(String windowId) throws NullPointerException
{
- if (windowId == null)
- {
- throw new NullPointerException();
- }
- this.windowId = windowId;
+ super(windowId);
}
-
- public String getId()
- {
- return windowId;
- }
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-10-06
21:35:50 UTC (rev 4562)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-10-06
22:59:10 UTC (rev 4563)
@@ -76,6 +76,7 @@
import org.gatein.pc.portlet.impl.spi.AbstractRequestContext;
import org.gatein.pc.portlet.impl.spi.AbstractSecurityContext;
import org.gatein.pc.portlet.impl.spi.AbstractServerContext;
+import org.gatein.pc.portlet.impl.spi.AbstractWindowContext;
import java.io.Serializable;
import java.util.ArrayList;
@@ -812,7 +813,7 @@
invocation.setServerContext(new AbstractServerContext(servletRequest,
prc.getResponse()));
//TODO: ExoUserContext impl not tested
invocation.setUserContext(new ExoUserContext(servletRequest, userProfile));
- invocation.setWindowContext(new ExoWindowContext(storageName));
+ invocation.setWindowContext(new AbstractWindowContext(storageName));
invocation.setPortalContext(new AbstractPortalContext(Collections.singletonMap(
"javax.portlet.markup.head.element.support", "true")));
invocation.setSecurityContext(new AbstractSecurityContext(servletRequest));