Author: thomas.heute(a)jboss.com
Date: 2010-10-07 02:23:15 -0400 (Thu, 07 Oct 2010)
New Revision: 4568
Added:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java
Modified:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
Log:
JBEPP-506: Merge WSRP-2 changes
Modified: epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml 2010-10-07 03:43:39 UTC (rev
4567)
+++ epp/portal/branches/EPP_5_1_Branch/component/wsrp/pom.xml 2010-10-07 06:23:15 UTC (rev
4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPPortalStructureProvider.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -205,7 +205,7 @@
public ProducerInfo next()
{
- return mappings.next().toProducerInfo();
+ return mappings.next().toModel(null);
}
public void remove()
Modified:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java
(from rev 4563,
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java)
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java
(rev 0)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/mapping/BaseMapping.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/mapping/ExportInfoMapping.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoWindowContext.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-10-07
03:43:39 UTC (rev 4567)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-10-07
06:23:15 UTC (rev 4568)
@@ -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));