Package org.gatein.management.api.exceptions

Examples of org.gatein.management.api.exceptions.OperationException


        endRequest(operationName, chromatticManager, importError);
    }

    // See GTNPORTAL-3257
    private static void endRequest(String operationName, ChromatticManager manager, OperationException importError) {
        OperationException error = importError;
        try {
            // End the request to flush out anything that might go wrong when finalizing the request.
            manager.endRequest(true);
        } catch (Throwable t) {
            // This allows us to properly respond with an error (500 in REST scenario) if ChromatticManager.endRequest fails
            if (importError == null) {
                log.error("Exception occurred ending the request of ChromatticManager after a successful import.", t);
                error = new OperationException(operationName, "An exception occurred after a successful import. See server logs for more details");
            } else {
                log.error("Exception occurred ending the request of ChromatticManager after a failed import.", t);
            }
        } finally {
            // Start it again, as the calling container ends all ComponentRequestLifecycle's, and we don't want the end to be called w/out it beginning again.
View Full Code Here


        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, 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 (ResourceNotFoundException e) {
            throw e;
        } 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);
        }
    }
View Full Code Here

                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)) {
View Full Code Here

        String operationName = operationContext.getOperationName();
        PathAddress address = operationContext.getAddress();

        String siteType = address.resolvePathTemplate("site-type");
        if (siteType == null)
            throw new OperationException(operationName, "Site type was not specified.");

        ObjectType<Site> objectType = Utils.getObjectType(Utils.getSiteType(siteType));
        if (objectType == null) {
            throw new ResourceNotFoundException("No site type found for " + siteType);
        }

        POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
        POMSession session = mgr.getSession();
        if (session == null)
            throw new OperationException(operationName, "MOP session was null");

        Workspace workspace = session.getWorkspace();
        if (workspace == null)
            throw new OperationException(operationName, "MOP workspace was null");

        execute(operationContext, resultHandler, workspace, objectType);
    }
View Full Code Here

        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);
        }
    }
View Full Code Here

            } else if (site.getObjectType() == ObjectType.GROUP_SITE) {
                children.add("group");
            } else if (site.getObjectType() == ObjectType.USER_SITE) {
                children.add("user");
            } else {
                throw new OperationException(operationContext.getOperationName(), "Unknown site type " + site.getObjectType());
            }
        } else {
            if (site.getObjectType() == ObjectType.GROUP_SITE) {
                Collection<? extends Site> groupsites = site.getWorkspace().getSites(site.getObjectType());
                for (Site groupsite : groupsites) {
View Full Code Here

        String operationName = operationContext.getOperationName();
        PathAddress address = operationContext.getAddress();

        String siteName = address.resolvePathTemplate("site-name");
        if (siteName == null)
            throw new OperationException(operationName, "No site name specified.");

        SiteKey siteKey = getSiteKey(siteType, siteName);

        Site site = workspace.getSite(siteType, siteKey.getName());
        if (site == null)
View Full Code Here

                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());
                }
View Full Code Here

        String pageName = operationContext.getAddress().resolvePathTemplate("page-name");
        if (pageName == null) { // retrieve pages
            try {
                resultHandler.completed(PageUtils.getAllPages(dataStorage, pageService, siteKey));
            } catch (Exception e) {
                throw new OperationException(operationName, "Could not retrieve pages for site " + siteKey);
            }
        } else {
            PageKey key = new PageKey(siteKey, pageName);
            try {
                Page page = PageUtils.getPage(dataStorage, pageService, key);
                if (page == null) {
                    throw new ResourceNotFoundException("No page found for " + key);
                } else {
                    resultHandler.completed(page);
                }
            } catch (ResourceNotFoundException e) {
                throw e;
            } catch (OperationException e) {
                throw e;
            } catch (Exception e) {
                throw new OperationException(operationName, "Operation failed getting page for " + key, e);
            }
        }
    }
View Full Code Here

         }
      }
      else
      {
         // Why pass in operation name, if it's not used as part of the message...
         throw new OperationException(operationName, "Operation '" + operationName  + "' not found for address '" + address + "'");
      }
   }
View Full Code Here

TOP

Related Classes of org.gatein.management.api.exceptions.OperationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.