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;
  }
Exemple #2
0
 /**
  * Gets UserACL
  *
  * @return userACL
  */
 private UserACL getUserACL() {
   if (userACL == null) {
     ExoContainer container = ExoContainerContext.getCurrentContainer();
     return (UserACL) container.getComponentInstanceOfType(UserACL.class);
   }
   return userACL;
 }
  /** @return Returns a list of pages or returns null if has not any page. */
  public List<PageModel> next() {
    ExoContainer container = PortalContainer.getInstance();
    PageService pageService = (PageService) container.getComponentInstance(PageService.class);
    QueryResult<PageContext> result =
        pageService.findPages(
            currentIndex,
            pageSize + 1,
            SiteType.valueOf(ownerType.toUpperCase()),
            ownerId,
            name,
            title);

    int size = result.getSize();
    hasNext = size > pageSize;

    //
    if (size > 0) {
      int hsize = hasNext ? pageSize : size;
      List<PageModel> holder = new ArrayList<PageModel>(hsize);

      Iterator<PageContext> iterator = result.iterator();
      while (holder.size() < hsize) {
        holder.add(new PageModel(iterator.next()));
      }

      currentIndex += holder.size();
      return holder;
    } else {
      return null;
    }
  }
Exemple #4
0
 /**
  * Gets OrganizationService
  *
  * @return organizationService
  */
 private OrganizationService getOrgService() {
   if (orgService == null) {
     ExoContainer container = ExoContainerContext.getCurrentContainer();
     orgService =
         (OrganizationService) container.getComponentInstanceOfType(OrganizationService.class);
   }
   return orgService;
 }
Exemple #5
0
 public static String getRestContextName() {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   PortalContainerInfo containerInfo =
       (PortalContainerInfo) container.getComponentInstanceOfType(PortalContainerInfo.class);
   return portalContainerConfig.getRestContextName(containerInfo.getContainerName());
 }
 private Session getSession(SessionProvider sprovider) throws Exception {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   RepositoryService repositoryService =
       (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class);
   ManageableRepository currentRepo = repositoryService.getCurrentRepository();
   return sprovider.getSession(
       currentRepo.getConfiguration().getDefaultWorkspaceName(), currentRepo);
 }
Exemple #7
0
 /**
  * Gets the service.
  *
  * @param clazz the class
  * @param containerName the container's name
  * @return the service
  */
 public static <T> T getService(Class<T> clazz, String containerName) {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   if (containerName != null) {
     container = RootContainer.getInstance().getPortalContainer(containerName);
   }
   if (container.getComponentInstanceOfType(clazz) == null) {
     containerName = PortalContainer.getCurrentPortalContainerName();
     container = RootContainer.getInstance().getPortalContainer(containerName);
   }
   return clazz.cast(container.getComponentInstanceOfType(clazz));
 }
 public void removeQuestion(String questionActivityId) {
   try {
     ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
     ActivityManager activityM =
         (ActivityManager) exoContainer.getComponentInstanceOfType(ActivityManager.class);
     ExoSocialActivity activity = activityM.getActivity(questionActivityId);
     activityM.deleteActivity(activity);
   } catch (Exception e) {
     LOG.debug("Fail to remove activity when remove question " + e.getMessage());
   }
 }
 public ResourceBundle getBundle(UserNavigation navigation) {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   ResourceBundleManager rbMgr =
       (ResourceBundleManager)
           container.getComponentInstanceOfType(ResourceBundleManager.class);
   Locale locale = Util.getPortalRequestContext().getLocale();
   return rbMgr.getNavigationResourceBundle(
       locale.getLanguage(),
       navigation.getKey().getTypeName(),
       navigation.getKey().getName());
 }
 public void postSave(User user, boolean isNew) throws Exception {
   ExoContainer pcontainer = ExoContainerContext.getCurrentContainer();
   OrganizationService service =
       (OrganizationService) pcontainer.getComponentInstanceOfType(OrganizationService.class);
   UserProfile up = service.getUserProfileHandler().createUserProfileInstance();
   up.setUserName(user.getUserName());
   service.getUserProfileHandler().saveUserProfile(up, false);
   if (config_ == null) return;
   if (isNew && !config_.isIgnoreUser(user.getUserName())) {
     createDefaultUserMemberships(user, service);
   }
 }
 public void removeComment(
     String questionActivityId, String commentActivityId, String questionPath) {
   try {
     ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
     ActivityManager activityM =
         (ActivityManager) exoContainer.getComponentInstanceOfType(ActivityManager.class);
     activityM.deleteComment(questionActivityId, commentActivityId);
     refreshActivity(questionPath, questionActivityId);
   } catch (Exception e) {
     LOG.debug("Fail to remove comment when remove question's comment " + e.getMessage());
   }
 }
