Author: nscavell
Date: 2011-10-13 15:39:42 -0400 (Thu, 13 Oct 2011)
New Revision: 7741
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
Log:
GTNPORTAL-2152: Fix site layout file name for MOP export and import.
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-10-13
16:30:15 UTC (rev 7740)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-10-13
19:39:42 UTC (rev 7741)
@@ -79,7 +79,7 @@
private void siteLayoutManagementRegistration(ManagedResource.Registration sites)
{
// This allows us to filter based on path template site-layout.
- ManagedResource.Registration siteLayout =
sites.registerSubResource("{site-layout: portal}", description("Management
resource responsible for handling management operations for a site's layout."));
+ ManagedResource.Registration siteLayout =
sites.registerSubResource("{site-layout: portal|group|user}",
description("Management resource responsible for handling management operations for a
site's layout."));
siteLayout.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteLayoutReadResource(), description("The site layout resource."));
siteLayout.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
SiteLayoutReadConfigAsXml(), description("Reads site layout data for a specific site
as configuration xml."));
siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
SiteLayoutExportResource(), description("Exports site layout configuration xml as a
zip file."));
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java 2011-10-13
16:30:15 UTC (rev 7740)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/SiteLayoutExportTask.java 2011-10-13
19:39:42 UTC (rev 7741)
@@ -25,15 +25,14 @@
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
+import org.exoplatform.portal.mop.SiteType;
import org.gatein.management.api.binding.Marshaller;
import org.gatein.management.api.operation.model.ExportTask;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
@@ -41,7 +40,15 @@
*/
public class SiteLayoutExportTask extends AbstractExportTask implements ExportTask
{
- public static final String FILE = "portal.xml";
+ public static final Set<String> FILES;
+ static
+ {
+ HashSet<String> tmp = new HashSet<String>(3);
+ tmp.add("portal.xml");
+ tmp.add("group.xml");
+ tmp.add("user.xml");
+ FILES = tmp;
+ }
private final DataStorage dataStorage;
private final Marshaller<PortalConfig> marshaller;
@@ -56,7 +63,22 @@
@Override
protected String getXmlFileName()
{
- return FILE;
+ if (siteKey.getType() == SiteType.PORTAL)
+ {
+ return "portal.xml";
+ }
+ else if (siteKey.getType() == SiteType.GROUP)
+ {
+ return "group.xml";
+ }
+ else if (siteKey.getType() == SiteType.USER)
+ {
+ return "user.xml";
+ }
+ else
+ {
+ throw new RuntimeException("Unknown site type " + siteKey.getType());
+ }
}
@Override
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java 2011-10-13
16:30:15 UTC (rev 7740)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/MopImportResource.java 2011-10-13
19:39:42 UTC (rev 7741)
@@ -136,7 +136,7 @@
importMap.put(siteKey, mopImport);
}
- if (file.equals(SiteLayoutExportTask.FILE))
+ if (SiteLayoutExportTask.FILES.contains(file))
{
// Unmarshal site layout data
Marshaller<PortalConfig> marshaller =
operationContext.getBindingProvider().getMarshaller(PortalConfig.class, ContentType.XML);
@@ -314,7 +314,7 @@
private static String[] parseEntry(ZipEntry entry) throws IOException
{
String name = entry.getName();
- if (name.endsWith(SiteLayoutExportTask.FILE) || name.endsWith(PageExportTask.FILE)
|| name.endsWith(NavigationExportTask.FILE))
+ if (isSiteLayoutEntry(name) || name.endsWith(PageExportTask.FILE) ||
name.endsWith(NavigationExportTask.FILE))
{
String[] parts = new String[3];
parts[0] = name.substring(0, name.indexOf("/"));
@@ -328,6 +328,16 @@
}
}
+ private static boolean isSiteLayoutEntry(String zipEntryName)
+ {
+ for (String file : SiteLayoutExportTask.FILES)
+ {
+ if (zipEntryName.endsWith(file)) return true;
+ }
+
+ return false;
+ }
+
// Bug in SUN's JDK XMLStreamReader implementation closes the underlying stream
when
// it finishes reading an XML document. This is no good when we are using a
ZipInputStream.
// See
http://bugs.sun.com/view_bug.do?bug_id=6539065 for more information.
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-10-13
16:30:15 UTC (rev 7740)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-10-13
19:39:42 UTC (rev 7741)
@@ -64,7 +64,22 @@
if (pageOrNav)
{
- children.add("portal");
+ if (site.getObjectType() == ObjectType.PORTAL_SITE)
+ {
+ children.add("portal");
+ }
+ else if (site.getObjectType() == ObjectType.GROUP_SITE)
+ {
+ children.add("group");
+ }
+ else if (site.getObjectType() == ObjectType.USER_SITE)
+ {
+ children.add("user");
+ }
+ else
+ {
+ throw new OperationException(operationContext.getOperationName(),
"Unknown site type " + site.getObjectType());
+ }
}
else
{