Author: hoang_to
Date: 2011-03-01 04:51:53 -0500 (Tue, 01 Mar 2011)
New Revision: 5952
Modified:
portal/branches/branch-GTNPORTAL-1822/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
portal/branches/branch-GTNPORTAL-1822/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
Log:
GTNPORTAL-1821: Option to override portal metadata at startup
Modified:
portal/branches/branch-GTNPORTAL-1822/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
---
portal/branches/branch-GTNPORTAL-1822/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-03-01
09:48:47 UTC (rev 5951)
+++
portal/branches/branch-GTNPORTAL-1822/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-03-01
09:51:53 UTC (rev 5952)
@@ -81,6 +81,12 @@
/** . */
private boolean isUseTryCatch;
+ /**
+ * If true the portal clear portal metadata from data storage and replace
+ * it with new data created from .xml files
+ */
+ private boolean overrideExistingData;
+
/** . */
private Logger log = LoggerFactory.getLogger(getClass());
@@ -125,11 +131,23 @@
isUseTryCatch = true;
}
+ valueParam = params.getValueParam("override");
+ if(valueParam != null)
+ {
+ overrideExistingData = "true".equals(valueParam.getValue());
+ }
+ else
+ {
+ overrideExistingData = false;
+ }
+
}
public void run() throws Exception
{
- if (dataStorage_.getPortalConfig(defaultPortal) != null)
+ //DANGEROUS! If the user delete the defaultPortal (ie: classic), the next time he
restarts
+ //the server. Data of predefined owners would be overriden
+ if (dataStorage_.getPortalConfig(defaultPortal) != null &&
!overrideExistingData)
return;
if (isUseTryCatch)
@@ -279,6 +297,10 @@
result.addAll(other.templateConfigs);
this.templateConfigs = Collections.unmodifiableList(result);
}
+
+ //The override is true if and only if one of the plugin NewPortalConfigListener
configures its
+ //override param as true
+ overrideExistingData = overrideExistingData || other.overrideExistingData;
}
public void initPortalConfigDB(NewPortalConfig config) throws Exception
@@ -387,8 +409,16 @@
}
else
{
- navigation.merge(currentNavigation);
- dataStorage_.save(navigation);
+ if(overrideExistingData)
+ {
+ dataStorage_.remove(currentNavigation);
+ dataStorage_.create(navigation);
+ }
+ else
+ {
+ navigation.merge(currentNavigation);
+ dataStorage_.save(navigation);
+ }
}
}
Modified:
portal/branches/branch-GTNPORTAL-1822/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
---
portal/branches/branch-GTNPORTAL-1822/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-03-01
09:48:47 UTC (rev 5951)
+++
portal/branches/branch-GTNPORTAL-1822/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-03-01
09:51:53 UTC (rev 5952)
@@ -113,6 +113,11 @@
<description>the path to the location that contains Page
templates</description>
<value>war:/conf/portal/template/pages</value>
</value-param>
+ <value-param>
+ <name>override</name>
+ <description>The flag parameter to decide if portal metadata is
overriden on restarting server</description>
+ <value>false</value>
+ </value-param>
<object-param>
<name>site.templates.location</name>
<description>description</description>
Show replies by date