コード例 #1
0
 public void updateFolderAllowed(String path) {
   UIFormSelectBox sltWorkspace = getChildById(UIDriveInputSet.FIELD_WORKSPACE);
   String strWorkspace = sltWorkspace.getSelectedValues()[0];
   SessionProvider sessionProvider = WCMCoreUtils.getSystemSessionProvider();
   try {
     Session session =
         sessionProvider.getSession(
             strWorkspace,
             getApplicationComponent(RepositoryService.class).getCurrentRepository());
     Node rootNode = (Node) session.getItem(path);
     List<SelectItemOption<String>> foldertypeOptions = new ArrayList<SelectItemOption<String>>();
     RequestContext context = RequestContext.getCurrentInstance();
     ResourceBundle res = context.getApplicationResourceBundle();
     for (String foldertype : setFoldertypes) {
       if (isChildNodePrimaryTypeAllowed(rootNode, foldertype)) {
         try {
           foldertypeOptions.add(
               new SelectItemOption<String>(
                   res.getString(getId() + ".label." + foldertype.replace(":", "_")), foldertype));
         } catch (MissingResourceException mre) {
           foldertypeOptions.add(new SelectItemOption<String>(foldertype, foldertype));
         }
       }
     }
     Collections.sort(foldertypeOptions, new ItemOptionNameComparator());
     getUIFormSelectBox(FIELD_ALLOW_CREATE_FOLDERS).setOptions(foldertypeOptions);
   } catch (Exception e) {
     if (LOG.isErrorEnabled()) {
       LOG.error("Unexpected problem occurs while updating", e);
     }
   }
 }
コード例 #2
0
ファイル: LinkProvider.java プロジェクト: VeryCompany/social
 /**
  * Gets the uri link to space profile by its pretty name.
  *
  * @param prettyName The pretty name of space.
  * @return the uri link to space @LevelAPI Platform
  * @since 1.2.0 GA
  */
 public static String getSpaceUri(final String prettyName) {
   SpaceService spaceService = getSpaceService();
   Space space = spaceService.getSpaceByPrettyName(prettyName);
   RequestContext ctx = RequestContext.getCurrentInstance();
   if (ctx != null) {
     NodeURL nodeURL = ctx.createURL(NodeURL.TYPE);
     NavigationResource resource =
         new NavigationResource(SiteType.GROUP, space.getGroupId(), space.getUrl());
     return nodeURL.setResource(resource).toString();
   } else {
     return null;
   }
 }
コード例 #3
0
  public static List<SelectItemOption<String>> getTimesSelectBoxOptions(
      String labelFormat, String valueFormat, long timeInteval) {

    WebuiRequestContext context = RequestContext.getCurrentInstance();
    Locale locale = context.getParentAppRequestContext().getLocale();
    return getTimesSelectBoxOptions(labelFormat, valueFormat, timeInteval, locale);
  }
コード例 #4
0
  public String createToken(String gadgetURL, Long moduleId) {
    RequestContext context = RequestContext.getCurrentInstance();
    String rUserId = getIdentityId(context.getRemoteUser());

    // PortalRequestContext request = Util.getPortalRequestContext() ;
    // String uri = request.getNodePath();

    // String[] els = uri.split("/");
    String ownerId = rUserId;
    //    if (els.length >= 3 && els[1].equals("people")) {
    //      ownerId = getIdentityId(els[2]);
    //    }
    /*else if(els.length == 2 && els[1].equals("mydashboard")) {
      owner = rUser;
    }*/

    return createToken(gadgetURL, ownerId, rUserId, moduleId, "default");
  }
コード例 #5
0
  public List<String> getListGroup() throws Exception {
    OrganizationService service = getApplicationComponent(OrganizationService.class);
    List<String> listGroup = new ArrayList<String>();
    RequestContext reqCtx = RequestContext.getCurrentInstance();
    String remoteUser = reqCtx.getRemoteUser();
    if (getCurrentGroup() == null) return null;
    Collection<Group> groups = service.getGroupHandler().findGroups(getCurrentGroup());
    if (groups.size() > 0) {
      for (Object child : groups) {
        Group childGroup = (Group) child;
        Membership membership = getMemberShip(remoteUser, childGroup.getId());

        if (membership != null) {
          listGroup.add(childGroup.getId());
        }
      }
    }
    return listGroup;
  }
コード例 #6
0
 public static String getLabel(String componentid, String id) throws Exception {
   WebuiRequestContext context = RequestContext.getCurrentInstance();
   ResourceBundle res = context.getApplicationResourceBundle();
   String label = componentid + ".label." + id;
   try {
     return res.getString(label);
   } catch (MissingResourceException e) {
     return id;
   }
 }
コード例 #7
0
 public static String getResourceBundle(String key, String defaultValue) {
   WebuiRequestContext context = RequestContext.getCurrentInstance();
   ResourceBundle res = context.getApplicationResourceBundle();
   try {
     return res.getString(key);
   } catch (MissingResourceException e) {
     log.warn("Can not find the resource for key: " + key);
     return defaultValue;
   }
 }
コード例 #8
0
 public static String getServerBaseUrl() {
   PortletRequestContext portletRequestContext = RequestContext.getCurrentInstance();
   String url =
       portletRequestContext.getRequest().getScheme()
           + "://"
           + portletRequestContext.getRequest().getServerName()
           + ":"
           + String.format("%s", portletRequestContext.getRequest().getServerPort())
           + "/";
   return url;
 }
