Beispiel #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);
  }
  public String getTitle() throws Exception {
    String title = (String) request_.getAttribute(REQUEST_TITLE);

    //
    if (title == null) {
      UIPortal uiportal = Util.getUIPortal();

      //
      UserNode node = uiportal.getSelectedUserNode();
      if (node != null) {
        ExoContainer container = getApplication().getApplicationServiceContainer();
        container.getComponentInstanceOfType(UserPortalConfigService.class);
        UserPortalConfigService configService =
            (UserPortalConfigService)
                container.getComponentInstanceOfType(UserPortalConfigService.class);
        Page page = configService.getPage(node.getPageRef(), getRemoteUser());

        //
        if (page != null) {
          title = page.getTitle();
          return ExpressionUtil.getExpressionValue(this.getApplicationResourceBundle(), title);
        } else {
          title = node.getResolvedLabel();
        }
      }
    }

    //
    return title;
  }
Beispiel #3
0
    public void execute(Event<UISpaceInfo> event) throws Exception {
      UISpaceInfo uiSpaceInfo = event.getSource();
      SpaceService spaceService = uiSpaceInfo.getSpaceService();
      UIPortal uiPortal = Util.getUIPortal();

      String id = uiSpaceInfo.getUIStringInput(SPACE_ID).getValue();
      String name = uiSpaceInfo.getUIStringInput(SPACE_DISPLAY_NAME).getValue();
      Space space = spaceService.getSpaceById(id);
      String oldDisplayName = space.getDisplayName();
      String existingDescription = space.getDescription();

      if (space == null) {
        // redirect to spaces
        event.getRequestContext().sendRedirect(Utils.getURI("all-spaces"));
        return;
      }

      UserNode selectedNode = uiPortal.getSelectedUserNode();
      UserNode renamedNode = null;

      boolean nameChanged = (!space.getDisplayName().equals(name));
      UIPortletApplication uiApp = uiSpaceInfo.getAncestorOfType(UIPortletApplication.class);
      if (nameChanged) {

        String cleanedString = SpaceUtils.cleanString(name);
        if (spaceService.getSpaceByUrl(cleanedString) != null) {
          // reset to origin values
          uiSpaceInfo.getUIStringInput(SPACE_DISPLAY_NAME).setValue(oldDisplayName);
          uiSpaceInfo.getUIFormTextAreaInput(SPACE_DESCRIPTION).setValue(existingDescription);

          //
          uiApp.addMessage(
              new ApplicationMessage(
                  "UISpaceInfo.msg.current-name-exist", null, ApplicationMessage.INFO));
          return;
        }

        renamedNode = uiSpaceInfo.renamePageNode(name, space);
        if (renamedNode == null) {
          return;
        }
      }
      uiSpaceInfo.invokeSetBindingBean(space);

      String spaceDescription = space.getDescription();
      if (spaceDescription == null || spaceDescription.trim().length() == 0) {
        ResourceBundle resourceBundle = event.getRequestContext().getApplicationResourceBundle();
        space.setDescription(resourceBundle.getString(MSG_DEFAULT_SPACE_DESCRIPTION));
        uiSpaceInfo.getUIFormTextAreaInput(SPACE_DESCRIPTION).setValue(space.getDescription());
      } else {
        space.setDescription(StringEscapeUtils.escapeHtml(space.getDescription()));
        if (!existingDescription.equals(spaceDescription)) {
          space.setField(UpdatedField.DESCRIPTION);
        }
      }

      space.setEditor(Utils.getViewerRemoteId());

      if (nameChanged) {
        space.setDisplayName(oldDisplayName);
        String remoteId = Utils.getViewerRemoteId();
        spaceService.renameSpace(remoteId, space, name);

        // rename group label
        OrganizationService organizationService =
            (OrganizationService)
                ExoContainerContext.getCurrentContainer()
                    .getComponentInstanceOfType(OrganizationService.class);
        GroupHandler groupHandler = organizationService.getGroupHandler();
        Group group = groupHandler.findGroupById(space.getGroupId());
        group.setLabel(space.getDisplayName());
        groupHandler.saveGroup(group, true);
      } else {
        spaceService.updateSpace(space);
      }

      if (nameChanged) {
        if (renamedNode != null) {
          // update space navigation (change name).
          selectedNode = renamedNode;
          PortalRequestContext prContext = Util.getPortalRequestContext();
          prContext.createURL(NodeURL.TYPE).setNode(selectedNode);
          event.getRequestContext().sendRedirect(Utils.getSpaceURL(selectedNode));
          return;
        }
      } else {
        uiApp.addMessage(
            new ApplicationMessage(
                "UISpaceInfo.msg.update-success", null, ApplicationMessage.INFO));
      }
    }