Search in sources :

Example 1 with CmsRpcException

use of org.opencms.gwt.CmsRpcException in project opencms-core by alkacon.

the class CmsErrorDialog method handleException.

/**
 * Handles the exception by logging the exception to the server log and displaying an error dialog on the client.<p>
 *
 * @param message the error message
 * @param t the throwable
 */
public static void handleException(String message, Throwable t) {
    StackTraceElement[] trace;
    String className;
    if (t instanceof CmsRpcException) {
        CmsRpcException ex = (CmsRpcException) t;
        trace = ex.getOriginalStackTrace();
        className = ex.getOriginalClassName();
    } else {
        message = CmsClientStringUtil.getMessage(t);
        trace = t.getStackTrace();
        className = t.getClass().getName();
    }
    // send the ticket to the server
    String ticket = CmsLog.log(message + LINE_BREAK + CmsClientStringUtil.getStackTraceAsString(trace, LINE_BREAK));
    String errorMessage = message == null ? className + ": " + Messages.get().key(Messages.GUI_NO_DESCIPTION_0) : message;
    errorMessage += LINE_BREAK + Messages.get().key(Messages.GUI_REASON_0) + ":" + t;
    String details = Messages.get().key(Messages.GUI_TICKET_MESSAGE_3, ticket, className, message) + CmsClientStringUtil.getStackTraceAsString(trace, LINE_BREAK);
    new CmsErrorDialog(errorMessage, details).center();
}
Also used : CmsRpcException(org.opencms.gwt.CmsRpcException)

Example 2 with CmsRpcException

use of org.opencms.gwt.CmsRpcException in project opencms-core by alkacon.

the class CmsVfsSitemapService method changeCategory.

/**
 * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#changeCategory(java.lang.String, org.opencms.util.CmsUUID, java.lang.String, java.lang.String)
 */
public void changeCategory(String entryPoint, CmsUUID id, String title, String name) throws CmsRpcException {
    try {
        name = OpenCms.getResourceManager().getFileTranslator().translateResource(name.trim().replace('/', '-'));
        CmsObject cms = getCmsObject();
        CmsResource categoryResource = cms.readResource(id);
        ensureLock(categoryResource);
        String sitePath = cms.getSitePath(categoryResource);
        String newPath = CmsStringUtil.joinPaths(CmsResource.getParentFolder(sitePath), name);
        cms.writePropertyObject(sitePath, new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, title, null));
        if (!CmsStringUtil.joinPaths("/", newPath, "/").equals(CmsStringUtil.joinPaths("/", sitePath, "/"))) {
            cms.moveResource(sitePath, newPath);
        }
    } catch (Exception e) {
        error(e);
    }
}
Also used : CmsObject(org.opencms.file.CmsObject) CmsResource(org.opencms.file.CmsResource) CmsProperty(org.opencms.file.CmsProperty) CmsRoleViolationException(org.opencms.security.CmsRoleViolationException) CmsXmlException(org.opencms.xml.CmsXmlException) CmsSecurityException(org.opencms.security.CmsSecurityException) CmsVfsResourceNotFoundException(org.opencms.file.CmsVfsResourceNotFoundException) CmsRpcException(org.opencms.gwt.CmsRpcException) PatternSyntaxException(java.util.regex.PatternSyntaxException) CmsException(org.opencms.main.CmsException) CmsLoaderException(org.opencms.loader.CmsLoaderException)

Example 3 with CmsRpcException

use of org.opencms.gwt.CmsRpcException in project opencms-core by alkacon.

the class CmsVfsSitemapService method getResourceLink.

/**
 * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#getResourceLink(org.opencms.util.CmsUUID, java.lang.String)
 */
public String getResourceLink(CmsUUID baseId, String sitePath) throws CmsRpcException {
    try {
        CmsObject cms = OpenCms.initCmsObject(getCmsObject());
        CmsResource baseResource = cms.readResource(baseId, CmsResourceFilter.IGNORE_EXPIRATION);
        String contextPath = cms.getSitePath(baseResource);
        cms.getRequestContext().setUri(contextPath);
        String result = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, sitePath);
        return result;
    } catch (Exception e) {
        error(e);
    }
    return null;
}
Also used : CmsObject(org.opencms.file.CmsObject) CmsResource(org.opencms.file.CmsResource) CmsRoleViolationException(org.opencms.security.CmsRoleViolationException) CmsXmlException(org.opencms.xml.CmsXmlException) CmsSecurityException(org.opencms.security.CmsSecurityException) CmsVfsResourceNotFoundException(org.opencms.file.CmsVfsResourceNotFoundException) CmsRpcException(org.opencms.gwt.CmsRpcException) PatternSyntaxException(java.util.regex.PatternSyntaxException) CmsException(org.opencms.main.CmsException) CmsLoaderException(org.opencms.loader.CmsLoaderException)

Example 4 with CmsRpcException

use of org.opencms.gwt.CmsRpcException in project opencms-core by alkacon.

the class CmsVfsSitemapService method createSubSitemap.

/**
 * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#createSubSitemap(org.opencms.util.CmsUUID)
 */
