title: Access File Directory From Sharepoint Server Using Java - Checking Permissions
body: <p>programmers. Can you please help me? To preface, I'm a first-year intern and the company I work for wants me to write a program that checks if the files on SharePoint are locked or unlocked, and if they are locked, run a PowerShell script to unlock the file and state who it was locked by (so this information is under permissions on SharePoint). The PowerShell script is already done, but I'm have A LOT of trouble with the Java program. I just don't understand how to do it. Please help - this is my first internship and I really don't want to disappoint.</p>
  
  <p>So, since I didn't know how to get the folders, I wrote a simple program to index all the files and folders in a user specified directory (just to get a simple idea of what the hell I'm doing). Now, How would I change the program so I can instead index the SharePoint directory? Please try to explain your solutions as well - I want to learn.</p>
  
  <p>Honestly, even if you can show me an ugly way to do this (i.e. download all the files in a directory and then index them to see if they were locked, and who locked them), I'd be over the moon. Just, please help...</p>
  
  <p>Here is a code snippet I wrote using TreeView. I know it's not that good or optimized - I'm still relatively new to Java, and I just want it to work:</p>
  
  <pre><code>    private File user_filedirectory() throws Exception {
      String directory_name;
      directory_name = JOptionPane.showInputDialog(null, "Enter a file directory: ", "File Directory", JOptionPane.INFORMATION_MESSAGE);
  
      boolean bool_directory;
      bool_directory = false;
      boolean bool_exists;
      bool_exists = false;
  
      String path;
      path = null;
      File f;
      f = null;
  
      f = new File(directory_name);
      bool_directory = f.isDirectory();
      bool_exists = f.exists();
  
      path = f.getPath();
  
      if (!(bool_exists || bool_directory)) {
          showMessageDialog(null, "Invalid File Directory! Close Alert and Try Again...", "Invalid File Directory", ERROR_MESSAGE);
          return user_filedirectory();
      } else return f;
  }
  
  private void createNodes(DefaultMutableTreeNode node, File f) {
  
      if (!f.isDirectory()) {
          out.printf("FILE - %s%n", f.getName());
          DefaultMutableTreeNode child;
          child = new DefaultMutableTreeNode(f);
          node.add(child);
      } else {
          out.printf("DIRECTORY - %s%n", f.getName());
          DefaultMutableTreeNode child;
          child = new DefaultMutableTreeNode(f);
          node.add(child);
          File[] fList;
          fList = f.listFiles();
          if (fList == null);
          File[] requireNonNull;
          requireNonNull = requireNonNull(fList);
          for (int i = 0, requireNonNullLength = requireNonNull.length; i &lt; requireNonNullLength; i++) {
              File aRequireNonNull;
              aRequireNonNull = requireNonNull[i];
              File aFList;
              aFList = aRequireNonNull;
              createNodes(child, aFList);
          }
      }
  }
  </code></pre>