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); } } }
/** * 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; } }
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); }
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"); }
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; }
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; } }
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; } }
public static String getServerBaseUrl() { PortletRequestContext portletRequestContext = RequestContext.getCurrentInstance(); String url = portletRequestContext.getRequest().getScheme() + "://" + portletRequestContext.getRequest().getServerName() + ":" + String.format("%s", portletRequestContext.getRequest().getServerPort()) + "/"; return url; }
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; }
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); }
/** * Get current user name. * * @return */ public String getCurrentUserName() { RequestContext context = RequestContext.getCurrentInstance(); return context.getRemoteUser(); }
/** * 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); }
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); }
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); }