Author: hfnukal
Date: 2012-06-22 09:04:56 -0400 (Fri, 22 Jun 2012)
New Revision: 8738
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
Log:
Bug 807281 - NPE when calling export-resource on an invalid navigation node.
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java 2012-06-22
12:57:31 UTC (rev 8737)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/FilteredNavigationExportResource.java 2012-06-22
13:04:56 UTC (rev 8738)
@@ -32,6 +32,7 @@
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.exceptions.ResourceNotFoundException;
import org.gatein.management.api.operation.OperationContext;
import org.gatein.management.api.operation.OperationContextDelegate;
import org.gatein.management.api.operation.OperationHandler;
@@ -104,6 +105,10 @@
resultHandler.completed(new ExportResourceModel(task));
}
}
+ catch (ResourceNotFoundException e)
+ {
+ throw e;
+ }
catch (OperationException e)
{
throw new OperationException(e.getOperationName(), getStepMessage(e, address,
stepResultHandler), e);
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2012-06-22
12:57:31 UTC (rev 8737)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/navigation/NavigationExportResource.java 2012-06-22
13:04:56 UTC (rev 8738)
@@ -27,6 +27,7 @@
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.management.exportimport.NavigationExportTask;
import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NodeContext;
import org.gatein.management.api.ContentType;
import org.gatein.management.api.PathTemplateFilter;
import org.gatein.management.api.binding.BindingProvider;
@@ -76,10 +77,16 @@
DescriptionService descriptionService =
operationContext.getRuntimeContext().getRuntimeComponent(DescriptionService.class);
NavigationService navigationService =
operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
+ NavigationKey navigationKey = new NavigationKey(siteKey, navUri);
+
+ // Find navigation first
+ NodeContext<?> context = NavigationUtils.loadNode(navigationService,
navigationService.loadNavigation(siteKey), navigationKey.getNavUri());
+ if (context == null) throw new ResourceNotFoundException("Navigation node
not found for navigation uri '" + navUri +"'");
+
BindingProvider bindingProvider = operationContext.getBindingProvider();
Marshaller<PageNavigation> marshaller =
bindingProvider.getMarshaller(PageNavigation.class, ContentType.XML);
- NavigationExportTask exportTask = new NavigationExportTask(new
NavigationKey(siteKey, navUri), navigationService, descriptionService, marshaller);
+ NavigationExportTask exportTask = new NavigationExportTask(navigationKey,
navigationService, descriptionService, marshaller);
resultHandler.completed(new ExportResourceModel(exportTask));
}