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();
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations