@Override public PageAction getParent() { return pageInstance.getParent().getActionBean(); }
@Override public PageAction getParent() { return pageInstance.getParent().getActionBean(); }
@Path(":pages") @GET @Produces(MimeTypes.APPLICATION_JSON_UTF8) public NavigationItem getPages() { List<PageInstance> pageInstancePath = new ArrayList<PageInstance>(); PageInstance current = pageInstance; while (current != null) { pageInstancePath.add(0, current); current = current.getParent(); } //TODO |dispatch is not cached in REST calls, so we have to build it from actual page instances //TODO |to avoid building it from scratch and losing potential modifications to page instances title and //TODO |description done by pages in the path. Dispatch dispatch = new Dispatch(pageInstancePath.toArray(new PageInstance[pageInstancePath.size()])); return new Navigation( portofinoConfiguration, dispatch, SecurityUtils.getSubject(), false). getRootNavigationItem(); }
public static Permissions calculateActualPermissions(PageInstance instance) { List<Page> pages = new ArrayList<Page>(); while (instance != null) { pages.add(0, instance.getPage()); instance = instance.getParent(); } return calculateActualPermissions(new Permissions(), pages); }
protected void checkActionBeanInvocation(ContainerRequestContext requestContext, PageAction pageAction) { Method handler = resourceInfo.getResourceMethod(); List<PageInstance> pageInstancePath = new ArrayList<PageInstance>(); PageInstance last = pageAction.getPageInstance(); while(last != null) { pageInstancePath.add(0, last); last = last.getParent(); } Dispatch dispatch = new Dispatch(pageInstancePath.toArray(new PageInstance[pageInstancePath.size()])); HttpServletRequest request = ElementsThreadLocals.getHttpServletRequest(); if(!SecurityLogic.isAllowed(request, dispatch, pageAction, handler)) { Response.Status status = SecurityUtils.getSubject().isAuthenticated() ? Response.Status.FORBIDDEN : Response.Status.UNAUTHORIZED; requestContext.abortWith(Response.status(status).build()); } else if(!ButtonsLogic.doGuardsPass(pageAction, handler)) { requestContext.abortWith( Response.status(Response.Status.CONFLICT) .entity("The action couldn't be invoked, a guard did not pass") .build()); } else { logger.debug("Portofino-specific security check passed"); } }
public static boolean isEmbedded(PageAction pageAction) { PageInstance parent = pageAction.getPageInstance().getParent(); if(parent == null) { return false; //Root page } PageAction parentActionBean = parent.getActionBean(); if(parentActionBean == null) { return false; } String parentPath = parentActionBean.getContext().getActionPath(); String myPath = pageAction.getContext().getActionPath(); return !StringUtils.equals(parentPath, myPath); } }
int start = dispatch.getClosestSubtreeRootIndex(); PageInstance pageInstance = dispatch.getPageInstance(start); PageInstance parentPageInstance = pageInstance.getParent(); if(parentPageInstance == null) { start++;
logger.debug("Preparing PageActions"); for(PageInstance page : dispatch.getPageInstancePath()) { if(page.getParent() == null) { logger.debug("Not preparing root"); continue;
public Resolution deletePage() { PageInstance pageInstance = getPageInstance(); PageInstance parentPageInstance = pageInstance.getParent(); if(parentPageInstance == null) { SessionMessages.addErrorMessage(ElementsThreadLocals.getText("you.cant.delete.the.root.page"));
PageInstance oldParent = pageInstance.getParent(); if(oldParent == null) { SessionMessages.addErrorMessage(ElementsThreadLocals.getText("you.cant.copy.or.move.the.root.page")); newParent = new PageInstance(newParent.getParent(), newParent.getDirectory(), oldParent.getPage(), null); newParent.getParameters().addAll(params);
String prefix = ""; if(rootPageIndex > 0) { prefix += rootPageInstance.getParent().getPath() + "/" + rootPageInstance.getName();
/** * Sets up the Elements form(s) */ protected void prepareConfigurationForms() { Page page = pageInstance.getPage(); PageInstance parent = pageInstance.getParent(); assert parent != null; FormBuilder formBuilder = new FormBuilder(EditPage.class) .configPrefix(CONF_FORM_PREFIX) .configFields(PageActionLogic.supportsDetail(getClass()) ? PAGE_CONFIGURATION_FIELDS : PAGE_CONFIGURATION_FIELDS_NO_DETAIL) .configFieldSetNames("Page"); SelectionProvider layoutSelectionProvider = createTemplateSelectionProvider(); formBuilder.configSelectionProvider(layoutSelectionProvider, "template"); SelectionProvider detailLayoutSelectionProvider = createTemplateSelectionProvider(); formBuilder.configSelectionProvider(detailLayoutSelectionProvider, "detailTemplate"); pageConfigurationForm = formBuilder.build(); EditPage edit = new EditPage(); edit.id = page.getId(); edit.title = page.getTitle(); edit.description = page.getDescription(); edit.template = page.getLayout().getTemplate(); edit.detailTemplate = page.getDetailLayout().getTemplate(); pageConfigurationForm.readFromObject(edit); if(script == null) { prepareScript(); } }