Пример #1
0
  public static boolean hasEditPermissionOnPage() throws Exception {
    UIPortalApplication portalApp = Util.getUIPortalApplication();
    UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
    UIPageBody pageBody = uiWorkingWS.findFirstComponentOfType(UIPageBody.class);
    UIPage uiPage = (UIPage) pageBody.getUIComponent();
    UserACL userACL = portalApp.getApplicationComponent(UserACL.class);

    if (uiPage != null) {
      return userACL.hasEditPermissionOnPage(
          uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
    }
    UIPortal currentUIPortal =
        portalApp
            .<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID)
            .findFirstComponentOfType(UIPortal.class);
    UserNode currentNode = currentUIPortal.getSelectedUserNode();
    String pageReference = currentNode.getPageRef();
    if (pageReference == null) {
      return false;
    }
    DataStorage dataStorage = portalApp.getApplicationComponent(DataStorage.class);
    Page page = dataStorage.getPage(pageReference);
    if (page == null) {
      return false;
    }
    return userACL.hasEditPermission(page);
  }
Пример #2
0
 public static Page toPageModel(UIPage uiPage) {
   Page model = new Page(uiPage.getStorageId());
   toContainer(model, uiPage);
   model.setOwnerId(uiPage.getSiteKey().getName());
   model.setOwnerType(uiPage.getSiteKey().getTypeName());
   model.setIcon(uiPage.getIcon());
   model.setPageId(uiPage.getPageId());
   model.setTitle(uiPage.getTitle());
   model.setAccessPermissions(uiPage.getAccessPermissions());
   model.setEditPermission(uiPage.getEditPermission());
   model.setFactoryId(uiPage.getFactoryId());
   model.setShowMaxWindow(uiPage.isShowMaxWindow());
   model.setModifiable(uiPage.isModifiable());
   return model;
 }