Package org.gatein.management.api.exceptions

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


                expanded.put(newSiteKey, newMopImport);
            }

        } catch (Throwable t) {
            throw new OperationException("Import portal template", t.getMessage(), t);
        }

        return expanded;
    }
View Full Code Here


                expanded.put(newSiteKey, newMopImport);
            }

        } catch (Throwable t) {
            throw new OperationException("Import group template", t.getMessage(), t);
        }

        return expanded;
    }
View Full Code Here

                expanded.put(newSiteKey, newMopImport);
            }

        } catch (Throwable t) {
            throw new OperationException("Import user template", t.getMessage(), t);
        }

        return expanded;
    }
View Full Code Here

    private OperationException performImport(OperationAttributes attr, Map<SiteKey, MopImport> importMap)
            throws OperationException {

        // Performs import
        Map<SiteKey, MopImport> importsRan = new HashMap<SiteKey, MopImport>();
        OperationException importError = null;
        try {
            log.info("Performing import using importMode '" + attr.importMode + "'");
            for (Map.Entry<SiteKey, MopImport> mopImportEntry : importMap.entrySet()) {
                SiteKey siteKey = mopImportEntry.getKey();
                MopImport mopImport = mopImportEntry.getValue();
                MopImport ran = new MopImport();

                if (importsRan.containsKey(siteKey)) {
                    throw new IllegalStateException("Multiple site imports for same operation.");
                }
                importsRan.put(siteKey, ran);

                log.debug("Importing data for site " + siteKey);

                // Site layout import
                if (mopImport.siteTask != null) {
                    log.debug("Importing site layout data.");
                    ran.siteTask = mopImport.siteTask;
                    mopImport.siteTask.importData(attr.importMode);
                }

                // Pages import
                if (mopImport.pageTask != null) {
                    log.debug("Importing page data.");
                    ran.pageTask = mopImport.pageTask;
                    mopImport.pageTask.importData(attr.importMode);
                }

                // Navigation import
                if (mopImport.navigationTask != null) {
                    log.debug("Importing navigation data.");
                    ran.navigationTask = mopImport.navigationTask;
                    mopImport.navigationTask.importData(attr.importMode);
                }
            }
            log.info("Import successful !");
        } catch (Throwable t) {
            boolean rollbackSuccess = true;
            log.error("Exception importing data.", t);
            log.info("Attempting to rollback data modified by import.");
            for (Map.Entry<SiteKey, MopImport> mopImportEntry : importsRan.entrySet()) {
                SiteKey siteKey = mopImportEntry.getKey();
                MopImport mopImport = mopImportEntry.getValue();

                log.debug("Rolling back imported data for site " + siteKey);
                if (mopImport.navigationTask != null) {
                    log.debug("Rolling back navigation modified during import...");
                    try {
                        mopImport.navigationTask.rollback();
                    } catch (Throwable t1) // Continue rolling back even though there are exceptions.
                    {
                        rollbackSuccess = false;
                        log.error("Error rolling back navigation data for site " + siteKey, t1);
                    }
                }
                if (mopImport.pageTask != null) {
                    log.debug("Rolling back pages modified during import...");
                    try {
                        mopImport.pageTask.rollback();
                    } catch (Throwable t1) // Continue rolling back even though there are exceptions.
                    {
                        rollbackSuccess = false;
                        log.error("Error rolling back page data for site " + siteKey, t1);
                    }
                }
                if (mopImport.siteTask != null) {
                    log.debug("Rolling back site layout modified during import...");
                    try {
                        mopImport.siteTask.rollback();
                    } catch (Throwable t1) // Continue rolling back even though there are exceptions.
                    {
                        rollbackSuccess = false;
                        log.error("Error rolling back site layout for site " + siteKey, t1);
                    }
                }
            }

            String message = (rollbackSuccess) ?
                    "Error during import. Tasks successfully rolled back. Portal should be back to consistent state."
                    : "Error during import. Errors in rollback as well. Portal may be in an inconsistent state.";

            importError = new OperationException(attr.operationName, message, t);
        } finally {
            importMap.clear();
            importsRan.clear();
        }
View Full Code Here

    }

    // See GTNPORTAL-3257
    private static void endRequest(OperationAttributes attr, BackendServices svc, OperationException importError) {

        OperationException error = importError;
        try {
            // End the request to flush out anything that might go wrong when finalizing the request.
            svc.chromatticManager.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(attr.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);
            }
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.