Exemple #12
0
  /** {@inheritDoc} */
  @Override
  public synchronized void stop() {
    RepositoryImpl repository = (RepositoryImpl) getComponentInstanceOfType(RepositoryImpl.class);

    try {
      repository.setState(ManageableRepository.OFFLINE);
    } catch (RepositoryException e) {
      log.error("Can not switch repository to OFFLINE", e);
    }

    super.stop();
    super.unregisterAllComponents();
  }
Exemple #13
0
  /**
   * Gets space application handlers
   *
   * @return
   */
  @SuppressWarnings("unchecked")
  private Map<String, SpaceApplicationHandler> getSpaceApplicationHandlers() {
    if (this.spaceApplicationHandlers == null) {
      this.spaceApplicationHandlers = new HashMap();

      ExoContainer container = ExoContainerContext.getCurrentContainer();
      SpaceApplicationHandler appHandler =
          (DefaultSpaceApplicationHandler)
              container.getComponentInstanceOfType(DefaultSpaceApplicationHandler.class);
      this.spaceApplicationHandlers.put(appHandler.getName(), appHandler);
    }
    return this.spaceApplicationHandlers;
  }
  public void unVoteQuestion(String questionId) {
    try {
      ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
      FAQService faqS = (FAQService) exoContainer.getComponentInstanceOfType(FAQService.class);
      Question question = faqS.getQuestionById(questionId);

      // No event is created because old and new values are equal but we must update the activity's
      // content
      question.setEditedQuestionRating(question.getMarkVote());
      saveQuestion(question, false);
    } catch (Exception e) {
      LOG.debug("Fail to unvote question " + e.getMessage());
    }
  }
  public boolean hasNext() {
    if (hasNext && currentIndex == 0) {
      ExoContainer container = PortalContainer.getInstance();
      PageService pageService = (PageService) container.getComponentInstance(PageService.class);
      QueryResult<PageContext> result =
          pageService.findPages(
              0, 1, SiteType.valueOf(ownerType.toUpperCase()), ownerId, name, title);

      hasNext = result.getSize() > 0;
    }

    //
    return hasNext;
  }
Exemple #16
0
 /**
  * refine node for validation
  *
  * @param currentNode
  * @throws Exception
  */
 private static void refineNode(Node currentNode) throws Exception {
   if (currentNode instanceof NodeImpl && !((NodeImpl) currentNode).isValid()) {
     ExoContainer container = ExoContainerContext.getCurrentContainer();
     LinkManager linkManager =
         (LinkManager) container.getComponentInstanceOfType(LinkManager.class);
     if (linkManager.isLink(currentNode)) {
       try {
         currentNode = linkManager.getTarget(currentNode, false);
       } catch (RepositoryException ex) {
         currentNode = linkManager.getTarget(currentNode, true);
       }
     }
   }
 }
 private void refreshActivity(String questionId, String questionActivityId) {
   try {
     ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
     FAQService faqS = (FAQService) exoContainer.getComponentInstanceOfType(FAQService.class);
     Question question = faqS.getQuestionById(questionId);
     ActivityManager activityM =
         (ActivityManager) exoContainer.getComponentInstanceOfType(ActivityManager.class);
     ExoSocialActivity activity = activityM.getActivity(questionActivityId);
     updateActivity(activity, question);
     activityM.updateActivity(activity);
   } catch (Exception e) {
     LOG.debug("Fail to refresh activity " + e.getMessage());
   }
 }
  @Override
  public void execute(JobExecutionContext jec) throws JobExecutionException {

    if (log.isInfoEnabled()) {
      log.info("Job Scheduler ready to send emails");
    }
    ExoContainer containerContext = ExoContainerContext.getCurrentContainer();
    SocialNotificationService socialNotificationService =
        (SocialNotificationService)
            containerContext.getComponentInstanceOfType(SocialNotificationService.class);
    socialNotificationService.spaceNotification();
    if (log.isInfoEnabled()) {
      log.info("Job Scheduler done sending emails");
    }
  }
