Package org.gatein.api

Examples of org.gatein.api.ApiException


    Map<Locale, Described.State> loadDescriptions(String id) {
        try {
            return descriptionService.getDescriptions(id);
        } catch (Throwable t) {
            throw new ApiException("Failed to retrieve descriptions", t);
        }
    }
View Full Code Here


            } else { // look it up
                site = request.getPortal().getSite(siteId);
            }

            if (site == null) {
                throw new ApiException("Could not resolve display name because site " + siteId + " could not be found.");
            }

            i18nResolver = new Navigation18NResolver(descriptionService, bundleManager, site.getLocale(), siteId);
        }
View Full Code Here

    private NodeContext<ApiNode> loadNodeContext(Scope scope, NodeChangeListener<NodeContext<ApiNode>> listener) {
        try {
            return navigationService.loadNode(model, navCtx, scope, listener);
        } catch (Throwable e) {
            throw new ApiException("Failed to load node", e);
        }
    }
View Full Code Here

    void rebaseNodeContext(NodeContext<ApiNode> ctx, Scope scope, NodeChangeListener<NodeContext<ApiNode>> listener) {
        try {
            navigationService.rebaseNode(ctx, scope, listener);
        } catch (Throwable e) {
            throw new ApiException("Failed to refresh node", e);
        }
    }
View Full Code Here

    private void saveNodeContext(NodeContext<ApiNode> ctx, NodeChangeListener<NodeContext<ApiNode>> listener) {
        try {
            navigationService.saveNode(ctx, listener);
        } catch (Throwable e) {
            throw new ApiException("Failed to save node", e);
        }
    }
View Full Code Here

    private void save(NavigationContext ctx) {
        try {
            navigationService.saveNavigation(ctx);
        } catch (Throwable e) {
            throw new ApiException("Failed to save navigation", e);
        }
    }
View Full Code Here

    private void setDescriptions(String id, Map<Locale, Described.State> descriptions) {
        try {
            descriptionService.setDescriptions(id, descriptions);
        } catch (Throwable t) {
            throw new ApiException("Failed to set descriptions", t);
        }
    }
View Full Code Here

            case HIDDEN:
                return org.exoplatform.portal.mop.Visibility.HIDDEN;
            case SYSTEM:
                return org.exoplatform.portal.mop.Visibility.SYSTEM;
            default:
                throw new ApiException("Unknown visibility flag " + flag);
        }
    }
View Full Code Here

            case SYSTEM:
                return Status.SYSTEM;
            case TEMPORAL:
                return Status.PUBLICATION;
            default:
                throw new ApiException("Unknown internal visibility '" + visibility + "'");
        }
    }
View Full Code Here

        if (create) {
            try {
                PortalConfig existing = storage.getPortalConfig(portalConfig.getType(), portalConfig.getName());
                if (existing != null) throw new EntityAlreadyExistsException("Cannot create site. Site " + id + " already exists.");
            } catch (Exception e) {
                throw new ApiException("Exception occurred checking if site already existed before creating site " + id, e);
            }

            // In order to properly create a site (which includes creating it from a template) it seemed much harder
            // to get it working properly (NewPortalConfigListener)
            if (areWeInATestEnvironment()) {
                try {
                    storage.create(portalConfig); // Just create an empty site
                } catch (Exception e) {
                    throw new ApiException("Exception creating site " + id + " in testing environment.");
                }
            } else {
                try {
                    switch (id.getType()) {
                        case SITE:
                            service.createUserPortalConfig(portalConfig.getType(), portalConfig.getName(), templateName);
                            break;
                        case SPACE:
                            service.createGroupSite(portalConfig.getName());
                            break;
                        case DASHBOARD:
                            service.createUserSite(portalConfig.getName());
                            break;
                    }
                } catch (Exception e) {
                    throw new ApiException("Could not create site " + id, e);
                }
            }

            // Retrieve the site that was created above and replay any changes done via the Site api object.
            PortalConfig created;
            try {
                created = storage.getPortalConfig(portalConfig.getType(), portalConfig.getName());
                if (created == null) throw new ApiException("Could not find site after we successfully created it.");

            } catch (Exception e) {
                throw new ApiException("Exception occurred retrieving previously created site " + id);
            }
            SiteImpl createdSite = new SiteImpl(created);

            // Now replay/set the data that may have changed since the call from Portal.create to Portal.save
            if (changed.contains("access")) {
                createdSite.setAccessPermission(getAccessPermission());
            }
            if (changed.contains("edit")) {
                createdSite.setEditPermission(getEditPermission());
            }
            if (changed.contains("skin")) {
                createdSite.setSkin(getSkin());
            }
            if (changed.contains("locale")) {
                createdSite.setLocale(getLocale());
            }
            if (changed.contains("description")) {
                createdSite.setDescription(getDescription());
            }
            if (changed.contains("displayName")) {
                createdSite.setDisplayName(getDisplayName());
            }
            createdSite.getAttributes().putAll(getAttributes());
            this.attributes = createdSite.getAttributes();
            // Now we can set the internal PortalConfig object which should now properly reflect the site that was created
            // above and the changes done via the API
            this.portalConfig = createdSite.portalConfig;
        }

        // Attributes is the only object that can be modified outside the context of this object
        portalConfig.setProperties(Util.from(attributes));

        try {
            storage.save(portalConfig);
            changed = null;
            create = false;
            templateName = null;
        } catch (Exception e) {
            throw new ApiException("Exception occurred trying to save site " + id, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.gatein.api.ApiException

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.