public boolean hasPermission(Page page) { Identity identity = getIdentity(); if (PortalConfig.USER_TYPE.equals(page.getOwnerType())) { if (page.getOwnerId().equals(identity.getUserId())) { page.setModifiable(true); return true; } } if (superUser_.equals(identity.getUserId())) { page.setModifiable(true); return true; } if (hasEditPermission(page)) { page.setModifiable(true); return true; } page.setModifiable(false); String[] accessPerms = page.getAccessPermissions(); if (accessPerms != null) { for (String per : accessPerms) { if (hasPermission(identity, per)) { return true; } } } return false; }
public static void toUIPage(UIPage uiPage, Page model) throws Exception { toUIContainer(uiPage, model); uiPage.setSiteKey(new SiteKey(model.getOwnerType(), model.getOwnerId())); uiPage.setIcon(model.getIcon()); uiPage.setAccessPermissions(model.getAccessPermissions()); uiPage.setEditPermission(model.getEditPermission()); uiPage.setFactoryId(model.getFactoryId()); uiPage.setPageId(model.getPageId()); uiPage.setTitle(model.getTitle()); uiPage.setShowMaxWindow(model.isShowMaxWindow()); uiPage.setModifiable(model.isModifiable()); List<UIPortlet> portlets = new ArrayList<UIPortlet>(); uiPage.findComponentOfType(portlets, UIPortlet.class); for (UIPortlet portlet : portlets) { portlet.setPortletInPortal(false); } }