Class AccountFileManager

java.lang.Object
  |
  +--AccountFileManager

public class AccountFileManager
extends java.lang.Object

This class takes care of file manipulations on the server, as well creating new user accounts, checking the login operation, and reading the user's directory contents.

Author:
James Brundege

Constructor Summary
AccountFileManager(org.bioquery.bqutils.BQUser user, java.lang.String bioqueryDirectory)
          Constructor needs a BQUser object and the path to the bioquery-users directory.
 
Method Summary
 boolean authenticate()
          Checks the username and password of the BQUser passed in the constructor.
 boolean copyFile(java.lang.String oldPath, java.lang.String newPath)
          Copies the file from oldPath to newPath.
 boolean createDirectory(java.lang.String path)
          Creates a new directory in the user's home directory.
 boolean createNewAccount()
          Creates a new user account based on the BQUser passed to the constructor.
 boolean deleteFile(java.lang.String path)
          Deletes the file or directory at path.
 boolean moveFile(java.lang.String oldPath, java.lang.String newPath)
          Moves the file from oldPath to newPath.
 java.io.InputStream openFile(java.lang.String filePath)
          Opens the file for the given filePath and returns an InputStream to that file's contents.
 boolean renameFile(java.lang.String oldPath, java.lang.String newName)
          Renames the file at oldPath to newName.
 boolean saveFile(java.io.InputStream content, java.lang.String path)
          Saves the contents of the given InputStream into a file with the location and name given in path.
 java.util.List updateFileList()
          Returns a List containing the full path of every file and directory in this users account, relative to this users directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountFileManager

public AccountFileManager(org.bioquery.bqutils.BQUser user,
                          java.lang.String bioqueryDirectory)
Constructor needs a BQUser object and the path to the bioquery-users directory.
Parameters:
user - a BQUser object with the username and password.
bioqueryDirectory - A String of the full path to the bioquery users directory. Should be the the bioquery-users directory for all users, not to the subdirectory of the BQUser passed in (which is bioqueryDirectory + username).
Method Detail

createNewAccount

public boolean createNewAccount()
Creates a new user account based on the BQUser passed to the constructor.
Returns:
true if the account was created successfully, false if the account was not made. Reasons for a false return might include the username was in use, the username or password were too short or contained invalid characters, or the user directory could not be created.

authenticate

public boolean authenticate()
Checks the username and password of the BQUser passed in the constructor.
Returns:
true if the username and password are valid, false otherwise.

updateFileList

public java.util.List updateFileList()
Returns a List containing the full path of every file and directory in this users account, relative to this users directory.

openFile

public java.io.InputStream openFile(java.lang.String filePath)
Opens the file for the given filePath and returns an InputStream to that file's contents. The filePath should be relative to the user's directory.

createDirectory

public boolean createDirectory(java.lang.String path)
Creates a new directory in the user's home directory. The path should be relative to the user's home directory.
Parameters:
path - a path to the new directory relative to the user's home directory.
Returns:
true if the directory was created successfully, else false.

saveFile

public boolean saveFile(java.io.InputStream content,
                        java.lang.String path)
Saves the contents of the given InputStream into a file with the location and name given in path.
Parameters:
content - An InputStream from which the file contents can be read.
path - The path at which to save the file, relative to the user's home directory, and including the filename on the end.
Returns:
true if the file was saved successfully, false otherwise.

deleteFile

public boolean deleteFile(java.lang.String path)
Deletes the file or directory at path.
Parameters:
path - the path of the file or directory to be deleted, relative to the user's home directory.
Returns:
true if the file was deleted successfully, else false.

moveFile

public boolean moveFile(java.lang.String oldPath,
                        java.lang.String newPath)
Moves the file from oldPath to newPath.
Parameters:
oldPath - The current location of the file to be moved, relative to the user's home directory.
newPath - The location to move the file to.
Returns:
true if the file was moved successfully, else false.

copyFile

public boolean copyFile(java.lang.String oldPath,
                        java.lang.String newPath)
Copies the file from oldPath to newPath.
Parameters:
oldPath - The current location of the file to be copied, relative to the user's home directory.
newPath - The location to copy the file to.
Returns:
true if the file was copied successfully, else false.

renameFile

public boolean renameFile(java.lang.String oldPath,
                          java.lang.String newName)
Renames the file at oldPath to newName.
Parameters:
oldPath - The current path to the file to be renamed, relative to the user's home directory.
newName - The name to change the filename to, without any path inforamtion.
Returns:
true if the file was renamed successfully, else false.