Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
  /**
   * Get allowed folder types in current path.
   *
   * @param currentNode
   * @param currentDrive
   * @return List<String> of node types
   * @throws Exception
   */
  public static List<String> getAllowedFolderTypesInCurrentPath(
      Node currentNode, DriveData currentDrive) throws Exception {
    List<String> allowedTypes = new ArrayList<String>();
    NodeTypeImpl currentNodeType = (NodeTypeImpl) currentNode.getPrimaryNodeType();
    String[] arrFoldertypes = currentDrive.getAllowCreateFolders().split(",");
    NodeTypeManager ntManager = currentNode.getSession().getWorkspace().getNodeTypeManager();

    for (String strFolderType : arrFoldertypes) {
      if (strFolderType.isEmpty()) continue;
      NodeType folderType = ntManager.getNodeType(strFolderType);
      if ((currentNodeType)
          .isChildNodePrimaryTypeAllowed(
              Constants.JCR_ANY_NAME, ((NodeTypeImpl) folderType).getQName())) {
        allowedTypes.add(strFolderType);
      }
    }

    return allowedTypes;
  }
Exemplo n.º 3
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);
  }