protected String getClosestSafePath(PageInstance newParent, String newName) { String path = newParent.getPath(); int indexOfDetail = path.indexOf(PageInstance.DETAIL); if(indexOfDetail > 0) { return path.substring(0, indexOfDetail); } else { return path + (path.endsWith("/") ? "" : "/") + newName; } }
/** * Reconstructs the URL path to this PageInstance from the root of the application (not including the * webapp's context path). */ public String getPath() { if(getParent() == null) { return ""; } else { return getParent().getPath() + "/" + getUrlFragment(); } }
if(dispatch != null) { logger.debug("The protected resource is a page action"); resource = dispatch.getLastPageInstance().getPath(); allowed = hasPermissions(configuration, dispatch, subject, handler); } else {
@Override protected ClassAccessor prepare(PageInstance pageInstance) { Database actualDatabase = getCrudConfiguration().getActualDatabase(); if (actualDatabase == null) { logger.warn("Crud " + crudConfiguration.getName() + " (" + pageInstance.getPath() + ") " + "has an invalid database: " + getCrudConfiguration().getDatabase()); return null; } baseTable = getCrudConfiguration().getActualTable(); if (baseTable == null) { logger.warn("Crud " + crudConfiguration.getName() + " (" + pageInstance.getPath() + ") " + "has an invalid table"); return null; } return new TableAccessor(baseTable); }
@Override public void setPageInstance(PageInstance pageInstance) { super.setPageInstance(pageInstance); this.crudConfiguration = (CrudConfiguration) pageInstance.getConfiguration(); if (crudConfiguration == null) { logger.warn("Crud is not configured: " + pageInstance.getPath()); return; } ClassAccessor innerAccessor = prepare(pageInstance); if (innerAccessor == null) { return; } classAccessor = new CrudAccessor(crudConfiguration, innerAccessor); pkHelper = new PkHelper(classAccessor); }
start++; } else { sb.append(parentPageInstance.getPath());
logger.error("Error deleting page", e); return new RedirectResolution(StringUtils.defaultIfEmpty(parentPageInstance.getPath(), "/"));
@Button(list = "edit-content", key = "update", order = 1, type = Button.TYPE_PRIMARY) @RequiresPermissions(level = AccessLevel.VIEW, permissions = { PERMISSION_EDIT }) public Resolution updateContent() { title = context.getRequest().getParameter("title"); title = StringUtils.trimToNull(title); if (title == null) { SessionMessages.addErrorMessage(ElementsThreadLocals.getText("title.cannot.be.empty")); return new ForwardResolution("/m/pageactions/text/edit-content.jsp"); } description = context.getRequest().getParameter("description"); description = StringUtils.trimToNull(description); Page page = pageInstance.getPage(); page.setTitle(title); page.setDescription(description); try { DispatcherLogic.savePage(pageInstance.getDirectory(), page); saveContent(); SessionMessages.addInfoMessage(ElementsThreadLocals.getText("object.updated.successfully")); } catch (Exception e) { logger.error("Could not save content for page " + pageInstance.getPath(), e); SessionMessages.addInfoMessage(ElementsThreadLocals.getText("update.failed")); } return cancel(); }
String prefix = ""; if(rootPageIndex > 0) { prefix += rootPageInstance.getParent().getPath() + "/" + rootPageInstance.getName();
parentDirectory = parentPageInstance.getDirectory(); directory = parentPageInstance.getChildPageDirectory(fragment); configurePath = parentPageInstance.getPath(); break; default: