Author: nscavell
Date: 2011-09-12 16:48:35 -0400 (Mon, 12 Sep 2011)
New Revision: 7359
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
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/binding/xml/NavigationMarshaller.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
portal/trunk/pom.xml
Log:
GTNPORTAL-2081: Allow filtering during mop export.
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-09-12
14:44:00 UTC (rev 7358)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -33,6 +33,7 @@
import org.exoplatform.portal.mop.management.operations.page.PageReadResource;
import org.exoplatform.portal.mop.management.operations.site.SiteLayoutExportResource;
import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadConfigAsXml;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadResource;
import org.exoplatform.portal.mop.management.operations.site.SiteReadResource;
import org.exoplatform.portal.mop.management.operations.site.SiteTypeReadResource;
import org.gatein.management.api.ComponentRegistration;
@@ -54,16 +55,16 @@
ComponentRegistration registration =
context.registerManagedComponent("mop");
registration.registerBindingProvider(MopBindingProvider.INSTANCE);
- ManagedResource.Registration mop =
registration.registerManagedResource(description("MOP (Model Object for Portal)
Managed Resource"));
+ ManagedResource.Registration mop =
registration.registerManagedResource(description("MOP (Model Object for Portal)
Managed Resource, responsible for handling management operations on navigation, pages, and
sites."));
mop.registerOperationHandler(OperationNames.IMPORT_RESOURCE, new
MopImportResource(), description("Imports mop data from an exported zip
file."));
- mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(),
description("Available site types for a portal"));
+ mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(),
description("Lists available site types for a portal"));
ManagedResource.Registration sitetypes =
mop.registerSubResource("{site-type}sites", description("Management
resource responsible for handling management operations on a specific site type for a
portal."));
- sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteTypeReadResource(), description("Available sites for a given site type."));
+ sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteTypeReadResource(), description("Lists available sites for a given site
type."));
ManagedResource.Registration sites =
sitetypes.registerSubResource("{site-name: .*}", description("Management
resource responsible for handling management operations on a specific site."));
- sites.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteReadResource(), description("Available artifacts for a given site (ie pages,
navigation, site layout)"));
+ sites.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteReadResource(), description("Lists available resources for a given site (ie
pages, navigation, site layout)"));
// Site Layout management
siteLayoutManagementRegistration(sites);
@@ -77,7 +78,9 @@
private void siteLayoutManagementRegistration(ManagedResource.Registration sites)
{
- ManagedResource.Registration siteLayout =
sites.registerSubResource("portal", description("Management resource
responsible for handling management operations for a site layout."));
+ // 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."));
+ 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."));
}
@@ -85,15 +88,15 @@
private void pageManagementRegistration(ManagedResource.Registration sites)
{
// Pages management resource registration
- ManagedResource.Registration pages = sites.registerSubResource("pages",
description("Management resource responsible for handling management operations on
all pages of a site."));
+ ManagedResource.Registration pages = sites.registerSubResource("pages",
description("Management resource responsible for handling management operations for
pages of a site."));
// Pages management operations
- pages.registerOperationHandler(OperationNames.READ_RESOURCE, new
PageReadResource(), description("Available pages at the specified address."),
true);
- pages.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
PageReadConfigAsXml(), description("Reads pages as configuration xml at the specified
address."), true);
+ pages.registerOperationHandler(OperationNames.READ_RESOURCE, new
PageReadResource(), description("Lists available pages at a specified
address."), true);
+ pages.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
PageReadConfigAsXml(), description("Reads pages as configuration xml at a specified
address."), true);
pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
PageExportResource(), description("Exports pages configuration xml as a zip
file."), true);
// Page name management resource registration
- pages.registerSubResource("{page-name}", description("Page
management resource representing an individual page."));
+ pages.registerSubResource("{page-name}", description("Page resource
representing an individual page of a site."));
}
private void navigationManagementRegistration(ManagedResource.Registration sites)
@@ -103,7 +106,7 @@
// Navigation management operations
navigation.registerOperationHandler(OperationNames.READ_RESOURCE, new
NavigationReadResource(), description("Available navigation nodes at the specified
address."), true);
- navigation.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
NavigationReadConfigAsXml(), description("Reads navigation as configuration xml at
the specified address."), true);
+ navigation.registerOperationHandler(OperationNames.READ_CONFIG_AS_XML, new
NavigationReadConfigAsXml(), description("Reads navigation as configuration xml at a
specified address."), true);
navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
NavigationExportResource(), description("Exports navigation configuration xml as a
zip file."), true);
// Navigation node management resource registration
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java 2011-09-12
14:44:00 UTC (rev 7358)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/binding/xml/NavigationMarshaller.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -99,10 +99,10 @@
writer.writeElement(Element.PRIORITY, WritableValueTypes.INTEGER,
navigation.getPriority());
// Page nodes
- writer.writeStartElement(Element.PAGE_NODES);
ArrayList<NavigationFragment> fragments = navigation.getFragments();
for (NavigationFragment fragment : fragments)
{
+ writer.writeStartElement(Element.PAGE_NODES);
if (fragment.getParentURI() != null)
{
String parentUri = fragment.getParentURI();
@@ -117,9 +117,10 @@
marshallNode(writer, node);
}
}
+ writer.writeEndElement(); // End page-nodes
}
- writer.writeEndElement().writeEndElement(); // End page-nodes and node-navigation
+ writer.writeEndElement(); // End node-navigation
}
public void marshallNode(StaxWriter<Element> writer, PageNode node) throws
XMLStreamException
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-09-12
14:44:00 UTC (rev 7358)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -23,6 +23,7 @@
package org.exoplatform.portal.mop.management.exportimport;
import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.management.operations.navigation.NavigationKey;
import org.exoplatform.portal.mop.management.operations.navigation.NavigationUtils;
@@ -55,6 +56,15 @@
this.marshaller = marshaller;
}
+ // TODO: This is a little sloppy to support filtering, fix if we have time.
+ private PageNavigation navigation;
+ public NavigationExportTask(PageNavigation navigation,
Marshaller<PageNavigation> marshaller)
+ {
+ super(new SiteKey(navigation.getOwnerType(), navigation.getOwnerId()));
+ this.navigation = navigation;
+ this.marshaller = marshaller;
+ }
+
@Override
protected String getXmlFileName()
{
@@ -64,7 +74,11 @@
@Override
public void export(OutputStream outputStream) throws IOException
{
- PageNavigation navigation = NavigationUtils.loadPageNavigation(navigationKey,
navigationService, descriptionService);
+ if (navigation == null)
+ {
+ navigation = NavigationUtils.loadPageNavigation(navigationKey,
navigationService, descriptionService);
+ }
+
marshaller.marshal(navigation, outputStream);
}
}
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -0,0 +1,238 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.mop.management.operations.navigation;
+
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
+import org.gatein.management.api.ContentType;
+import org.gatein.management.api.ManagedResource;
+import org.gatein.management.api.PathAddress;
+import org.gatein.management.api.PathTemplateFilter;
+import org.gatein.management.api.binding.BindingProvider;
+import org.gatein.management.api.binding.Marshaller;
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.OperationContextDelegate;
+import org.gatein.management.api.operation.OperationHandler;
+import org.gatein.management.api.operation.OperationNames;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.StepResultHandler;
+import org.gatein.management.api.operation.model.ExportResourceModel;
+import org.gatein.management.api.operation.model.ExportTask;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class FilteredNavigationExportResource
+{
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
PathTemplateFilter filter)
+ {
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+ Marshaller<PageNavigation> marshaller =
bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
+
+ final ManagedResource resource = operationContext.getManagedResource();
+ final PathAddress address = operationContext.getAddress();
+ final String operationName = operationContext.getOperationName();
+
+ StepResultHandler<PageNavigation> stepResultHandler = new
StepResultHandler<PageNavigation>(address)
+ {
+ @Override
+ public void failed(String failureDescription)
+ {
+ if (address.equals(getCurrentAddress()))
+ {
+ throw new OperationException(operationName, "Navigation export
failed. Reason: " + failureDescription);
+ }
+ else
+ {
+ throw new OperationException(operationName, "Navigation export
failed. Reason: " + failureDescription + " [Step Address: " +
getCurrentAddress() + "]");
+ }
+ }
+
+ @Override
+ protected void doCompleted(PageNavigation result)
+ {
+ if (getResults().isEmpty())
+ {
+ super.doCompleted(result);
+ }
+ else
+ {
+ PageNavigation navigation = getResults().get(0);
+ merge(navigation, result);
+ }
+ }
+ };
+
+ try
+ {
+ executeHandlers(resource, operationContext, address,
OperationNames.READ_CONFIG_AS_XML, stepResultHandler, filter, true);
+ List<PageNavigation> results = stepResultHandler.getResults();
+ if (results.isEmpty())
+ {
+ resultHandler.completed(new
ExportResourceModel(Collections.<ExportTask>emptyList()));
+ }
+ else
+ {
+ NavigationExportTask task = new
NavigationExportTask(stepResultHandler.getResults().get(0), marshaller);
+ resultHandler.completed(new ExportResourceModel(task));
+ }
+ }
+ catch (OperationException e)
+ {
+ throw new OperationException(e.getOperationName(), getStepMessage(e, address,
stepResultHandler), e);
+ }
+ catch (Throwable t)
+ {
+ throw new OperationException(operationName, getStepMessage(t, address,
stepResultHandler), t);
+ }
+ }
+
+ private void executeHandlers(ManagedResource resource, final OperationContext
operationContext, PathAddress address, String operationName,
StepResultHandler<PageNavigation> stepResultHandler, PathTemplateFilter filter,
boolean root)
+ {
+ //resource.getSubResource(address);
+ OperationHandler handler = resource.getOperationHandler(address, operationName);
+ System.out.println("Filter: " + filter + " accepted ? " +
address.accepts(filter) + " for address " + address + " and nav-uri
template " + address.resolvePathTemplate("nav-uri"));
+ if (handler != null && !root && address.accepts(filter))
+ {
+ handler.execute(operationContext, stepResultHandler);
+ }
+ else
+ {
+ OperationHandler readResource = resource.getOperationHandler(address,
OperationNames.READ_RESOURCE);
+ BasicResultHandler readResourceResult = new BasicResultHandler();
+ readResource.execute(new OperationContextDelegate(operationContext)
+ {
+ @Override
+ public String getOperationName()
+ {
+ return OperationNames.READ_RESOURCE;
+ }
+ }, readResourceResult);
+ if (readResourceResult.getFailureDescription() != null)
+ {
+ throw new OperationException(operationName, "Failure '" +
readResourceResult.getFailureDescription() + "' encountered executing " +
OperationNames.READ_RESOURCE);
+ }
+
+ Object model = readResourceResult.getResult();
+ if (! (model instanceof ReadResourceModel) )
+ {
+ throw new RuntimeException("Was expecting " +
ReadResourceModel.class + " to be returned for operation " +
OperationNames.READ_RESOURCE + " at address " + address);
+ }
+
+ for (String child : ((ReadResourceModel) model).getChildren())
+ {
+ final PathAddress childAddress = address.append(child);
+ OperationContext childContext = new
OperationContextDelegate(operationContext)
+ {
+ @Override
+ public PathAddress getAddress()
+ {
+ return childAddress;
+ }
+ };
+ executeHandlers(resource, childContext, childAddress, operationName,
stepResultHandler.next(childAddress), filter, false);
+ }
+ }
+ }
+
+ private String getStepMessage(Throwable t, PathAddress originalAddress,
StepResultHandler<PageNavigation> stepResultHandler)
+ {
+ String message = (t.getMessage() == null) ? "Step operation failure" :
t.getMessage();
+ if (originalAddress.equals(stepResultHandler.getCurrentAddress()))
+ {
+ return message;
+ }
+ else
+ {
+ return message + " [Step Address: " +
stepResultHandler.getCurrentAddress() + "]";
+ }
+ }
+
+ private void merge(PageNavigation navigation, PageNavigation result)
+ {
+ for (NavigationFragment fragment : result.getFragments())
+ {
+ if (fragment.getParentURI() != null)
+ {
+ NavigationFragment found = findFragment(navigation,
fragment.getParentURI());
+ if (found == null)
+ {
+ navigation.addFragment(fragment);
+ }
+ else
+ {
+ found.getNodes().addAll(fragment.getNodes());
+ }
+ }
+ else
+ {
+ navigation.addFragment(fragment);
+ }
+ }
+ }
+
+ private NavigationFragment findFragment(PageNavigation navigation, String parentUri)
+ {
+ for (NavigationFragment fragment : navigation.getFragments())
+ {
+ if (fragment.getParentURI().equals(parentUri)) return fragment;
+ }
+
+ return null;
+ }
+
+ private static class BasicResultHandler implements ResultHandler
+ {
+ private Object result;
+ private String failureDescription;
+
+ @Override
+ public void completed(Object result)
+ {
+ this.result = result;
+ }
+
+ @Override
+ public void failed(String failureDescription)
+ {
+ this.failureDescription = failureDescription;
+ }
+
+ public Object getResult()
+ {
+ return result;
+ }
+
+ public String getFailureDescription()
+ {
+ return failureDescription;
+ }
+ }
+}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2011-09-12
14:44:00 UTC (rev 7358)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -28,6 +28,7 @@
import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.gatein.management.api.ContentType;
+import org.gatein.management.api.PathTemplateFilter;
import org.gatein.management.api.binding.BindingProvider;
import org.gatein.management.api.binding.Marshaller;
import org.gatein.management.api.exceptions.OperationException;
@@ -38,26 +39,49 @@
import org.gatein.mop.api.workspace.Navigation;
import org.gatein.mop.api.workspace.Site;
+import java.text.ParseException;
+import java.util.List;
+
/**
* @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
* @version $Revision$
*/
public class NavigationExportResource extends AbstractNavigationOperationHandler
{
+ private static final FilteredNavigationExportResource filtered = new
FilteredNavigationExportResource();
+
@Override
protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation navigation) throws ResourceNotFoundException, OperationException
{
- Site site = navigation.getSite();
- String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
- SiteKey siteKey = getSiteKey(site);
+ List<String> filterAttributes =
operationContext.getAttributes().getValues("filter");
+ PathTemplateFilter filter;
+ try
+ {
+ filter = PathTemplateFilter.parse(filterAttributes);
+ }
+ catch (ParseException e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Could
not parse filter attributes.", e);
+ }
- DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
- NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
- BindingProvider bindingProvider = operationContext.getBindingProvider();
- Marshaller<PageNavigation> marshaller =
bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
+ if (filter.hasPathTemplate("nav-uri"))
+ {
+ filtered.execute(operationContext, resultHandler, filter);
+ }
+ else
+ {
+ Site site = navigation.getSite();
+ String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
+ SiteKey siteKey = getSiteKey(site);
- NavigationExportTask exportTask = new NavigationExportTask(new
NavigationKey(siteKey, navUri), navigationService, descriptionService, marshaller);
+ DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ BindingProvider bindingProvider = operationContext.getBindingProvider();
+ Marshaller<PageNavigation> marshaller =
bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
- resultHandler.completed(new ExportResourceModel(exportTask));
+ NavigationExportTask exportTask = new NavigationExportTask(new
NavigationKey(siteKey, navUri), navigationService, descriptionService, marshaller);
+
+ resultHandler.completed(new ExportResourceModel(exportTask));
+ }
}
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java 2011-09-12
14:44:00 UTC (rev 7358)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageExportResource.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -26,6 +26,8 @@
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.management.exportimport.PageExportTask;
import org.gatein.management.api.ContentType;
+import org.gatein.management.api.PathAddress;
+import org.gatein.management.api.PathTemplateFilter;
import org.gatein.management.api.binding.BindingProvider;
import org.gatein.management.api.exceptions.OperationException;
import org.gatein.management.api.exceptions.ResourceNotFoundException;
@@ -35,8 +37,10 @@
import org.gatein.management.api.operation.model.ExportTask;
import org.gatein.mop.api.workspace.Page;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
/**
@@ -55,6 +59,7 @@
Collection<Page> pagesList = pages.getChildren();
List<ExportTask> tasks = new ArrayList<ExportTask>(pagesList.size());
+
PageExportTask pageExportTask =
new PageExportTask(siteKey, dataStorage, bindingProvider.getMarshaller(
org.exoplatform.portal.config.model.Page.PageSet.class, ContentType.XML));
@@ -64,7 +69,24 @@
{
if (pageName == null)
{
- pageExportTask.addPageName(page.getName());
+ PathAddress pageAddress =
operationContext.getAddress().append(page.getName());
+ // We need to look up the subresource because this sets the path template
resolver to be used by the filter.
+ operationContext.getManagedResource().getSubResource(pageAddress);
+
+ PathTemplateFilter filter;
+ try
+ {
+ filter =
PathTemplateFilter.parse(operationContext.getAttributes().getValues("filter"));
+ }
+ catch (ParseException e)
+ {
+ throw new OperationException(operationContext.getOperationName(),
"Could not parse filter attributes.", e);
+ }
+
+ if (pageAddress.accepts(filter))
+ {
+ pageExportTask.addPageName(page.getName());
+ }
}
else if (pageName.equals(page.getName()))
{
@@ -76,9 +98,14 @@
{
throw new ResourceNotFoundException("No page found for " + new
PageKey(siteKey, pageName));
}
-
- tasks.add(pageExportTask);
-
- resultHandler.completed(new ExportResourceModel(tasks));
+ else if (pageExportTask.getPageNames().isEmpty())
+ {
+ resultHandler.completed(new
ExportResourceModel(Collections.<ExportTask>emptyList()));
+ }
+ else
+ {
+ tasks.add(pageExportTask);
+ resultHandler.completed(new ExportResourceModel(tasks));
+ }
}
}
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java 2011-09-12
20:48:35 UTC (rev 7359)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.mop.management.operations.site;
+
+import org.gatein.management.api.exceptions.OperationException;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Site;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutReadResource extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ ReadResourceModel readResource = new ReadResourceModel(
+ "The site layout for site " + site.getName(),
Collections.<String>emptySet());
+
+ resultHandler.completed(readResource);
+ }
+}
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2011-09-12 14:44:00 UTC (rev 7358)
+++ portal/trunk/pom.xml 2011-09-12 20:48:35 UTC (rev 7359)
@@ -49,7 +49,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<org.gatein.wsrp.version>2.1.0-Beta05</org.gatein.wsrp.version>
<org.gatein.mop.version>1.1.0-Beta05</org.gatein.mop.version>
- <org.gatein.mgmt.version>1.0.0-Beta02</org.gatein.mgmt.version>
+ <org.gatein.mgmt.version>1.0.0-Beta03</org.gatein.mgmt.version>
<org.slf4j.version>1.5.8</org.slf4j.version>
<commons-pool.version>1.5.5</commons-pool.version>
<rhino.version>1.6R5</rhino.version>