public CmsSitemapChange createSubSitemap(CmsUUID entryId) throws CmsRpcException {
    CmsObject cms = getCmsObject();
    try {
        ensureSession();
        CmsResource subSitemapFolder = cms.readResource(entryId);
        ensureLock(subSitemapFolder);
        String sitePath = cms.getSitePath(subSitemapFolder);
        createSitemapContentFolder(cms, subSitemapFolder);
        subSitemapFolder.setType(getSubsitemapType());
        cms.writeResource(subSitemapFolder);
        tryUnlock(subSitemapFolder);
        CmsSitemapClipboardData clipboard = getClipboardData();
        CmsClientSitemapEntry entry = toClientEntry(getNavBuilder().getNavigationForResource(sitePath, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED), false);
        clipboard.addModified(entry);
        setClipboardData(clipboard);
        CmsSitemapChange result = new CmsSitemapChange(entry.getId(), entry.getSitePath(), ChangeType.modify);
        result.setUpdatedEntry(entry);
        return result;
    } catch (Exception e) {
        error(e);
    }
    return null;
}
Also used : CmsObject(org.opencms.file.CmsObject) CmsResource(org.opencms.file.CmsResource) CmsSitemapChange(org.opencms.ade.sitemap.shared.CmsSitemapChange) CmsClientSitemapEntry(org.opencms.ade.sitemap.shared.CmsClientSitemapEntry) CmsSitemapClipboardData(org.opencms.ade.sitemap.shared.CmsSitemapClipboardData) CmsRoleViolationException(org.opencms.security.CmsRoleViolationException) CmsXmlException(org.opencms.xml.CmsXmlException) CmsSecurityException(org.opencms.security.CmsSecurityException) CmsVfsResourceNotFoundException(org.opencms.file.CmsVfsResourceNotFoundException) CmsRpcException(org.opencms.gwt.CmsRpcException) PatternSyntaxException(java.util.regex.PatternSyntaxException) CmsException(org.opencms.main.CmsException) CmsLoaderException(org.opencms.loader.CmsLoaderException)

Example 5 with CmsRpcException

use of org.opencms.gwt.CmsRpcException in project opencms-core by alkacon.

the class CmsVfsSitemapService method createCategory.

/**
 * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#createCategory(java.lang.String, org.opencms.util.CmsUUID, java.lang.String, java.lang.String)
 */
public void createCategory(String entryPoint, CmsUUID id, String title, String name) throws CmsRpcException {
    try {
        if ((name == null) || (name.length() == 0)) {
            name = title;
        }
        name = OpenCms.getResourceManager().getFileTranslator().translateResource(name.trim().replace('/', '-'));
        CmsObject cms = getCmsObject();
        CmsCategoryService catService = CmsCategoryService.getInstance();
        CmsCategory createdCategory = null;
        if (id.isNullUUID()) {
            String localRepositoryPath = CmsStringUtil.joinPaths(entryPoint, CmsCategoryService.getInstance().getRepositoryBaseFolderName(getCmsObject()));
            // ensure category repository exists
            if (!cms.existsResource(localRepositoryPath)) {
                tryUnlock(cms.createResource(localRepositoryPath, OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.getStaticTypeName())));
            }
            createdCategory = catService.createCategory(cms, null, name, title, "", localRepositoryPath);
        } else {
            CmsResource parentResource = cms.readResource(id);
            CmsCategory parent = catService.getCategory(cms, parentResource);
            createdCategory = catService.createCategory(cms, parent, name, title, "", cms.getRequestContext().removeSiteRoot(parentResource.getRootPath()));
        }
        tryUnlock(cms.readResource(createdCategory.getId()));
    } catch (Exception e) {
        error(e);
    }
}
Also used : CmsObject(org.opencms.file.CmsObject) CmsResource(org.opencms.file.CmsResource) CmsCategoryService(org.opencms.relations.CmsCategoryService) CmsCategory(org.opencms.relations.CmsCategory) CmsRoleViolationException(org.opencms.security.CmsRoleViolationException) CmsXmlException(org.opencms.xml.CmsXmlException) CmsSecurityException(org.opencms.security.CmsSecurityException) CmsVfsResourceNotFoundException(org.opencms.file.CmsVfsResourceNotFoundException) CmsRpcException(org.opencms.gwt.CmsRpcException) PatternSyntaxException(java.util.regex.PatternSyntaxException) CmsException(org.opencms.main.CmsException) CmsLoaderException(org.opencms.loader.CmsLoaderException)

Aggregations

CmsRpcException (org.opencms.gwt.CmsRpcException)28 CmsException (org.opencms.main.CmsException)25 CmsObject (org.opencms.file.CmsObject)23 CmsResource (org.opencms.file.CmsResource)21 CmsXmlException (org.opencms.xml.CmsXmlException)21 CmsVfsResourceNotFoundException (org.opencms.file.CmsVfsResourceNotFoundException)18 CmsLoaderException (org.opencms.loader.CmsLoaderException)12 PatternSyntaxException (java.util.regex.PatternSyntaxException)10 CmsRoleViolationException (org.opencms.security.CmsRoleViolationException)10 CmsSecurityException (org.opencms.security.CmsSecurityException)10 CmsUUID (org.opencms.util.CmsUUID)10 Locale (java.util.Locale)9 CmsADEConfigData (org.opencms.ade.configuration.CmsADEConfigData)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 CmsFile (org.opencms.file.CmsFile)6 CmsXmlContent (org.opencms.xml.content.CmsXmlContent)6 CmsIllegalArgumentException (org.opencms.main.CmsIllegalArgumentException)5 CmsProperty (org.opencms.file.CmsProperty)4 CmsContentDefinition (org.opencms.ade.contenteditor.shared.CmsContentDefinition)3 CmsClientSitemapEntry (org.opencms.ade.sitemap.shared.CmsClientSitemapEntry)3