org.kohsuke.jnt
Class JNFileFolder

java.lang.Object
  extended by org.kohsuke.jnt.JNFileFolder

public final class JNFileFolder
extends Object

folder in the java.net file sharing section.

In java.net, the "documents & files" section serves as a simle per-project file system. This object represents one folder in such a file system.

Author:
Kohsuke Kawaguchi (kk@kohsuke.org)

Method Summary
 JNFileFolder createFolder(String name, String description)
          Creates a new sub-folder in this folder.
 void delete()
          Removes this folder.
 void deleteFile(String fileName)
          Deprecated. use getFiles().get(fileName).delete()
 boolean equals(Object o)
           
 boolean existsFile(String fileName)
          Deprecated. use getFiles().containsKey(fileName)
 JNFile getFile(String fileName)
          Gets a file in this folder.
 Map<String,JNFile> getFiles()
          Returns the files in this folder.
 int getId()
          Gets the unique ID that distinguishes this folder.
 String getName()
          Gets the name of this folder.
 JNFileFolder getParent()
          Returns the parent folder, or null if this folder is the root.
 JNFileFolder getSubFolder(String folderName)
          Returns a sub-folder.
 Map<String,JNFileFolder> getSubFolders()
          Returns the subfolders of this folder.
 int hashCode()
           
 boolean isRoot()
          Returns true if this is the root folder of a project.
 JNFile linkUrl(String fileName, String description, FileStatus status, URL link)
          Creates a link to an URL.
 JNFile uploadFile(String fileName, String description, FileStatus fileStatus, File fileToUpload)
          Uploads a file to the folder.
 JNFile uploadFile(String fileName, String description, FileStatus fileStatus, InputStream data, String contentType)
          Uploads a file from a source other than File.
 void uploadFile(String fileName, String description, String fileStatus, File fileToUpload)
          Deprecated. use uploadFile(String, String, FileStatus, File)
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSubFolder

public JNFileFolder getSubFolder(String folderName)
                          throws ProcessingException
Returns a sub-folder.

Parameters:
folderName - '/'-separated folder name. such as "abc", "abc/def", or "/abc/def".
Returns:
if the folder is not found, return null.
Throws:
ProcessingException

getParent

public JNFileFolder getParent()
Returns the parent folder, or null if this folder is the root.


getName

public String getName()
Gets the name of this folder.

For the root folder, this method returns the name of the project.

Returns:
always non-null valid string.

getId

public int getId()
Gets the unique ID that distinguishes this folder.

The uniqueness is within a project.


isRoot

public boolean isRoot()
Returns true if this is the root folder of a project.


getSubFolders

public Map<String,JNFileFolder> getSubFolders()
                                       throws ProcessingException
Returns the subfolders of this folder.

Returns:
can be empty but never be null. read-only.
Throws:
ProcessingException

getFiles

public Map<String,JNFile> getFiles()
                            throws ProcessingException
Returns the files in this folder.

Returns:
can be empty but never be null. read-only.
Throws:
ProcessingException

getFile

public JNFile getFile(String fileName)
               throws ProcessingException
Gets a file in this folder.

Convenience method for getFiles().get(fileName).

Throws:
ProcessingException

uploadFile

public void uploadFile(String fileName,
                       String description,
                       String fileStatus,
                       File fileToUpload)
                throws ProcessingException
Deprecated. use uploadFile(String, String, FileStatus, File)

Uploads a file to the folder.

Parameters:
fileStatus - can be null.
Throws:
ProcessingException

uploadFile

public JNFile uploadFile(String fileName,
                         String description,
                         FileStatus fileStatus,
                         File fileToUpload)
                  throws ProcessingException
Uploads a file to the folder.

Parameters:
fileStatus - can be null.
Throws:
ProcessingException

uploadFile

public JNFile uploadFile(String fileName,
                         String description,
                         FileStatus fileStatus,
                         InputStream data,
                         String contentType)
                  throws ProcessingException
Uploads a file from a source other than File.

Parameters:
data - The InputStream uploaded as a file.
contentType - The MIME type of the file to be uploaded, such as "text/plain" or "application/x-zip-compressed". java.net server doesn't seem to be using this information, so it could be just "application/octet-stream".
Throws:
ProcessingException

linkUrl

public JNFile linkUrl(String fileName,
                      String description,
                      FileStatus status,
                      URL link)
               throws ProcessingException
Creates a link to an URL.

Throws:
ProcessingException

createFolder

public JNFileFolder createFolder(String name,
                                 String description)
                          throws ProcessingException
Creates a new sub-folder in this folder.

This is an admin only operation

Returns:
newly created folder.
Throws:
ProcessingException

delete

public void delete()
            throws ProcessingException
Removes this folder.

Throws:
ProcessingException

existsFile

public boolean existsFile(String fileName)
                   throws ProcessingException
Deprecated. use getFiles().containsKey(fileName)

Checks if the specified file exists in the folder.

Throws:
ProcessingException

deleteFile

public void deleteFile(String fileName)
                throws ProcessingException
Deprecated. use getFiles().get(fileName).delete()

Deletes a file from the folder.

Throws:
ProcessingException

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2003-2009 Kohsuke Kawaguchi. All Rights Reserved.