Author: theute
Date: 2011-09-01 12:26:40 -0400 (Thu, 01 Sep 2011)
New Revision: 7280
Added:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml
Modified:
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
Log:
JBEPP-1129: Navigation is not being imported on fresh installation for multiple extensions
targeting the same site's navigation.
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1790/component:5871
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7095,7117,7125,7132-7134,7210
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1790/component:5871
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7095,7117,7125,7132-7134,7210,7262
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-09-01
16:13:48 UTC (rev 7279)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-09-01
16:26:40 UTC (rev 7280)
@@ -40,7 +40,6 @@
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.UnmarshalledObject;
-import org.exoplatform.portal.config.model.Version;
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.pom.config.POMSession;
@@ -70,6 +69,9 @@
{
/** . */
+ private final UserPortalConfigService owner_;
+
+ /** . */
private ConfigurationManager cmanager_;
/** . */
@@ -115,6 +117,7 @@
private DescriptionService descriptionService_;
public NewPortalConfigListener(
+ UserPortalConfigService owner,
POMSessionManager pomMgr,
DataStorage dataStorage,
ConfigurationManager cmanager,
@@ -123,6 +126,7 @@
DescriptionService descriptionService)
throws Exception
{
+ owner_ = owner;
cmanager_ = cmanager;
dataStorage_ = dataStorage;
navigationService_ = navigationService;
@@ -538,7 +542,6 @@
//
PageNavigation navigation = obj.getObject();
- boolean extendedNavigation = obj.getVersion() == Version.V_1_2;
//
ImportMode importMode;
@@ -548,7 +551,7 @@
}
else
{
- importMode = ImportMode.CONSERVE;
+ importMode = owner_.getDefaultImportMode();
}
//
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2011-09-01
16:13:48 UTC (rev 7279)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2011-09-01
16:26:40 UTC (rev 7280)
@@ -31,6 +31,7 @@
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.importer.ImportMode;
import org.exoplatform.portal.mop.navigation.NavigationContext;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.mop.navigation.NavigationState;
@@ -71,6 +72,9 @@
/** . */
boolean destroyUserPortal;
+ /** . */
+ private final ImportMode defaultImportMode;
+
private Log log = ExoLogger.getLogger("Portal:UserPortalConfigService");
public UserPortalConfigService(
@@ -91,6 +95,10 @@
boolean destroyUserPortal = destroyUserPortalParam == null ||
destroyUserPortalParam.getValue().toLowerCase().trim().equals("true");
//
+ ValueParam defaultImportModeParam = params == null ? null :
params.getValueParam("default.import.mode");
+ ImportMode defaultImportMode = defaultImportModeParam == null ? ImportMode.CONSERVE
: ImportMode.valueOf(defaultImportModeParam.getValue().toUpperCase().trim());
+
+ //
this.storage_ = storage;
this.orgService_ = orgService;
this.userACL_ = userACL;
@@ -98,8 +106,14 @@
this.descriptionService = descriptionService;
this.createUserPortal = createUserPortal;
this.destroyUserPortal = destroyUserPortal;
+ this.defaultImportMode = defaultImportMode;
}
+ public ImportMode getDefaultImportMode()
+ {
+ return defaultImportMode;
+ }
+
public boolean getCreateUserPortal()
{
return createUserPortal;
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2011-09-01
16:13:48 UTC (rev 7279)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2011-09-01
16:26:40 UTC (rev 7280)
@@ -195,15 +195,15 @@
{
if (model == null)
{
- throw new NullPointerException();
+ throw new NullPointerException("No null model accepted");
}
if (navigation == null)
{
- throw new NullPointerException();
+ throw new NullPointerException("No null navigation accepted");
}
if (scope == null)
{
- throw new NullPointerException();
+ throw new NullPointerException("No null scope accepted");
}
String nodeId = navigation.data.rootId;
if (navigation.data.rootId != null)
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java 2011-09-01
16:13:48 UTC (rev 7279)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java 2011-09-01
16:26:40 UTC (rev 7280)
@@ -24,10 +24,19 @@
import org.exoplatform.component.test.KernelBootstrap;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.importer.Imported;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.Node;
+import org.exoplatform.portal.mop.navigation.NodeContext;
+import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.pom.config.POMSessionManager;
import org.gatein.mop.api.workspace.Workspace;
+import java.io.File;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
*/
@@ -59,4 +68,35 @@
RequestLifeCycle.end();
bootstrap.dispose();
}
+
+ public void testDefaultMode() throws Exception
+ {
+ KernelBootstrap bootstrap = new KernelBootstrap();
+ bootstrap.addConfiguration(ContainerScope.PORTAL,
"conf/exo.portal.component.test.jcr-configuration.xml");
+ bootstrap.addConfiguration(ContainerScope.PORTAL,
"conf/exo.portal.component.identity-configuration.xml");
+ bootstrap.addConfiguration(ContainerScope.PORTAL,
"conf/exo.portal.component.portal-configuration.xml");
+ bootstrap.addConfiguration(ContainerScope.PORTAL,
"org/exoplatform/portal/config/TestImport0-configuration.xml");
+ bootstrap.addConfiguration(ContainerScope.PORTAL,
"org/exoplatform/portal/config/TestImport1-configuration.xml");
+ System.setProperty("import.portal.0", "navigation2");
+ System.setProperty("override.1", "false");
+ System.setProperty("import.mode.1", "merge");
+ System.setProperty("import.portal.1", "navigation1");
+
+ //
+ bootstrap.boot();
+
+ //
+ PortalContainer container = bootstrap.getContainer();
+ NavigationService service =
(NavigationService)container.getComponentInstanceOfType(NavigationService.class);
+ RequestLifeCycle.begin(container);
+ NavigationContext nav =
service.loadNavigation(SiteKey.portal("classic"));
+ NodeContext<Node> root = service.loadNode(Node.MODEL, nav, Scope.ALL, null);
+ Collection<Node> c = root.getNodes();
+ assertEquals(3, c.size());
+ assertNotNull(root.get("foo"));
+ assertNotNull(root.get("daa"));
+ assertNotNull(root.get("bar"));
+ RequestLifeCycle.end();
+ bootstrap.dispose();
+ }
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml 2011-09-01
16:13:48 UTC (rev 7279)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml 2011-09-01
16:26:40 UTC (rev 7280)
@@ -114,6 +114,12 @@
<component>
<key>org.exoplatform.portal.config.UserPortalConfigService</key>
<type>org.exoplatform.portal.config.UserPortalConfigService</type>
+ <init-params>
+ <value-param>
+ <name>default.import.mode</name>
+ <value>merge</value>
+ </value-param>
+ </init-params>
</component>
<external-component-plugins>
Copied:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml
(from rev 7262,
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml)
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml
(rev 0)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml 2011-09-01
16:26:40 UTC (rev 7280)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Copyright (C) 2011 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
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd
http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
+
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
+
+ <external-component-plugins>
+
<target-component>org.exoplatform.portal.config.UserPortalConfigService</target-component>
+ <component-plugin>
+ <name>new.portal.config.user.listener</name>
+ <set-method>initListener</set-method>
+ <type>org.exoplatform.portal.config.NewPortalConfigListener</type>
+ <priority>1</priority>
+ <init-params>
+ <value-param>
+ <name>default.portal</name>
+ <value>classic</value>
+ </value-param>
+ <object-param>
+ <name>portal.configuration</name>
+ <object type="org.exoplatform.portal.config.NewPortalConfig">
+ <field name="predefinedOwner">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>classic</string>
+ </value>
+ </collection>
+ </field>
+ <field name="ownerType">
+ <string>portal</string>
+ </field>
+ <field name="templateLocation">
+
<string>classpath:/org/exoplatform/portal/config/${import.portal.0}-conf</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
Modified:
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-09-01
16:13:48 UTC (rev 7279)
+++
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-09-01
16:26:40 UTC (rev 7280)
@@ -226,6 +226,10 @@
<name>destroy.user.portal</name>
<value>${gatein.portal.idm.destroyserportal}</value>
</value-param>
+ <value-param>
+ <name>default.import.mode</name>
+ <value>merge</value>
+ </value-param>
</init-params>
</component>