Author: julien_viet
Date: 2011-08-31 08:39:59 -0400 (Wed, 31 Aug 2011)
New Revision: 7262
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java
portal/trunk/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
Log:
GTNPORTAL-2054 : Navigation default import mode should be configurable for component
plugins and set by default to merge
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-08-31
10:33:33 UTC (rev 7261)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-08-31
12:39:59 UTC (rev 7262)
@@ -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:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2011-08-31
10:33:33 UTC (rev 7261)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2011-08-31
12:39:59 UTC (rev 7262)
@@ -32,6 +32,7 @@
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.SiteType;
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;
@@ -72,6 +73,9 @@
/** . */
boolean destroyUserPortal;
+ /** . */
+ private final ImportMode defaultImportMode;
+
private Log log = ExoLogger.getLogger("Portal:UserPortalConfigService");
public UserPortalConfigService(
@@ -92,6 +96,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;
@@ -99,8 +107,14 @@
this.descriptionService = descriptionService;
this.createUserPortal = createUserPortal;
this.destroyUserPortal = destroyUserPortal;
+ this.defaultImportMode = defaultImportMode;
}
+ public ImportMode getDefaultImportMode()
+ {
+ return defaultImportMode;
+ }
+
public boolean getCreateUserPortal()
{
return createUserPortal;
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2011-08-31
10:33:33 UTC (rev 7261)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationServiceImpl.java 2011-08-31
12:39:59 UTC (rev 7262)
@@ -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:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java 2011-08-31
10:33:33 UTC (rev 7261)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java 2011-08-31
12:39:59 UTC (rev 7262)
@@ -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:
portal/trunk/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml 2011-08-31
10:33:33 UTC (rev 7261)
+++
portal/trunk/component/portal/src/test/resources/conf/exo.portal.component.portal-configuration.xml 2011-08-31
12:39:59 UTC (rev 7262)
@@ -119,6 +119,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>
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/TestImport0-configuration.xml 2011-08-31
12:39:59 UTC (rev 7262)
@@ -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:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-08-31
10:33:33 UTC (rev 7261)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-08-31
12:39:59 UTC (rev 7262)
@@ -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>