Author: trong.tran
Date: 2010-02-10 07:54:25 -0500 (Wed, 10 Feb 2010)
New Revision: 1616
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java
Removed:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java
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/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
Log:
GTNPORTAL-598 Add supporting to be able configuring portal templates from the extension
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 2010-02-10
10:55:19 UTC (rev 1615)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java 2010-02-10
12:54:25 UTC (rev 1616)
@@ -33,8 +33,14 @@
private String ownerType;
- private String templateOwner;
+ private String templateName;
+ private String location;
+
+ /**
+ * @deprecated use the location instead
+ */
+ @Deprecated
private String templateLocation;
public NewPortalConfig()
@@ -45,10 +51,16 @@
{
this.ownerType = cfg.ownerType;
this.templateLocation = cfg.templateLocation;
- this.templateOwner = cfg.templateOwner;
+ this.location = cfg.location;
+ this.templateName = cfg.templateName;
this.predefinedOwner = new HashSet<String>(cfg.predefinedOwner);
}
+ public NewPortalConfig(String path)
+ {
+ this.location = path;
+ }
+
public HashSet<String> getPredefinedOwner()
{
return predefinedOwner;
@@ -59,24 +71,44 @@
this.predefinedOwner = s;
}
+ /**
+ * @return the location
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * @param location the location to set
+ */
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
+
public String getTemplateLocation()
{
- return templateLocation;
+ if (location != null)
+ return location;
+ else
+ return templateLocation;
}
public void setTemplateLocation(String s)
{
+ this.location = s;
this.templateLocation = s;
}
- public String getTemplateOwner()
+ public String getTemplateName()
{
- return templateOwner;
+ return templateName;
}
- public void setTemplateOwner(String s)
+ public void setTemplateName(String s)
{
- this.templateOwner = s;
+ this.templateName = s;
}
public boolean isPredefinedOwner(String user)
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 2010-02-10
10:55:19 UTC (rev 1615)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2010-02-10
12:54:25 UTC (rev 1616)
@@ -44,10 +44,10 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
/**
* Created by The eXo Platform SARL Author : Tuan Nguyen
@@ -61,10 +61,12 @@
private DataStorage dataStorage_;
- private volatile List<?> configs;
+ private volatile List<NewPortalConfig> configs;
- private PageTemplateConfig pageTemplateConfig_;
+ private List<SiteConfigTemplates> templateConfigs;
+ private String pageTemplatesLocation_;
+
private String defaultPortal;
private boolean isUseTryCatch;
@@ -77,18 +79,20 @@
cmanager_ = cmanager;
dataStorage_ = dataStorage;
- ObjectParameter objectParam = params.getObjectParam("page.templates");
- if (objectParam != null)
- pageTemplateConfig_ = (PageTemplateConfig)objectParam.getObject();
+ ValueParam valueParam = params.getValueParam("page.templates.location");
+ if (valueParam != null)
+ pageTemplatesLocation_ = valueParam.getValue();
defaultPortal = "classic";
- ValueParam valueParam = params.getValueParam("default.portal");
+ valueParam = params.getValueParam("default.portal");
if (valueParam != null)
defaultPortal = valueParam.getValue();
if (defaultPortal == null || defaultPortal.trim().length() == 0)
defaultPortal = "classic";
configs = params.getObjectParamValues(NewPortalConfig.class);
+ templateConfigs = params.getObjectParamValues(SiteConfigTemplates.class);
+
// get parameter
valueParam = params.getValueParam("initializing.failure.ignore");
// determine in the run function, is use try catch or not
@@ -105,66 +109,61 @@
public void run() throws Exception
{
- if (isInitedDB(defaultPortal))
+ if (dataStorage_.getPortalConfig(defaultPortal) != null)
return;
if (isUseTryCatch)
{
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortletPreferencesDB(portalConfig);
+ initPortletPreferencesDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortalConfigDB(portalConfig);
+ initPortalConfigDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageDB(portalConfig);
+ initPageDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageNavigationDB(portalConfig);
+ initPageNavigationDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- portalConfig.getPredefinedOwner().clear();
+ ele.getPredefinedOwner().clear();
}
catch (Exception e)
{
@@ -175,30 +174,25 @@
}
else
{
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortletPreferencesDB(portalConfig);
+ initPortletPreferencesDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortalConfigDB(portalConfig);
+ initPortalConfigDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageDB(portalConfig);
+ initPageDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageNavigationDB(portalConfig);
+ initPageNavigationDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- portalConfig.getPredefinedOwner().clear();
+ ele.getPredefinedOwner().clear();
}
}
}
@@ -213,13 +207,13 @@
* a copy of the original object.
*
* @param ownerType the owner type
+ * @param template
* @return the specified new portal config
*/
- NewPortalConfig getPortalConfig(String ownerType)
+ NewPortalConfig getPortalConfig(String ownerType, String template)
{
- for (Object object : configs)
+ for (NewPortalConfig portalConfig : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)object;
if (portalConfig.getOwnerType().equals(ownerType))
{
// We are defensive, we make a deep copy
@@ -229,25 +223,35 @@
return null;
}
- @SuppressWarnings("unchecked")
- synchronized void addPortalConfigs(NewPortalConfigListener listener)
+ /**
+ * This is used to merge an other NewPortalConfigListener to this one
+ *
+ * @param other
+ */
+ public void mergePlugin(NewPortalConfigListener other)
{
+ this.defaultPortal = other.defaultPortal;
if (configs == null)
{
- this.configs = listener.configs;
+ this.configs = other.configs;
}
- else if (listener.configs != null && !listener.configs.isEmpty())
+ else if (other.configs != null && !other.configs.isEmpty())
{
- List result = new ArrayList(configs);
- result.addAll(listener.configs);
+ List<NewPortalConfig> result = new
ArrayList<NewPortalConfig>(configs);
+ result.addAll(other.configs);
this.configs = Collections.unmodifiableList(result);
}
- }
- private boolean isInitedDB(String portalName) throws Exception
- {
- PortalConfig pconfig = dataStorage_.getPortalConfig(portalName);
- return pconfig != null;
+ if (templateConfigs == null)
+ {
+ this.templateConfigs = other.templateConfigs;
+ }
+ else if (other.templateConfigs != null &&
!other.templateConfigs.isEmpty())
+ {
+ List<SiteConfigTemplates> result = new
ArrayList<SiteConfigTemplates>(templateConfigs);
+ result.addAll(other.templateConfigs);
+ this.templateConfigs = Collections.unmodifiableList(result);
+ }
}
public void initPortalConfigDB(NewPortalConfig config) throws Exception
@@ -285,19 +289,16 @@
}
}
- private void createPortalConfig(NewPortalConfig config, String owner) throws
Exception
+ public void createPortalConfig(NewPortalConfig config, String owner) throws Exception
{
String type = config.getOwnerType();
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null ||
config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, type, notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null &&
config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, type, isTemplate);
- // get xml content and parse xml content
try
{
- String xml = getDefaultConfigIfExists(config.getTemplateLocation(), path);
+ String xml = getDefaultConfig(config.getTemplateLocation(), path);
if (xml == null)
{
@@ -314,7 +315,7 @@
}
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -346,15 +347,12 @@
}
}
- private void createPage(NewPortalConfig config, String owner) throws Exception
+ public void createPage(NewPortalConfig config, String owner) throws Exception
{
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null ||
config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, "pages", notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null &&
config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, "pages", isTemplate);
- // get xml content and parse xml content
try
{
String xml = getDefaultConfig(config.getTemplateLocation(), path);
@@ -363,7 +361,7 @@
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -382,14 +380,11 @@
}
}
- private void createPageNavigation(NewPortalConfig config, String owner) throws
Exception
+ public void createPageNavigation(NewPortalConfig config, String owner) throws
Exception
{
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null ||
config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, "navigation", notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null &&
config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, "navigation", isTemplate);
- // get xml content and parse xml content
try
{
String xml = getDefaultConfig(config.getTemplateLocation(), path);
@@ -398,7 +393,7 @@
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -421,14 +416,11 @@
}
}
- private void createPortletPreferences(NewPortalConfig config, String owner) throws
Exception
+ public void createPortletPreferences(NewPortalConfig config, String owner) throws
Exception
{
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null ||
config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, "portlet-preferences",
notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null &&
config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, "portlet-preferences",
isTemplate);
- // get xml content and parse xml content
try
{
String xml = getDefaultConfig(config.getTemplateLocation(), path);
@@ -437,7 +429,7 @@
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -456,18 +448,12 @@
}
}
- private String getDefaultConfigIfExists(String location, String path) throws
Exception
- {
- URL url = cmanager_.getURL(location + path);
- return url == null ? null : IOUtil.getStreamContentAsString(url.openStream());
- }
-
private String getDefaultConfig(String location, String path) throws Exception
{
String s = location + path;
try
{
- return IOUtil.getStreamContentAsString(cmanager_.getInputStream(s));
+ return IOUtil.getStreamContentAsString(cmanager_.getInputStream(location +
path));
}
catch (Exception ignore)
{
@@ -476,32 +462,39 @@
}
}
- private String getPathConfig(NewPortalConfig portalConfig, String owner, String
dataType, boolean notTemplate)
+ private String getPathConfig(NewPortalConfig portalConfig, String owner, String
fileName, boolean isTemplate)
{
String path = "";
- if (!notTemplate)
+ if (isTemplate)
{
String ownerType = portalConfig.getOwnerType();
- path = "/" + ownerType + "/template/" +
portalConfig.getTemplateOwner() + "/" + dataType + ".xml";
+ path = "/" + ownerType + "/template/" +
portalConfig.getTemplateName() + "/" + fileName + ".xml";
}
else
{
String ownerType = portalConfig.getOwnerType();
- path = "/" + ownerType + "/" + owner + "/" +
dataType + ".xml";
+ path = "/" + ownerType + "/" + owner + "/" +
fileName + ".xml";
}
return path;
}
public Page createPageFromTemplate(String ownerType, String owner, String temp) throws
Exception
{
- return fromXML(ownerType, owner, getTemplateConfig(temp, "page"),
Page.class);
+ String path = pageTemplatesLocation_ + "/" + temp +
"/page.xml";
+ InputStream is = cmanager_.getInputStream(path);
+ String xml = IOUtil.getStreamContentAsString(is);
+ return fromXML(ownerType, owner, xml, Page.class);
}
- private String getTemplateConfig(String name, String dataType) throws Exception
+ public String getTemplateConfig(String type, String name)
{
- String path = pageTemplateConfig_.getLocation() + "/" + name +
"/" + dataType + ".xml";
- InputStream is = cmanager_.getInputStream(path);
- return IOUtil.getStreamContentAsString(is);
+ for (SiteConfigTemplates tempConfig : templateConfigs)
+ {
+ Set<String> templates = tempConfig.getTemplates(type);
+ if (templates != null && templates.contains(name))
+ return tempConfig.getLocation();
+ }
+ return null;
}
// Deserializing code
Deleted:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java 2010-02-10
10:55:19 UTC (rev 1615)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java 2010-02-10
12:54:25 UTC (rev 1616)
@@ -1,69 +0,0 @@
-/**
- * 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.
- */
-
-package org.exoplatform.portal.config;
-
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * Author : Pham Thanh Tung
- * thanhtungty(a)gmail.com
- * Mar 3, 2008
- */
-public class PageTemplateConfig
-{
-
- String location;
-
- List<String> templates;
-
- /**
- * @return the location
- */
- public String getLocation()
- {
- return location;
- }
-
- /**
- * @param location the location to set
- */
- public void setLocation(String location)
- {
- this.location = location;
- }
-
- /**
- * @return the templates
- */
- public List<String> getTemplates()
- {
- return templates;
- }
-
- /**
- * @param templates the templates to set
- */
- public void setTemplates(List<String> templates)
- {
- this.templates = templates;
- }
-
-}
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java 2010-02-10
12:54:25 UTC (rev 1616)
@@ -0,0 +1,74 @@
+/**
+ * Copyright (C) 2010 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.
+ */
+package org.exoplatform.portal.config;
+
+import org.exoplatform.portal.config.model.PortalConfig;
+
+import java.util.Set;
+
+/**
+ * @author <a href="trong.tran(a)exoplatform.com">Trong Tran</a>
+ * @version $Revision$
+ */
+
+public class SiteConfigTemplates
+{
+ private String location;
+
+ private Set<String> portalTemplates;
+
+ private Set<String> groupTemplates;
+
+ private Set<String> userTemplates;
+
+ /**
+ * @return the location
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * @param location the locationPath to set
+ */
+ public void setLocation(String locationPath)
+ {
+ this.location = locationPath;
+ }
+
+ /**
+ * @return the type
+ */
+ public Set<String> getTemplates(String type)
+ {
+ if (type.equals(PortalConfig.PORTAL_TYPE))
+ {
+ return portalTemplates;
+ }
+ else if (type.equals(PortalConfig.GROUP_TYPE))
+ {
+ return groupTemplates;
+ }
+ else
+ {
+ return userTemplates;
+ }
+ }
+}
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 2010-02-10
10:55:19 UTC (rev 1615)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-02-10
12:54:25 UTC (rev 1616)
@@ -59,7 +59,7 @@
private OrganizationService orgService_;
private NewPortalConfigListener newPortalConfigListener_;
-
+
private Log log = ExoLogger.getLogger("Portal:UserPortalConfigService");
public UserPortalConfigService(
@@ -201,24 +201,25 @@
/**
* This method should create a the portal config, pages and navigation according to
the template name.
*
- * @param portalName the portal name
+ * @param siteName the Site name
* @param template the template to use
* @throws Exception any exception
*/
- public void createUserPortalConfig(String ownerType, String portalName, String
template) throws Exception
+ public void createUserPortalConfig(String ownerType, String siteName, String template)
throws Exception
{
- NewPortalConfig portalConfig =
newPortalConfigListener_.getPortalConfig(ownerType);
+ String templatePath = newPortalConfigListener_.getTemplateConfig(ownerType,
template);
- //
- portalConfig.setTemplateOwner(template);
- portalConfig.getPredefinedOwner().clear();
- portalConfig.getPredefinedOwner().add(portalName);
+ NewPortalConfig portalConfig = new NewPortalConfig(templatePath);
+ portalConfig.setTemplateName(template);
+ portalConfig.setOwnerType(ownerType);
- //
- newPortalConfigListener_.initPortletPreferencesDB(portalConfig);
- newPortalConfigListener_.initPortalConfigDB(portalConfig);
- newPortalConfigListener_.initPageDB(portalConfig);
- newPortalConfigListener_.initPageNavigationDB(portalConfig);
+ if (!portalConfig.getOwnerType().equals(PortalConfig.USER_TYPE))
+ {
+ newPortalConfigListener_.createPortletPreferences(portalConfig, siteName);
+ }
+ newPortalConfigListener_.createPortalConfig(portalConfig, siteName);
+ newPortalConfigListener_.createPage(portalConfig, siteName);
+ newPortalConfigListener_.createPageNavigation(portalConfig, siteName);
}
/**
@@ -229,7 +230,7 @@
*/
public void removeUserPortalConfig(String portalName) throws Exception
{
- removeUserPortalConfig("portal", portalName);
+ removeUserPortalConfig(PortalConfig.PORTAL_TYPE, portalName);
}
/**
@@ -497,7 +498,7 @@
public List<String> getAllPortalNames() throws Exception
{
List<String> list = new ArrayList<String>();
- Query<PortalConfig> query = new Query<PortalConfig>("portal",
null, null, null, PortalConfig.class);
+ Query<PortalConfig> query = new
Query<PortalConfig>(PortalConfig.PORTAL_TYPE, null, null, null,
PortalConfig.class);
PageList<PortalConfig> pageList = storage_.find(query);
List<PortalConfig> configs = pageList.getAll();
for (PortalConfig ele : configs)
@@ -558,7 +559,7 @@
}
else
{
-
newPortalConfigListener_.addPortalConfigs((NewPortalConfigListener)listener);
+ newPortalConfigListener_.mergePlugin((NewPortalConfigListener)listener);
}
}
}
@@ -576,7 +577,6 @@
//
RequestLifeCycle.begin(PortalContainer.getInstance());
- //
newPortalConfigListener_.run();
}
catch (Exception e)
Modified:
portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml
===================================================================
---
portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml 2010-02-10
10:55:19 UTC (rev 1615)
+++
portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml 2010-02-10
12:54:25 UTC (rev 1616)
@@ -42,6 +42,44 @@
<description>In the run method, use try catch or not (value is
true/false)</description>
<value>true</value>
</value-param>
+ <value-param>
+ <name>page.templates.location</name>
+ <description>the path to the location that contains Page
templates</description>
+ <value>classpath:/portal/template/pages</value>
+ </value-param>
+ <object-param>
+ <name>site.templates.location</name>
+ <description>description</description>
+ <object
type="org.exoplatform.portal.config.SiteConfigTemplates">
+ <field name="location">
+ <string>classpath:/portal</string>
+ </field>
+ <field name="portalTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>classic</string>
+ </value>
+ <value>
+ <string>test</string>
+ </value>
+ </collection>
+ </field>
+ <field name="groupTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>group</string>
+ </value>
+ </collection>
+ </field>
+ <field name="userTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>user</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
<object-param>
<name>portal.configuration</name>
<description>description</description>
@@ -129,18 +167,6 @@
</field>
</object>
</object-param>
- <object-param>
- <name>page.templates</name>
- <description>List of page templates</description>
- <object
type="org.exoplatform.portal.config.PageTemplateConfig">
- <field name="templates">
- <collection type="java.util.ArrayList"></collection>
- </field>
- <field name="location">
- <string>classpath:/portal/template/pages</string>
- </field>
- </object>
- </object-param>
</init-params>
</component-plugin>
</external-component-plugins>
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-02-10
10:55:19 UTC (rev 1615)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-02-10
12:54:25 UTC (rev 1616)
@@ -40,6 +40,8 @@
import org.exoplatform.services.listener.Event;
import org.exoplatform.services.listener.Listener;
import org.exoplatform.services.listener.ListenerService;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupHandler;
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserHandler;
@@ -816,6 +818,36 @@
}.execute(null);
}
+ public void testGroupTemplate()
+ {
+ new UnitTest()
+ {
+ public void execute() throws Exception
+ {
+ String groupName = "groupTest";
+ assertNull(storage_.getPortalConfig(PortalConfig.GROUP_TYPE, groupName));
+
+ //
+ GroupHandler groupHandler = orgService_.getGroupHandler();
+ Group group = groupHandler.createGroupInstance();
+ group.setGroupName(groupName);
+ group.setDescription("this is a group for test");
+ groupHandler.addChild(null, group, true);
+
+ //
+ PortalConfig cfg = storage_.getPortalConfig(PortalConfig.GROUP_TYPE,
"/" + groupName);
+ assertNotNull(cfg);
+ Container container = cfg.getPortalLayout();
+ assertNotNull(container);
+ assertEquals(4, container.getChildren().size());
+ assertTrue(container.getChildren().get(2) instanceof PageBody);
+ assertTrue(((Application)container.getChildren().get(1)).getType() ==
ApplicationType.PORTLET);
+
+ groupHandler.removeGroup(group, true);
+ }
+ }.execute(null);
+ }
+
public void testCacheUserPortalConfig()
{
new UnitTest()