Exemple #19
0
  private void initAllWorkspaceComponentEntries(ExoContainer parent) {
    SystemParametersPersistenceConfigurator sppc =
        (SystemParametersPersistenceConfigurator)
            parent.getComponentInstanceOfType(SystemParametersPersistenceConfigurator.class);

    for (WorkspaceEntry workspaceEntry : config.getWorkspaceEntries()) {
      initWorkspaceComponentEntries(sppc, workspaceEntry);
    }
  }
 public void removeAnswer(String questionPath, String answerActivityId) {
   try {
     ExoContainer exoContainer = ExoContainerContext.getCurrentContainer();
     FAQService faqS = (FAQService) exoContainer.getComponentInstanceOfType(FAQService.class);
     String questionActivityId = faqS.getActivityIdForQuestion(questionPath);
     ActivityManager activityM =
         (ActivityManager) exoContainer.getComponentInstanceOfType(ActivityManager.class);
     for (String id : answerActivityId.split(",")) {
       ExoSocialActivity activity = activityM.getActivity(id);
       if (activity != null) {
         activityM.deleteComment(questionActivityId, id);
       }
     }
     refreshActivity(questionPath, questionActivityId);
   } catch (Exception e) {
     LOG.debug("Fail to remove comment when remove question's answer " + e.getMessage());
   }
 }
 /**
  * This method simply delegates the incoming call to the WebAppController stored in the Portal
  * Container object
  */
 @Override
 protected void onService(ExoContainer container, HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   try {
     WebAppController controller =
         (WebAppController) container.getComponentInstanceOfType(WebAppController.class);
     controller.service(req, res);
   } catch (Throwable t) {
     throw new ServletException(t);
   }
 }
Exemple #22
0
  public static void deleteFileActivity(Node node) throws RepositoryException {
    // get services
    ExoContainer container = ExoContainerContext.getCurrentContainer();
    ActivityManager activityManager =
        (ActivityManager) container.getComponentInstanceOfType(ActivityManager.class);
    IdentityManager identityManager =
        (IdentityManager) container.getComponentInstanceOfType(IdentityManager.class);

    // get owner
    String activityOwnerId = getActivityOwnerId(node);
    String nodeActivityID = StringUtils.EMPTY;
    ExoSocialActivity exa = null;
    if (node.isNodeType(ActivityTypeUtils.EXO_ACTIVITY_INFO)) {
      try {
        nodeActivityID = node.getProperty(ActivityTypeUtils.EXO_ACTIVITY_ID).getString();
        activityManager.deleteActivity(nodeActivityID);
      } catch (Exception e) {
        LOG.info("No activity is deleted, return no related activity");
      }
    }
  }
  public UserPortalConfig getUserPortalConfig() {
    if (userPortalConfig == null) {
      String portalName = null;
      String remoteUser = getRemoteUser();
      SiteType siteType = getSiteType();

      ExoContainer appContainer = getApplication().getApplicationServiceContainer();
      UserPortalConfigService service_ =
          (UserPortalConfigService)
              appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
      if (SiteType.PORTAL == siteType) {
        portalName = getSiteName();
      }

      HttpSession session = request_.getSession();
      if (portalName == null) {
        if (session != null) {
          portalName = (String) session.getAttribute(LAST_PORTAL_NAME);
        }
      }

      if (portalName == null) {
        portalName = service_.getDefaultPortal();
      }
      try {
        userPortalConfig =
            service_.getUserPortalConfig(
                portalName, remoteUser, PortalRequestContext.USER_PORTAL_CONTEXT);
        if (userPortalConfig != null) {
          session.setAttribute(LAST_PORTAL_NAME, portalName);
        }
      } catch (Exception e) {
        return null;
      }
    }

    return userPortalConfig;
  }
