private String getDriveName(List<DriveData> lstDrive, Node node) throws RepositoryException { String driveName = ""; for (DriveData drive : lstDrive) { if (node.getSession().getWorkspace().getName().equals(drive.getWorkspace()) && node.getPath().contains(drive.getHomePath()) && drive.getHomePath().equals("/")) { driveName = drive.getName(); break; } } return driveName; }
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); }