Author: nscavell
Date: 2011-07-27 20:02:21 -0400 (Wed, 27 Jul 2011)
New Revision: 6938
Added:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
Removed:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
portal/branches/gatein-management/pom.xml
Log:
Clarify difference between reading resources and reading configuration.
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/MopManagementExtension.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -26,12 +26,13 @@
import org.exoplatform.portal.mop.management.operations.MopImportResource;
import org.exoplatform.portal.mop.management.operations.MopReadResource;
import
org.exoplatform.portal.mop.management.operations.navigation.NavigationExportResource;
+import
org.exoplatform.portal.mop.management.operations.navigation.NavigationReadConfigAsXml;
import
org.exoplatform.portal.mop.management.operations.navigation.NavigationReadResource;
import org.exoplatform.portal.mop.management.operations.page.PageExportResource;
+import org.exoplatform.portal.mop.management.operations.page.PageReadConfigAsXml;
import org.exoplatform.portal.mop.management.operations.page.PageReadResource;
-import org.exoplatform.portal.mop.management.operations.page.PagesReadResource;
import org.exoplatform.portal.mop.management.operations.site.SiteLayoutExportResource;
-import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadResource;
+import org.exoplatform.portal.mop.management.operations.site.SiteLayoutReadConfigAsXml;
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,43 +55,59 @@
registration.registerBindingProvider(MopBindingProvider.INSTANCE);
ManagedResource.Registration mop =
registration.registerManagedResource(description("MOP (Model Object for Portal)
Managed Resource"));
- mop.registerOperationHandler("import-resource", new MopImportResource(),
description("Imports mop data from an exported zip file."), true);
+ mop.registerOperationHandler(OperationNames.IMPORT_RESOURCE, new
MopImportResource(), description("Imports mop data from an exported zip
file."));
- mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(),
description("Lists the available site types for a portal."));
+ mop.registerOperationHandler(OperationNames.READ_RESOURCE, new MopReadResource(),
description("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("Lists the available sites for a site
type."));
+ sitetypes.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteTypeReadResource(), description("Available sites for a given site type."));
- //TODO: Would be nice to find acceptable regex for site name, nav uri, page name
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("Lists all available artifacts for a given site (ie
pages, navigation, site layout)"));
+ sites.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteReadResource(), description("Available artifacts for a given site (ie pages,
navigation, site layout)"));
- // Site layout management and operation registration
+ // Site Layout management
+ siteLayoutManagementRegistration(sites);
+
+ // Page management
+ pageManagementRegistration(sites);
+
+ // Navigation management
+ navigationManagementRegistration(sites);
+ }
+
+ private void siteLayoutManagementRegistration(ManagedResource.Registration sites)
+ {
ManagedResource.Registration siteLayout =
sites.registerSubResource("portal", description("Management resource
responsible for handling management operations for a site layout."));
- siteLayout.registerOperationHandler(OperationNames.READ_RESOURCE, new
SiteLayoutReadResource(), description("Retrieves site layout data for a specific
site."));
- siteLayout.registerOperationHandler(OperationNames.EXPORT_RESOURCE, new
SiteLayoutExportResource(), description("Exports a site layout as a zip
file."));
+ 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."));
+ }
- // Page management and operation registration
- PageExportResource pageExport = new PageExportResource();
- PageReadResource pageReadResource = new PageReadResource();
+ 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."));
- pages.registerOperationHandler(OperationNames.READ_RESOURCE, new
PagesReadResource(), description("Lists all available pages available for a
site."));
- pages.registerOperationHandler(OperationNames.EXPORT_RESOURCE, pageExport,
description("Exports all pages for a site as a zip file."));
- ManagedResource.Registration page =
pages.registerSubResource("{page-name}", description("Page management
resource representing an individual page."));
- page.registerOperationHandler(OperationNames.READ_RESOURCE, new PageReadResource(),
description("Retrieves page data for a specific site."));
- page.registerOperationHandler(OperationNames.EXPORT_RESOURCE, pageExport,
description("Exports a page as a zip file."));
+ // 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.EXPORT_RESOURCE, new
PageExportResource(), description("Exports pages configuration xml as a zip
file."), true);
- // Navigation management and operation registration
- NavigationReadResource navReadResource = new NavigationReadResource();
- NavigationExportResource navExport = new NavigationExportResource();
- ManagedResource.Registration navigation =
sites.registerSubResource("navigation", description("Navigation management
resource representing a sites navigation."));
- navigation.registerOperationHandler(OperationNames.READ_RESOURCE, navReadResource,
description("Retrieves navigation for a specific site."));
- navigation.registerOperationHandler(OperationNames.EXPORT_RESOURCE, navExport,
description("Exports navigation as a zip file."));
+ // Page name management resource registration
+ pages.registerSubResource("{page-name}", description("Page
management resource representing an individual page."));
+ }
- ManagedResource.Registration navigationNode =
navigation.registerSubResource("{nav-uri: .*}", description("Navigation
node management resource representing a sites navigation."));
- navigationNode.registerOperationHandler(OperationNames.READ_RESOURCE,
navReadResource, description("Retrieves navigation node for a specific
site."));
- navigationNode.registerOperationHandler(OperationNames.EXPORT_RESOURCE, navExport,
description("Exports navigation as a zip file."));
+ private void navigationManagementRegistration(ManagedResource.Registration sites)
+ {
+ // Navigation management resource registration
+ ManagedResource.Registration navigation =
sites.registerSubResource("navigation", description("Management resource
responsible for handling management operations on a sites navigation."));
+
+ // 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.EXPORT_RESOURCE, new
NavigationExportResource(), description("Exports navigation configuration xml as a
zip file."), true);
+
+ // Navigation node management resource registration
+ navigation.registerSubResource("{nav-uri: .*}",
description("Management resource responsible for handling management operations on
specific navigation nodes."));
}
@Override
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/exportimport/NavigationExportTask.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -25,7 +25,7 @@
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.management.operations.navigation.NavigationKey;
-import org.exoplatform.portal.mop.management.operations.navigation.PageNavigationUtils;
+import org.exoplatform.portal.mop.management.operations.navigation.NavigationUtils;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.gatein.management.api.binding.Marshaller;
@@ -64,7 +64,7 @@
@Override
public void export(OutputStream outputStream) throws IOException
{
- PageNavigation navigation = PageNavigationUtils.loadPageNavigation(navigationKey,
navigationService, descriptionService);
+ PageNavigation navigation = NavigationUtils.loadPageNavigation(navigationKey,
navigationService, descriptionService);
marshaller.marshal(navigation, outputStream);
}
}
Copied:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
(from rev 6934,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java)
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadConfigAsXml.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,59 @@
+/*
+ * 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.PageNavigation;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.gatein.management.api.exceptions.ResourceNotFoundException;
+import org.gatein.management.api.operation.OperationContext;
+import org.gatein.management.api.operation.ResultHandler;
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadConfigAsXml extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation defaultNavigation)
+ {
+ String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ Site site = defaultNavigation.getSite();
+ SiteKey siteKey = getSiteKey(site);
+
+ //TODO: If there's any benefit in creating our own node model to use with
navigation service, lets do it
+
+ DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+
+ PageNavigation pageNavigation = NavigationUtils.loadPageNavigation(new
NavigationKey(siteKey, navUri), navigationService, descriptionService);
+ if (pageNavigation == null) throw new ResourceNotFoundException("Navigation
node not found for navigation uri '" + navUri +"'");
+
+ resultHandler.completed(pageNavigation);
+ }
+}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,59 +0,0 @@
-/*
- * 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.PageNavigation;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.ResultHandler;
-import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.Site;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class NavigationReadResource extends AbstractNavigationOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation navigation)
- {
- String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
-
- Site site = navigation.getSite();
- SiteKey siteKey = getSiteKey(site);
-
- //TODO: If there's any benefit in creating our own node model to use with
navigation service, lets do it
-
- DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
- NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
-
- PageNavigation pageNavigation = PageNavigationUtils.loadPageNavigation(new
NavigationKey(siteKey, navUri), navigationService, descriptionService);
- if (pageNavigation == null) throw new ResourceNotFoundException("Navigation
node " + navUri + " not found.");
-
- resultHandler.completed(pageNavigation);
- }
-}
Added:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationReadResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,47 @@
+package org.exoplatform.portal.mop.management.operations.navigation;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NodeContext;
+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.Navigation;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationReadResource extends AbstractNavigationOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Navigation defaultNavigation)
+ {
+ SiteKey siteKey = getSiteKey(defaultNavigation.getSite());
+ String navUri =
operationContext.getAddress().resolvePathTemplate("nav-uri");
+
+ NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ NavigationContext navigation = navigationService.loadNavigation(siteKey);
+
+ Set<String> children = new LinkedHashSet<String>();
+
+ NodeContext<NodeContext<?>> node =
NavigationUtils.loadNode(navigationService, navigation, navUri);
+ if (node == null)
+ {
+ throw new ResourceNotFoundException("Navigation node not found for
navigation uri '" + navUri +"'");
+ }
+
+ for (NodeContext child : node.getNodes())
+ {
+ children.add(child.getName());
+ }
+
+ ReadResourceModel model = new ReadResourceModel("Navigation nodes available at
this resource.", children);
+ resultHandler.completed(model);
+ }
+}
Copied:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
(from rev 6934,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java)
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationUtils.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,220 @@
+/*
+ * 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.I18NString;
+import org.exoplatform.portal.config.model.LocalizedString;
+import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.description.DescriptionService;
+import org.exoplatform.portal.mop.navigation.GenericScope;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NodeContext;
+import org.exoplatform.portal.mop.navigation.NodeModel;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.gatein.mop.api.workspace.Navigation;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class NavigationUtils
+{
+ private NavigationUtils(){}
+
+ public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService
navigationService, DescriptionService descriptionService)
+ {
+ NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
+ if (navigation == null) return null;
+
+ NodeContext<NodeContext<?>> node = loadNode(navigationService,
navigation, key.getNavUri());
+ if (node == null) return null;
+
+ if (key.getNavUri() != null)
+ {
+ return createFragmentedPageNavigation(descriptionService, navigation, node);
+ }
+ else
+ {
+ return createPageNavigation(descriptionService, navigation, node);
+ }
+ }
+
+ public static NodeContext<NodeContext<?>> loadNode(NavigationService
navigationService, NavigationContext navigation, String navUri)
+ {
+ if (navigation == null) return null;
+
+ if (navUri != null)
+ {
+ String[] path = trim(navUri.split("/"));
+ NodeContext<NodeContext<?>> node =
navigationService.loadNode(NodeModel.SELF_MODEL, navigation,
GenericScope.branchShape(path), null);
+ for (String name : path)
+ {
+ node = node.get(name);
+ if (node == null) break;
+ }
+
+ return node;
+ }
+ else
+ {
+ return navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL,
null);
+ }
+ }
+
+ public static PageNavigation createPageNavigation(DescriptionService service,
NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ NavigationFragment fragment = new NavigationFragment();
+ fragment.setNodes(children);
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static PageNavigation createFragmentedPageNavigation(DescriptionService
service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
+ {
+ PageNavigation pageNavigation = new PageNavigation();
+ pageNavigation.setPriority(navigation.getState().getPriority());
+ pageNavigation.setOwnerType(navigation.getKey().getTypeName());
+ pageNavigation.setOwnerId(navigation.getKey().getName());
+
+ ArrayList<PageNode> children = new ArrayList<PageNode>(1);
+ children.add(createPageNode(service, node));
+
+ NavigationFragment fragment = new NavigationFragment();
+ StringBuilder parentUri = new StringBuilder("/");
+ getPath(node.getParent(), parentUri);
+ fragment.setParentURI(parentUri.toString());
+ fragment.setNodes(children);
+
+ pageNavigation.addFragment(fragment);
+
+ return pageNavigation;
+ }
+
+ private static void getPath(NodeContext<NodeContext<?>> node,
StringBuilder parentUri)
+ {
+ if (node == null) return;
+ if (node.getParent() == null) return; // since "default" is the root
node, we ignore it
+
+ parentUri.insert(0, node.getName()).append("/");
+ getPath(node.getParent(), parentUri);
+ }
+
+ private static PageNode createPageNode(DescriptionService service,
NodeContext<NodeContext<?>> node)
+ {
+ PageNode pageNode = new PageNode();
+ pageNode.setName(node.getName());
+
+ if (node.getState().getLabel() == null)
+ {
+ Map<Locale, Described.State> descriptions =
service.getDescriptions(node.getId());
+ if (descriptions != null && !descriptions.isEmpty())
+ {
+ I18NString labels = new I18NString();
+ for (Map.Entry<Locale, Described.State> entry :
descriptions.entrySet())
+ {
+ labels.add(new LocalizedString(entry.getValue().getName(),
entry.getKey()));
+ }
+
+ pageNode.setLabels(labels);
+ }
+ }
+ else
+ {
+ pageNode.setLabel(node.getState().getLabel());
+ }
+
+ pageNode.setIcon(node.getState().getIcon());
+ long startPublicationTime = node.getState().getStartPublicationTime();
+ if (startPublicationTime != -1)
+ {
+ pageNode.setStartPublicationDate(new Date(startPublicationTime));
+ }
+
+ long endPublicationTime = node.getState().getEndPublicationTime();
+ if (endPublicationTime != -1)
+ {
+ pageNode.setEndPublicationDate(new Date(endPublicationTime));
+ }
+
+ pageNode.setVisibility(node.getState().getVisibility());
+ pageNode.setPageReference(node.getState().getPageRef());
+
+ if (node.getNodes() != null)
+ {
+ ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
+ for (NodeContext<?> child : node.getNodes())
+ {
+ @SuppressWarnings("unchecked")
+ NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
+ children.add(createPageNode(service, childNode));
+ }
+
+ pageNode.setChildren(children);
+ }
+ else
+ {
+ pageNode.setChildren(new ArrayList<PageNode>(0));
+ }
+
+ return pageNode;
+ }
+
+ private static String[] trim(String[] array)
+ {
+ List<String> trimmed = new ArrayList<String>(array.length);
+ for (String s : array)
+ {
+ if (s != null && !"".equals(s))
+ {
+ trimmed.add(s);
+ }
+ }
+
+ return trimmed.toArray(new String[trimmed.size()]);
+ }
+}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PageNavigationUtils.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,186 +0,0 @@
-/*
- * 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.I18NString;
-import org.exoplatform.portal.config.model.LocalizedString;
-import org.exoplatform.portal.config.model.NavigationFragment;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.mop.description.DescriptionService;
-import org.exoplatform.portal.mop.navigation.NavigationContext;
-import org.exoplatform.portal.mop.navigation.NavigationService;
-import org.exoplatform.portal.mop.navigation.NodeContext;
-import org.exoplatform.portal.mop.navigation.NodeModel;
-import org.exoplatform.portal.mop.navigation.Scope;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageNavigationUtils
-{
- private PageNavigationUtils(){}
-
- public static PageNavigation loadPageNavigation(NavigationKey key, NavigationService
navigationService, DescriptionService descriptionService)
- {
- NodeContext<NodeContext<?>> node;
- NavigationContext navigation = navigationService.loadNavigation(key.getSiteKey());
- if (navigation == null) return null;
-
- if (key.getNavUri() != null)
- {
- PathScope scope = new PathScope(key.getNavUri());
- node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, scope,
null);
- if (scope.getFoundId() == null) return null;
-
- node = node.getDescendant(scope.getFoundId());
- return createFragmentedPageNavigation(descriptionService, navigation, node);
- }
- else
- {
- node = navigationService.loadNode(NodeModel.SELF_MODEL, navigation, Scope.ALL,
null);
- if (node == null) return null;
-
- return createPageNavigation(descriptionService, navigation, node);
- }
- }
-
- public static PageNavigation createPageNavigation(DescriptionService service,
NavigationContext navigation, NodeContext<NodeContext<?>> node)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setPriority(navigation.getState().getPriority());
- pageNavigation.setOwnerType(navigation.getKey().getTypeName());
- pageNavigation.setOwnerId(navigation.getKey().getName());
-
- ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
- for (NodeContext<?> child : node.getNodes())
- {
- @SuppressWarnings("unchecked")
- NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
- children.add(createPageNode(service, childNode));
- }
-
- NavigationFragment fragment = new NavigationFragment();
- fragment.setNodes(children);
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private static PageNavigation createFragmentedPageNavigation(DescriptionService
service, NavigationContext navigation, NodeContext<NodeContext<?>> node)
- {
- PageNavigation pageNavigation = new PageNavigation();
- pageNavigation.setPriority(navigation.getState().getPriority());
- pageNavigation.setOwnerType(navigation.getKey().getTypeName());
- pageNavigation.setOwnerId(navigation.getKey().getName());
-
- ArrayList<PageNode> children = new ArrayList<PageNode>(1);
- children.add(createPageNode(service, node));
-
- NavigationFragment fragment = new NavigationFragment();
- StringBuilder parentUri = new StringBuilder("/");
- getPath(node.getParent(), parentUri);
- fragment.setParentURI(parentUri.toString());
- fragment.setNodes(children);
-
- pageNavigation.addFragment(fragment);
-
- return pageNavigation;
- }
-
- private static void getPath(NodeContext<NodeContext<?>> node,
StringBuilder parentUri)
- {
- if (node == null) return;
- if (node.getParent() == null) return; // since "default" is the root
node, we ignore it
-
- parentUri.insert(0, node.getName()).append("/");
- getPath(node.getParent(), parentUri);
- }
-
- private static PageNode createPageNode(DescriptionService service,
NodeContext<NodeContext<?>> node)
- {
- PageNode pageNode = new PageNode();
- pageNode.setName(node.getName());
-
- if (node.getState().getLabel() == null)
- {
- Map<Locale, Described.State> descriptions =
service.getDescriptions(node.getId());
- if (descriptions != null && !descriptions.isEmpty())
- {
- I18NString labels = new I18NString();
- for (Map.Entry<Locale, Described.State> entry :
descriptions.entrySet())
- {
- labels.add(new LocalizedString(entry.getValue().getName(),
entry.getKey()));
- }
-
- pageNode.setLabels(labels);
- }
- }
- else
- {
- pageNode.setLabel(node.getState().getLabel());
- }
-
- pageNode.setIcon(node.getState().getIcon());
- long startPublicationTime = node.getState().getStartPublicationTime();
- if (startPublicationTime != -1)
- {
- pageNode.setStartPublicationDate(new Date(startPublicationTime));
- }
-
- long endPublicationTime = node.getState().getEndPublicationTime();
- if (endPublicationTime != -1)
- {
- pageNode.setEndPublicationDate(new Date(endPublicationTime));
- }
-
- pageNode.setVisibility(node.getState().getVisibility());
- pageNode.setPageReference(node.getState().getPageRef());
-
- if (node.getNodes() != null)
- {
- ArrayList<PageNode> children = new
ArrayList<PageNode>(node.getNodeCount());
- for (NodeContext<?> child : node.getNodes())
- {
- @SuppressWarnings("unchecked")
- NodeContext<NodeContext<?>> childNode =
(NodeContext<NodeContext<?>>) child;
- children.add(createPageNode(service, childNode));
- }
-
- pageNode.setChildren(children);
- }
- else
- {
- pageNode.setChildren(new ArrayList<PageNode>(0));
- }
-
- return pageNode;
- }
-}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/PathScope.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,127 +0,0 @@
-/*
- * 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.mop.navigation.NodeState;
-import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.mop.navigation.VisitMode;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PathScope implements Scope
-{
- private String path;
- private String foundId;
-
- public PathScope(String path)
- {
- if (path == null) throw new IllegalArgumentException("path is null.");
- this.path = path;
- }
-
- @Override
- public Visitor get()
- {
- final String[] segments = trim(path.split("/"));
- return new Visitor()
- {
- @Override
- public VisitMode enter(int depth, String id, String name, NodeState state)
- {
- if (depth == 0)
- {
- return VisitMode.ALL_CHILDREN;
- }
- assert depth > 0;
-
- if (depth < segments.length)
- {
- if (name.equals(segments[depth-1]))
- {
- return VisitMode.ALL_CHILDREN;
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
- else if (depth == segments.length)
- {
- if (name.equals(segments[depth-1]))
- {
- foundId = id;
- return VisitMode.ALL_CHILDREN;
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
- else if (depth > segments.length)
- {
- if (foundId != null)
- {
- return VisitMode.ALL_CHILDREN;
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
- else
- {
- return VisitMode.NO_CHILDREN;
- }
- }
-
- @Override
- public void leave(int depth, String id, String name, NodeState state)
- {
- }
- };
- }
-
- String getFoundId()
- {
- return foundId;
- }
-
- private String[] trim(String[] array)
- {
- List<String> trimmed = new ArrayList<String>(array.length);
- for (String s : array)
- {
- if (s != null && !"".equals(s))
- {
- trimmed.add(s);
- }
- }
-
- return trimmed.toArray(new String[trimmed.size()]);
- }
-}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/AbstractPageQueryOperation.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,34 +0,0 @@
-/*
- * 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.page;
-
-import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.management.api.operation.QueryOperationHandler;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public abstract class AbstractPageQueryOperation extends
QueryOperationHandler<PageData>
-{
-}
Copied:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
(from rev 6934,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java)
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadConfigAsXml.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,68 @@
+/*
+ * 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.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+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 java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadConfigAsXml extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
org.gatein.mop.api.workspace.Page rootPage) throws ResourceNotFoundException,
OperationException
+ {
+ SiteKey siteKey = getSiteKey(rootPage.getSite());
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+
+ String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
+ if (pageName == null)
+ {
+ resultHandler.completed(PageUtils.getAllPages(dataStorage, siteKey,
operationContext.getOperationName()));
+ }
+ else
+ {
+ PageKey key = new PageKey(siteKey, pageName);
+ Page page = PageUtils.getPage(dataStorage, key,
operationContext.getOperationName());
+ if (page == null)
+ {
+ throw new ResourceNotFoundException("No page found for " + key);
+ }
+ else
+ {
+ resultHandler.completed(page);
+ }
+ }
+ }
+}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,72 +0,0 @@
-/*
- * 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.page;
-
-import org.exoplatform.portal.config.DataStorage;
-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.mop.api.workspace.Page;
-
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageReadResource extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page pages) throws ResourceNotFoundException, OperationException
- {
- String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
-
- if (pageName == null)
- throw new OperationException(operationContext.getOperationName(), "No page
name specified.");
-
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
-
- PageKey key = new PageKey(getSiteKey(pages.getSite()), pageName);
- try
- {
- org.exoplatform.portal.config.model.Page page =
dataStorage.getPage(key.getPageId());
- if (page == null)
- {
- throw new ResourceNotFoundException("No page found for " + key);
- }
- else
- {
- resultHandler.completed(page);
- }
- }
- catch (ResourceNotFoundException nfe)
- {
- throw nfe;
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(),
"Operation failed getting page for " + key, e);
- }
- }
-}
Added:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageReadResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,50 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+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.Page;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageReadResource extends AbstractPageOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page rootPage) throws ResourceNotFoundException, OperationException
+ {
+ String pageName =
operationContext.getAddress().resolvePathTemplate("page-name");
+ if (pageName == null)
+ {
+ Collection<Page> pageList = rootPage.getChildren();
+ Set<String> children = new LinkedHashSet<String>(pageList.size());
+ for (Page page : pageList)
+ {
+ children.add(page.getName());
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of all available pages
for site '" + rootPage.getSite().getName() +"'", children));
+ }
+ else
+ {
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ PageKey pageKey = new PageKey(getSiteKey(rootPage.getSite()), pageName);
+
+ if (PageUtils.getPage(dataStorage, pageKey, operationContext.getOperationName())
== null)
+ {
+ throw new ResourceNotFoundException("No page found for " +
pageKey);
+ }
+
+ resultHandler.completed(new ReadResourceModel("List of child pages for page
'" + pageName +"'", Collections.<String>emptySet()));
+ }
+ }
+}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUpdateResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,47 +0,0 @@
-/*
- * 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.page;
-
-import org.exoplatform.portal.mop.management.model.PageDataContainer;
-import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.UpdateOperationHandler;
-
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PageUpdateResource extends UpdateOperationHandler<PageData>
-{
- private static final PagesUpdateResource delegate = new PagesUpdateResource();
-
- @Override
- protected void execute(OperationContext operationContext, PageData page) throws
ResourceNotFoundException, OperationException
- {
- delegate.execute(operationContext, new
PageDataContainer(Collections.singletonList(page)));
- }
-}
Added:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PageUtils.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,48 @@
+package org.exoplatform.portal.mop.management.operations.page;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.gatein.management.api.exceptions.OperationException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class PageUtils
+{
+ private PageUtils(){}
+
+ public static Page getPage(DataStorage dataStorage, PageKey pageKey, String
operationName)
+ {
+ try
+ {
+ return dataStorage.getPage(pageKey.getPageId());
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationName, "Operation failed getting page
for " + pageKey, e);
+ }
+ }
+
+ public static Page.PageSet getAllPages(DataStorage dataStorage, SiteKey siteKey,
String operationName)
+ {
+ Query<Page> query = new Query<Page>(siteKey.getTypeName(),
siteKey.getName(), Page.class);
+ try
+ {
+ List<Page> pageList = dataStorage.find(query).getAll();
+ Page.PageSet pages = new Page.PageSet();
+ pages.setPages(new ArrayList<Page>(pageList));
+
+ return pages;
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationName, "Could not retrieve pages for
site " + siteKey);
+ }
+ }
+}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesReadResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,54 +0,0 @@
-/*
- * 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.page;
-
-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.Page;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PagesReadResource extends AbstractPageOperationHandler
-{
- @Override
- protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Page pages) throws ResourceNotFoundException, OperationException
- {
- Collection<Page> pageList = pages.getChildren();
- Set<String> children = new LinkedHashSet<String>(pageList.size());
- for (Page page : pageList)
- {
- children.add(page.getName());
- }
-
- resultHandler.completed(new ReadResourceModel("List of pages available for
given site.", children));
- }
-}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/page/PagesUpdateResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,58 +0,0 @@
-/*
- * 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.page;
-
-import org.exoplatform.portal.mop.management.model.PageDataContainer;
-import org.exoplatform.portal.pom.data.ModelDataStorage;
-import org.exoplatform.portal.pom.data.PageData;
-import org.gatein.management.api.exceptions.ResourceNotFoundException;
-import org.gatein.management.api.exceptions.OperationException;
-import org.gatein.management.api.operation.OperationContext;
-import org.gatein.management.api.operation.UpdateOperationHandler;
-
-/**
- * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
- * @version $Revision$
- */
-public class PagesUpdateResource extends UpdateOperationHandler<PageDataContainer>
-{
- //TODO: Rollback ?
- //TODO: Maybe use an import api and execute on input stream. See if we can use only
mop api's.
-
- @Override
- protected void execute(OperationContext operationContext, PageDataContainer pages)
throws ResourceNotFoundException, OperationException
- {
- ModelDataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(ModelDataStorage.class);
- for (PageData page : pages.getPages())
- {
- try
- {
- //dataStorage.save(page);
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(), "Could
not update page for address " + operationContext.getAddress(), e);
- }
- }
- }
-}
Copied:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
(from rev 6934,
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java)
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java
(rev 0)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadConfigAsXml.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -0,0 +1,60 @@
+/*
+ * 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.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
+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.mop.api.workspace.Site;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class SiteLayoutReadConfigAsXml extends AbstractSiteOperationHandler
+{
+ @Override
+ protected void execute(OperationContext operationContext, ResultHandler resultHandler,
Site site) throws ResourceNotFoundException, OperationException
+ {
+ DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
+ SiteKey siteKey = getSiteKey(site);
+
+ try
+ {
+ PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
+ resultHandler.completed(portalConfig);
+ }
+ catch (Exception e)
+ {
+ throw new OperationException(operationContext.getOperationName(), "Could
not retrieve site layout for site " + site, e);
+ }
+ }
+}
Deleted:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java 2011-07-27
14:07:50 UTC (rev 6937)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteLayoutReadResource.java 2011-07-28
00:02:21 UTC (rev 6938)
@@ -1,60 +0,0 @@
-/*
- * 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.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.config.tasks.PortalConfigTask;
-import org.exoplatform.portal.pom.data.PortalData;
-import org.exoplatform.portal.pom.data.PortalKey;
-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.mop.api.workspace.Site;
-
-/**
- * @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
- {
- DataStorage dataStorage =
operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
- SiteKey siteKey = getSiteKey(site);
-
- try
- {
- PortalConfig portalConfig = dataStorage.getPortalConfig(siteKey.getTypeName(),
siteKey.getName());
- resultHandler.completed(portalConfig);
- }
- catch (Exception e)
- {
- throw new OperationException(operationContext.getOperationName(), "Could
not retrieve site layout for site " + site, e);
- }
- }
-}
Modified: portal/branches/gatein-management/pom.xml
===================================================================
--- portal/branches/gatein-management/pom.xml 2011-07-27 14:07:50 UTC (rev 6937)
+++ portal/branches/gatein-management/pom.xml 2011-07-28 00:02:21 UTC (rev 6938)
@@ -49,7 +49,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<org.gatein.wsrp.version>2.1.0-Beta04</org.gatein.wsrp.version>
<org.gatein.mop.version>1.1.0-Beta05</org.gatein.mop.version>
-
<org.gatein.mgmt.version>1.0.0-Alpha02-SNAPSHOT</org.gatein.mgmt.version>
+
<org.gatein.mgmt.version>1.0.0-Alpha03-SNAPSHOT</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>