public Page getPageFrom(PageKey pageKey) {
   POMSession session = pomManager.getSession();
   final SiteKey siteKey = pageKey.getSite();
   final SiteType siteType = siteKey.getType();
   final String siteName = siteKey.getName();
   Site site = session.getWorkspace().getSite(Mapper.parseSiteType(siteType.getName()), siteName);
   return getPagesFrom(site).getChild(pageKey.getName());
 }
    public void execute(Event<UISpaceNavigationManagement> event) throws Exception {
      PortalRequestContext prContext = Util.getPortalRequestContext();
      UISpaceNavigationManagement uiManagement = event.getSource();
      UISpaceNavigationNodeSelector uiNodeSelector =
          uiManagement.getChild(UISpaceNavigationNodeSelector.class);
      UserPortalConfigService portalConfigService =
          uiManagement.getApplicationComponent(UserPortalConfigService.class);

      UIPortalApplication uiPortalApp = (UIPortalApplication) prContext.getUIApplication();
      UIWorkingWorkspace uiWorkingWS =
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
      prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
      prContext.ignoreAJAXUpdateOnPortlets(true);

      UserNavigation navigation = uiNodeSelector.getEdittedNavigation();
      SiteKey siteKey = navigation.getKey();
      String editedOwnerId = siteKey.getName();

      // Check existed
      UserPortalConfig userPortalConfig;
      if (SiteType.PORTAL.equals(siteKey.getType())) {
        userPortalConfig =
            portalConfigService.getUserPortalConfig(
                editedOwnerId, event.getRequestContext().getRemoteUser());
        if (userPortalConfig == null) {
          prContext
              .getUIApplication()
              .addMessage(
                  new ApplicationMessage(
                      "UIPortalForm.msg.notExistAnymore", null, ApplicationMessage.ERROR));
          return;
        }
      } else {
        userPortalConfig =
            portalConfigService.getUserPortalConfig(
                prContext.getPortalOwner(), event.getRequestContext().getRemoteUser());
      }

      UserNavigation persistNavigation = userPortalConfig.getUserPortal().getNavigation(siteKey);
      if (persistNavigation == null) {
        prContext
            .getUIApplication()
            .addMessage(
                new ApplicationMessage(
                    "UINavigationManagement.msg.NavigationNotExistAnymore",
                    null,
                    ApplicationMessage.ERROR));
        return;
      }

      uiNodeSelector.save();
    }
    public void execute(Event<UIAdminToolbarContainer> event) throws Exception {
      UIAdminToolbarContainer uicomp = event.getSource();
      UserNavigation edittedNavigation = Utils.getSelectedNavigation();

      WebuiRequestContext context = event.getRequestContext();
      UIApplication uiApplication = context.getUIApplication();

      if (edittedNavigation == null) {
        uiApplication.addMessage(
            new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));
        return;
      }

      UserACL userACL = uicomp.getApplicationComponent(UserACL.class);
      if (edittedNavigation.getKey().getType().equals(SiteType.PORTAL)) {
        String portalName = Util.getPortalRequestContext().getPortalOwner();
        UserPortalConfigService configService =
            uicomp.getApplicationComponent(UserPortalConfigService.class);
        UserPortalConfig userPortalConfig =
            configService.getUserPortalConfig(
                portalName, context.getRemoteUser(), PortalRequestContext.USER_PORTAL_CONTEXT);
        if (userPortalConfig == null) {
          uiApplication.addMessage(
              new ApplicationMessage(
                  "UISiteManagement.msg.portal-not-exist", new String[] {portalName}));
          return;
        }
        if (!userACL.hasEditPermission(userPortalConfig.getPortalConfig())) {
          uiApplication.addMessage(
              new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));
          return;
        }
      } else if (edittedNavigation.getKey().getType().equals(PortalConfig.GROUP_TYPE)) {
        if (!userACL.hasEditPermissionOnNavigation(
            SiteKey.group(edittedNavigation.getKey().getTypeName()))) {
          uiApplication.addMessage(
              new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));
          return;
        }
      }

      if (uicomp.naviManager == null) {
        uicomp.naviManager = uicomp.createUIComponent(UINavigationManagement.class, null, null);
      }
      Utils.createPopupWindow(
          uicomp, uicomp.naviManager, EDIT_NAVIGATION_POPUP_CONTAINER_ID, 400, -1, -1);

      uicomp.naviManager.setSiteKey(edittedNavigation.getKey());
      UserPortal userPortal = getUserPortal();
      UINavigationNodeSelector selector =
          uicomp.naviManager.getChild(UINavigationNodeSelector.class);
      selector.setEdittedNavigation(edittedNavigation);
      selector.setUserPortal(userPortal);
      selector.initTreeData();

      context.addUIComponentToUpdateByAjax(uicomp);
    }
 public String getPageManagementLink() {
   if (pageManagementLink == null) {
     UserACL userACL = getApplicationComponent(UserACL.class);
     String[] adminGroups = userACL.getAdminGroups().split(";");
     pageManagementLink =
         NavigationURLUtils.getURL(SiteKey.group(adminGroups[0]), PAGE_MANAGEMENT_URI);
   }
   return pageManagementLink;
 }
  @Override
  protected void execute(OperationContext operationContext, ResultHandler resultHandler, Site site)
      throws ResourceNotFoundException, OperationException {
    DataStorage dataStorage =
        operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
    SiteKey siteKey = getSiteKey(site);

    try {
      PortalConfig portalConfig =
          dataStorage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
      resultHandler.completed(portalConfig);
    } catch (Exception e) {
      throw new OperationException(
          operationContext.getOperationName(),
          "Could not retrieve site layout for site " + site,
          e);
    }
  }
예제 #6
0
  // copied from @link{#hasEditPermission}
  public boolean hasEditPermissionOnNavigation(SiteKey siteKey) {
    Identity identity = getIdentity();
    if (superUser_.equals(identity.getUserId())) {
      return true;
    }

    //
    switch (siteKey.getType()) {
      case PORTAL:
        // TODO: We should also take care of Portal's navigation
        return false;
      case GROUP:
        String temp = siteKey.getName().trim();
        String expAdminGroup = getAdminGroups();
        String expPerm = null;

        // Check to see whether current user is member of admin group or not,
        // if so grant
        // edit permission for group navigation for that user.
        if (expAdminGroup != null) {
          expAdminGroup = expAdminGroup.startsWith("/") ? expAdminGroup : "/" + expAdminGroup;
          expPerm = temp.startsWith("/") ? temp : "/" + temp;
          if (isUserInGroup(expPerm) && isUserInGroup(expAdminGroup)) {
            return true;
          }
        }

        expPerm =
            navigationCreatorMembershipType_ + (temp.startsWith("/") ? ":" + temp : ":/" + temp);
        return hasPermission(identity, expPerm);
      case USER:
        return siteKey.getName().equals(identity.getUserId());
      default:
        return false;
    }
  }
 public String getSiteName() {
   return siteKey.getName();
 }
 public SiteType getSiteType() {
   return siteKey.getType();
 }