Exemple #24
0
  public void setUp() throws Exception {
    super.setUp();
    ExoContainer myContainer = ExoContainerContext.getCurrentContainer();
    favoriteService =
        (FavoriteService) myContainer.getComponentInstanceOfType(FavoriteService.class);

    SessionProviderService sessionProviderService =
        (SessionProviderService)
            myContainer.getComponentInstanceOfType(SessionProviderService.class);

    SessionProvider sessionProvider = sessionProviderService.getSystemSessionProvider(null);

    ManageableRepository manageableRepository = repositoryService.getRepository("repository");

    Session session = sessionProvider.getSession(COLLABORATION_WS, manageableRepository);
    Node rootNode = session.getRootNode();
    String[] names = new String[] {"root", "demo", "james", "john", "marry"};
    for (String name : names)
      if (rootNode.hasNode(name)) {
        rootNode.getNode(name).remove();
        rootNode.save();
      }
  }
  private static void initContainer() {
    try {
      ExoContainer container_ = RootContainer.getInstance();
      if (container_ != null) {
        container_.stop();
        container_.dispose();
      }
      String containerConf =
          ForumServiceTestCase.class.getResource("/conf/portal/configuration.xml").toString();
      StandaloneContainer.addConfigurationURL(containerConf);
      container = StandaloneContainer.getInstance();
      String loginConf =
          Thread.currentThread()
              .getContextClassLoader()
              .getResource("conf/portal/login.conf")
              .toString();

      if (System.getProperty("java.security.auth.login.config") == null)
        System.setProperty("java.security.auth.login.config", loginConf);
      ExoContainerContext.setCurrentContainer(container);
    } catch (Exception e) {
      log.error("Failed to initialize standalone container: ", e);
    }
  }
Exemple #26
0
 /**
  * @param : node: nt:file node with have the data stream
  * @return : Link to download the jcr:data of the given node
  * @throws Exception
  */
 public static String getDownloadRestServiceLink(Node node) throws Exception {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerInfo containerInfo =
       (PortalContainerInfo) container.getComponentInstanceOfType(PortalContainerInfo.class);
   String portalName = containerInfo.getContainerName();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   String restContextName = portalContainerConfig.getRestContextName(portalName);
   StringBuilder sb = new StringBuilder();
   Node currentNode = org.exoplatform.wcm.webui.Utils.getRealNode(node);
   String ndPath = currentNode.getPath();
   if (ndPath.startsWith("/")) {
     ndPath = ndPath.substring(1);
   }
   String encodedPath = URLEncoder.encode(ndPath, "utf-8");
   encodedPath =
       encodedPath.replaceAll("%2F", "/"); // we won't encode the slash characters in the path
   sb.append("/").append(restContextName).append("/contents/download/");
   sb.append(currentNode.getSession().getWorkspace().getName()).append("/").append(encodedPath);
   if (node.isNodeType("nt:frozenNode")) {
     sb.append("?version=" + node.getParent().getName());
   }
   return sb.toString();
 }
Exemple #27
0
  /** {@inheritDoc} */
  @Override
  public void start() {

    try {
      init();
      load();
    } catch (RepositoryException e) {
      log.error("Repository error", e);
      throw new RuntimeException(e);
    } catch (RepositoryConfigurationException e) {
      log.error("Configuration error", e);
      throw new RuntimeException(e);
    }

    super.start();
  }
