Author: julien_viet
Date: 2011-09-07 09:54:58 -0400 (Wed, 07 Sep 2011)
New Revision: 7330
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/pages.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/portal.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/pages.xml
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/portal.xml
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/conf/configuration.xml
Log:
GTNPORTAL-2083 : A site should not be overwritten when the workspace import marker is not
present
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java 2011-09-07
12:12:19 UTC (rev 7329)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java 2011-09-07
13:54:58 UTC (rev 7330)
@@ -20,6 +20,8 @@
package org.exoplatform.portal.config;
import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
/**
* Author : Nhu Dinh Thuan
@@ -43,6 +45,8 @@
private String importMode;
+ final Set<String> createdOwners = new HashSet<String>();
+
/**
* @deprecated use the location instead
*/
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-09-07
12:12:19 UTC (rev 7329)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-09-07
13:54:58 UTC (rev 7330)
@@ -433,7 +433,10 @@
{
for (String owner : config.getPredefinedOwner())
{
- createPortalConfig(config, owner);
+ if (createPortalConfig(config, owner))
+ {
+ config.createdOwners.add(owner);
+ }
}
}
@@ -441,7 +444,10 @@
{
for (String owner : config.getPredefinedOwner())
{
- createPage(config, owner);
+ if (config.createdOwners.contains(owner))
+ {
+ createPage(config, owner);
+ }
}
}
@@ -464,50 +470,48 @@
}
}
- public void createPortalConfig(NewPortalConfig config, String owner) throws Exception
+ public boolean createPortalConfig(NewPortalConfig config, String owner) throws
Exception
{
- try
+ String type = config.getOwnerType();
+ PortalConfig currentPortalConfig = dataStorage_.getPortalConfig(type, owner);
+ if (currentPortalConfig == null)
{
- String type = config.getOwnerType();
- UnmarshalledObject<PortalConfig> obj = getConfig(config, owner, type,
PortalConfig.class);
+ try
+ {
+ UnmarshalledObject<PortalConfig> obj = getConfig(config, owner, type,
PortalConfig.class);
- if (obj == null)
- {
- // Ensure that the PortalConfig has been defined
- // The PortalConfig could be empty if the related PortalConfigListener
- // has been launched after starting this service
- PortalConfig cfg = dataStorage_.getPortalConfig(type, owner);
- if (cfg == null)
+ if (obj == null)
{
- cfg = new PortalConfig(type);
- cfg.setPortalLayout(new Container());
- cfg.setName(owner);
- dataStorage_.create(cfg);
+ // Ensure that the PortalConfig has been defined
+ // The PortalConfig could be empty if the related PortalConfigListener
+ // has been launched after starting this service
+ PortalConfig cfg = dataStorage_.getPortalConfig(type, owner);
+ if (cfg == null)
+ {
+ cfg = new PortalConfig(type);
+ cfg.setPortalLayout(new Container());
+ cfg.setName(owner);
+ dataStorage_.create(cfg);
+ return true;
+ }
}
- return;
+ else
+ {
+ PortalConfig pconfig = obj.getObject();
+ // We use that owner value because it may have been fixed for group names
+ owner = pconfig.getName();
+ dataStorage_.create(pconfig);
+ return true;
+ }
}
-
- //
- PortalConfig pconfig = obj.getObject();
-
- // We use that owner value because it may have been fixed for group names
- owner = pconfig.getName();
-
- //
- PortalConfig currentPortalConfig = dataStorage_.getPortalConfig(type, owner);
- if (currentPortalConfig == null)
+ catch (IOException e)
{
- dataStorage_.create(pconfig);
+ log.error("Could not load portal configuration", e);
}
- else
- {
- dataStorage_.save(pconfig);
- }
}
- catch (IOException e)
- {
- log.error("Could not load portal configuration", e);
- }
+
+ //
+ return false;
}
public void createPage(NewPortalConfig config, String owner) throws Exception
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-09-07
12:12:19 UTC (rev 7329)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestImport.java 2011-09-07
13:54:58 UTC (rev 7330)
@@ -24,6 +24,11 @@
import org.exoplatform.component.test.KernelBootstrap;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.importer.Imported;
import org.exoplatform.portal.mop.navigation.NavigationContext;
@@ -32,6 +37,7 @@
import org.exoplatform.portal.mop.navigation.NodeContext;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.gatein.mop.api.workspace.Workspace;
import java.io.File;
@@ -99,4 +105,70 @@
RequestLifeCycle.end();
bootstrap.dispose();
}
+
+ public void testNoMixin() 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/TestImport1-configuration.xml");
+
+ //
+ System.setProperty("override.1", "false");
+ System.setProperty("import.mode.1", "conserve");
+ System.setProperty("import.portal.1", "site1");
+
+ //
+ bootstrap.boot();
+ PortalContainer container = bootstrap.getContainer();
+ DataStorage service =
(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ RequestLifeCycle.begin(container);
+ POMSessionManager mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ Workspace workspace = mgr.getSession().getWorkspace();
+ assertTrue(workspace.isAdapted(Imported.class));
+ long when1 = workspace.adapt(Imported.class).getCreationDate().getTime();
+ PortalConfig portal = service.getPortalConfig("classic");
+ Container layout = portal.getPortalLayout();
+ assertEquals(1, layout.getChildren().size());
+ Application<Portlet> layoutPortlet =
(Application<Portlet>)layout.getChildren().get(0);
+ assertEquals("site1/layout", service.getId(layoutPortlet.getState()));
+ Page page1 = service.getPage("portal::classic::page1");
+ assertEquals(1, page1.getChildren().size());
+ Application<Portlet> page1Portlet =
(Application<Portlet>)page1.getChildren().get(0);
+ assertEquals("site1/page1", service.getId(page1Portlet.getState()));
+ workspace.removeAdapter(Imported.class);
+ mgr.getSession().save();
+ RequestLifeCycle.end();
+ bootstrap.dispose();
+
+ //
+ System.setProperty("override.1", "false");
+ System.setProperty("import.mode.1", "conserve");
+ System.setProperty("import.portal.1", "site2");
+
+ //
+ bootstrap.boot();
+ container = bootstrap.getContainer();
+ service = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ RequestLifeCycle.begin(container);
+ mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ workspace = mgr.getSession().getWorkspace();
+ assertTrue(workspace.isAdapted(Imported.class));
+ long when2 = workspace.adapt(Imported.class).getCreationDate().getTime();
+ assertTrue(when2 > when1);
+ portal = service.getPortalConfig("classic");
+ layout = portal.getPortalLayout();
+ assertEquals(1, layout.getChildren().size());
+ layoutPortlet = (Application<Portlet>)layout.getChildren().get(0);
+ assertEquals("site1/layout", service.getId(layoutPortlet.getState()));
+ page1 = service.getPage("portal::classic::page1");
+ assertEquals(1, page1.getChildren().size());
+ page1Portlet = (Application<Portlet>)page1.getChildren().get(0);
+ assertEquals("site1/page1", service.getId(page1Portlet.getState()));
+ Page page2 = service.getPage("portal::classic::page2");
+ assertNull(page2);
+ RequestLifeCycle.end();
+ bootstrap.dispose();
+ }
}
Modified:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/conf/configuration.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/conf/configuration.xml 2011-09-07
12:12:19 UTC (rev 7329)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/conf/configuration.xml 2011-09-07
13:54:58 UTC (rev 7330)
@@ -130,6 +130,7 @@
</field>
</object>
</object-param>
+<!--
<object-param>
<name>user.configuration</name>
<object type="org.exoplatform.portal.config.NewPortalConfig">
@@ -148,6 +149,7 @@
</field>
</object>
</object-param>
+-->
</init-params>
</component-plugin>
</external-component-plugins>
@@ -298,6 +300,18 @@
</field>
</object>
</value>
+ <value>
+ <object
type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field
name="userName"><string>overwritelayout</string></field>
+ <field
name="password"><string>gtn</string></field>
+ <field
name="firstName"><string>Overwrite</string></field>
+ <field
name="lastName"><string>Layout</string></field>
+ <field
name="email"><string>overwrite@localhost</string></field>
+ <field name="groups">
+ <string>member:/platform/users</string>
+ </field>
+ </object>
+ </value>
</collection>
</field>
</object>
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/pages.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/pages.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/pages.xml 2011-09-07
13:54:58 UTC (rev 7330)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+
+<page-set
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
+
+ <page>
+ <name>page1</name>
+ <portlet-application>
+ <portlet>
+ <application-ref>site1</application-ref>
+ <portlet-ref>page1</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ </portlet-application>
+ </page>
+
+</page-set>
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/portal.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/portal.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site1-conf/portal/classic/portal.xml 2011-09-07
13:54:58 UTC (rev 7330)
@@ -0,0 +1,41 @@
+<?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.
+
+-->
+
+<portal-config
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <portal-name>classic</portal-name>
+ <locale>en</locale>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <portal-layout>
+ <portlet-application>
+ <portlet>
+ <application-ref>site1</application-ref>
+ <portlet-ref>layout</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ </portlet-application>
+ </portal-layout>
+</portal-config>
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/pages.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/pages.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/pages.xml 2011-09-07
13:54:58 UTC (rev 7330)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+
+<page-set
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
+
+ <page>
+ <name>page1</name>
+ <portlet-application>
+ <portlet>
+ <application-ref>site2</application-ref>
+ <portlet-ref>page1</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ </portlet-application>
+ </page>
+
+ <page>
+ <name>page2</name>
+ <portlet-application>
+ <portlet>
+ <application-ref>site2</application-ref>
+ <portlet-ref>page2</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ </portlet-application>
+ </page>
+
+</page-set>
Added:
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/portal.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/portal.xml
(rev 0)
+++
portal/trunk/component/portal/src/test/resources/org/exoplatform/portal/config/site2-conf/portal/classic/portal.xml 2011-09-07
13:54:58 UTC (rev 7330)
@@ -0,0 +1,41 @@
+<?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.
+
+-->
+
+<portal-config
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2
http://www.gatein.org/xml/ns/gatein_objects_1_2"
+
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <portal-name>classic</portal-name>
+ <locale>en</locale>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <portal-layout>
+ <portlet-application>
+ <portlet>
+ <application-ref>site2</application-ref>
+ <portlet-ref>layout</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ </portlet-application>
+ </portal-layout>
+</portal-config>