コード例 #9
0
 public static int getLimitUploadSize() {
   PortletRequestContext pcontext = (PortletRequestContext) RequestContext.getCurrentInstance();
   PortletPreferences portletPref = pcontext.getRequest().getPreferences();
   int limitMB;
   try {
     limitMB = Integer.parseInt(portletPref.getValue(UPLOAD_LIMIT, "").trim());
   } catch (NumberFormatException e) {
     limitMB = DEFAULT_VALUE_UPLOAD_PORTAL;
   }
   return limitMB;
 }
コード例 #10
0
  public void update(DriveData drive) throws Exception {
    String[] wsNames =
        getApplicationComponent(RepositoryService.class).getCurrentRepository().getWorkspaceNames();

    List<SelectItemOption<String>> workspace = new ArrayList<SelectItemOption<String>>();

    List<SelectItemOption<String>> foldertypeOptions = new ArrayList<SelectItemOption<String>>();
    for (String wsName : wsNames) {
      workspace.add(new SelectItemOption<String>(wsName, wsName));
    }

    RequestContext context = RequestContext.getCurrentInstance();
    ResourceBundle res = context.getApplicationResourceBundle();

    for (String foldertype : setFoldertypes) {
      try {
        foldertypeOptions.add(
            new SelectItemOption<String>(
                res.getString(getId() + ".label." + foldertype.replace(":", "_")), foldertype));
      } catch (MissingResourceException mre) {
        foldertypeOptions.add(new SelectItemOption<String>(foldertype, foldertype));
      }
    }
    getUIFormSelectBox(FIELD_WORKSPACE).setOptions(workspace);
    Collections.sort(foldertypeOptions, new ItemOptionNameComparator());
    getUIFormSelectBox(FIELD_ALLOW_CREATE_FOLDERS).setOptions(foldertypeOptions);
    getUIFormSelectBox(FIELD_ALLOW_CREATE_FOLDERS).setMultiple(true);
    if (drive != null) {

      // Begin of update
      UIDriveForm uiDriveForm = getAncestorOfType(UIDriveForm.class);
      String selectedWorkspace = drive.getWorkspace();
      String wsInitRootNodeType = uiDriveForm.getWorkspaceEntries(selectedWorkspace);
      // End of update

      invokeGetBindingField(drive);
      // Set value for multi-value select box
      String foldertypes = drive.getAllowCreateFolders();
      String selectedFolderTypes[];
      if (foldertypes.contains(",")) {
        selectedFolderTypes = foldertypes.split(",");
      } else {
        selectedFolderTypes = new String[] {foldertypes};
      }
      List<SelectItemOption<String>> folderOptions = new ArrayList<SelectItemOption<String>>();
      if (wsInitRootNodeType != null && wsInitRootNodeType.equals(Utils.NT_FOLDER)) {
        folderOptions.add(
            new SelectItemOption<String>(UIDriveInputSet.FIELD_FOLDER_ONLY, Utils.NT_FOLDER));
      } else {
        folderOptions.addAll(foldertypeOptions);
      }
      Collections.sort(folderOptions, new ItemOptionNameComparator());
      getUIFormSelectBox(FIELD_ALLOW_CREATE_FOLDERS).setOptions(folderOptions);
      getUIFormSelectBox(FIELD_ALLOW_CREATE_FOLDERS).setSelectedValues(selectedFolderTypes);
      getUIStringInput(FIELD_NAME).setDisabled(true);
      return;
    }
    getUIStringInput(FIELD_NAME).setDisabled(false);
    reset();
    getUICheckBoxInput(FIELD_VIEWPREFERENCESDOC).setChecked(false);
    getUICheckBoxInput(FIELD_VIEWNONDOC).setChecked(false);
    getUICheckBoxInput(FIELD_VIEWSIDEBAR).setChecked(false);
    getUICheckBoxInput(SHOW_HIDDEN_NODE).setChecked(false);
  }
コード例 #11
0
 /**
  * Get current user name.
  *
  * @return
  */
 public String getCurrentUserName() {
   RequestContext context = RequestContext.getCurrentInstance();
   return context.getRemoteUser();
 }
コード例 #12
0
ファイル: Utils.java プロジェクト: RandomStuffs22/ecms
 /**
  * Get resource bundle from PortalApplication resource bundle
  *
  * @param key
  * @return
  * @throws MissingResourceException
  */
 public static String getResourceBundle(String key) throws MissingResourceException {
   RequestContext context = Util.getPortalRequestContext();
   ResourceBundle res = context.getApplicationResourceBundle();
   return res.getString(key);
 }
コード例 #13
0
 public static List<SelectItemOption<String>> getTimesSelectBoxOptions(
     String timeFormat, int timeInteval) {
   WebuiRequestContext context = RequestContext.getCurrentInstance();
   Locale locale = context.getParentAppRequestContext().getLocale();
   return getTimesSelectBoxOptions(timeFormat, TIMEFORMAT, timeInteval, locale);
 }
コード例 #14
0
 public static List<SelectItemOption<String>> getTimesSelectBoxOptions(String timeFormat) {
   WebuiRequestContext context = RequestContext.getCurrentInstance();
   Locale locale = context.getParentAppRequestContext().getLocale();
   return getTimesSelectBoxOptions(
       timeFormat, TIMEFORMAT, CalendarSetting.DEFAULT_TIME_INTERVAL, locale);
 }