Exemple #28
0
  /**
   * @param node : activity raised from this source
   * @param activityMsgBundleKey
   * @param isSystemComment
   * @param systemComment the new value of System Posted activity, if (isSystemComment)
   *     systemComment can not be set to null, set to empty string instead of.
   * @throws Exception
   */
  public static ExoSocialActivity postFileActivity(
      Node node,
      String activityMsgBundleKey,
      boolean needUpdate,
      boolean isSystemComment,
      String systemComment)
      throws Exception {
    Object isSkipRaiseAct =
        DocumentContext.getCurrent().getAttributes().get(DocumentContext.IS_SKIP_RAISE_ACT);
    if (isSkipRaiseAct != null && Boolean.valueOf(isSkipRaiseAct.toString())) {
      return null;
    }
    if (!isSupportedContent(node)) {
      return null;
    }

    // get services
    ExoContainer container = ExoContainerContext.getCurrentContainer();
    ActivityManager activityManager =
        (ActivityManager) container.getComponentInstanceOfType(ActivityManager.class);
    IdentityManager identityManager =
        (IdentityManager) container.getComponentInstanceOfType(IdentityManager.class);
    ActivityCommonService activityCommonService =
        (ActivityCommonService) container.getComponentInstanceOfType(ActivityCommonService.class);

    SpaceService spaceService = WCMCoreUtils.getService(SpaceService.class);

    // refine to get the valid node
    refineNode(node);

    // get owner
    String activityOwnerId = getActivityOwnerId(node);
    String nodeActivityID = StringUtils.EMPTY;
    ExoSocialActivity exa = null;
    if (node.isNodeType(ActivityTypeUtils.EXO_ACTIVITY_INFO)) {
      try {
        nodeActivityID = node.getProperty(ActivityTypeUtils.EXO_ACTIVITY_ID).getString();
        exa = activityManager.getActivity(nodeActivityID);
      } catch (Exception e) {
        LOG.info("No activity is deleted, return no related activity");
      }
    }
    ExoSocialActivity activity = null;
    String commentID;
    boolean commentFlag = false;
    if (node.isNodeType(MIX_COMMENT) && activityCommonService.isEditing(node)) {
      if (node.hasProperty(MIX_COMMENT_ID)) {
        commentID = node.getProperty(MIX_COMMENT_ID).getString();
        if (StringUtils.isNotBlank(commentID)) activity = activityManager.getActivity(commentID);
        commentFlag = (activity != null);
      }
    }
    if (activity == null) {
      activity =
          createActivity(
              identityManager,
              activityOwnerId,
              node,
              activityMsgBundleKey,
              FILE_SPACES,
              isSystemComment,
              systemComment);
    }

    if (exa != null) {
      if (commentFlag) {
        Map<String, String> paramsMap = activity.getTemplateParams();
        String paramMessage = paramsMap.get(ContentUIActivity.MESSAGE);
        String paramContent = paramsMap.get(ContentUIActivity.SYSTEM_COMMENT);
        if (!StringUtils.isEmpty(paramMessage)) {
          paramMessage += ActivityCommonService.VALUE_SEPERATOR + activityMsgBundleKey;
          if (StringUtils.isEmpty(systemComment)) {
            paramContent += ActivityCommonService.VALUE_SEPERATOR + " ";
          } else {
            paramContent += ActivityCommonService.VALUE_SEPERATOR + systemComment;
          }
        } else {
          paramMessage = activityMsgBundleKey;
          paramContent = systemComment;
        }
        paramsMap.put(ContentUIActivity.MESSAGE, paramMessage);
        paramsMap.put(ContentUIActivity.SYSTEM_COMMENT, paramContent);
        activity.setTemplateParams(paramsMap);
        activityManager.updateActivity(activity);
      } else {
        activityManager.saveComment(exa, activity);
        if (activityCommonService.isEditing(node)) {
          commentID = activity.getId();
          if (node.canAddMixin(MIX_COMMENT)) node.addMixin(MIX_COMMENT);
          if (node.isNodeType(MIX_COMMENT)) node.setProperty(MIX_COMMENT_ID, commentID);
        }
      }
      return activity;
    } else {
      String spaceName = getSpaceName(node);
      if (spaceName != null
          && spaceName.length() > 0
          && spaceService.getSpaceByPrettyName(spaceName) != null) {
        // post activity to space stream
        Identity spaceIdentity =
            identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, spaceName, true);
        activityManager.saveActivityNoReturn(spaceIdentity, activity);
      } else if (activityOwnerId != null && activityOwnerId.length() > 0) {
        // post activity to user status stream
        Identity ownerIdentity =
            identityManager.getOrCreateIdentity(
                OrganizationIdentityProvider.NAME, activityOwnerId, true);
        activityManager.saveActivityNoReturn(ownerIdentity, activity);
      } else {
        return null;
      }
      String activityId = activity.getId();
      if (!StringUtils.isEmpty(activityId)) {
        ActivityTypeUtils.attachActivityId(node, activityId);
      }

      if (node.isNodeType(ActivityTypeUtils.EXO_ACTIVITY_INFO)) {
        try {
          nodeActivityID = node.getProperty(ActivityTypeUtils.EXO_ACTIVITY_ID).getString();
          exa = activityManager.getActivity(nodeActivityID);
        } catch (Exception e) {
          LOG.info("No activity is deleted, return no related activity");
        }
        if (exa != null && !commentFlag && isSystemComment) {
          activityManager.saveComment(exa, activity);
          if (activityCommonService.isEditing(node)) {
            commentID = activity.getId();
            if (node.canAddMixin(MIX_COMMENT)) node.addMixin(MIX_COMMENT);
            if (node.isNodeType(MIX_COMMENT)) node.setProperty(MIX_COMMENT_ID, commentID);
          }
        }
      }

      return activity;
    }
  }
  @SuppressWarnings("unchecked")
  public UIPageForm(InitParams initParams) throws Exception {
    super("UIPageForm");
    PortalRequestContext pcontext = Util.getPortalRequestContext();
    UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
    List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
    ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));

    UserPortalConfig userPortalConfig =
        configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
    ExoContainer container = ExoContainerContext.getCurrentContainer();
    UserACL acl = (UserACL) container.getComponentInstanceOfType(UserACL.class);
    if (acl.hasEditPermission(userPortalConfig.getPortalConfig())) {
      ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
    }
    ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
    ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());

    UIFormSelectBox uiSelectBoxOwnerType = new UIFormSelectBox(OWNER_TYPE, OWNER_TYPE, ownerTypes);
    uiSelectBoxOwnerType.setOnChange("ChangeOwnerType");

    UIFormInputSet uiSettingSet = new UIFormInputSet("PageSetting");
    uiSettingSet
        .addUIFormInput(new UIFormStringInput("pageId", "pageId", null).setEditable(false))
        .addUIFormInput(uiSelectBoxOwnerType)
        .addUIFormInput(ownerIdInput)
        .addUIFormInput(
            new UIFormStringInput("name", "name", null)
                .addValidator(StringLengthValidator.class, 3, 30)
                .addValidator(IdentifierValidator.class)
                .addValidator(MandatoryValidator.class))
        .addUIFormInput(
            new UIFormStringInput("title", "title", null)
                .addValidator(StringLengthValidator.class, 3, 120))
        .addUIFormInput(new UIFormCheckBoxInput("showMaxWindow", "showMaxWindow", false));
    addUIFormInput(uiSettingSet);
    setSelectedTab(uiSettingSet.getId());

    // WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
    // Param param = initParams.getParam("PageTemplate");
    // List<SelectItemCategory> itemCategories =
    // (List<SelectItemCategory>)param.getMapGroovyObject(context);
    // UIFormInputItemSelector uiTemplate = new UIFormInputItemSelector("Template", "template");
    // uiTemplate.setItemCategories(itemCategories);
    // addUIFormInput(uiTemplate);

    uiPermissionSetting = createUIComponent(UIFormInputSet.class, "PermissionSetting", null);
    UIListPermissionSelector uiListPermissionSelector =
        createUIComponent(UIListPermissionSelector.class, null, null);
    uiListPermissionSelector.configure("UIListPermissionSelector", "accessPermissions");
    uiListPermissionSelector.addValidator(EmptyIteratorValidator.class);
    uiPermissionSetting.addChild(uiListPermissionSelector);
    uiPermissionSetting.setSelectedComponent(uiListPermissionSelector.getId());
    UIPermissionSelector uiEditPermission =
        createUIComponent(UIPermissionSelector.class, null, null);
    uiEditPermission.setRendered(false);
    uiEditPermission.addValidator(
        org.exoplatform.webui.organization.UIPermissionSelector.MandatoryValidator.class);
    uiEditPermission.setEditable(false);
    uiEditPermission.configure("UIPermissionSelector", "editPermission");
    uiPermissionSetting.addChild(uiEditPermission);

    // TODO: This following line is fixed for bug PORTAL-2127
    uiListPermissionSelector
        .getChild(UIFormPopupWindow.class)
        .setId("UIPageFormPopupGroupMembershipSelector");

    List<String> groups = configService.getMakableNavigations(pcontext.getRemoteUser(), true);
    if (groups.size() > 0) {
      Collections.sort(groups);
      ownerTypes.add(new SelectItemOption<String>(PortalConfig.GROUP_TYPE));
      List<SelectItemOption<String>> groupsItem = new ArrayList<SelectItemOption<String>>();
      for (String group : groups) {
        groupsItem.add(new SelectItemOption<String>(group));
      }
      groupIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, groupsItem);
      groupIdSelectBox.setOnChange("ChangeOwnerId");
      groupIdSelectBox.setParent(uiSettingSet);
    }
    setActions(new String[] {"Save", "Close"});
  }
Exemple #30
0
 public static String getRestContextName(String portalContainerName) {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   return portalContainerConfig.getRestContextName(portalContainerName);
 }