audiojury.proxy
Class ProjectStoragePlugin

java.lang.Object
  |
  +--java.util.Observable
        |
        +--audiojury.proxy.ProjectStoragePlugin
All Implemented Interfaces:
ProjectProcessing

public class ProjectStoragePlugin
extends java.util.Observable
implements ProjectProcessing

Deals with project storage details. It can be replaced if another storage subsystem, such as a DBMS, if wanted. This specific plugin implementation is based on directory hierarchy and common files. It can utilize Windows shared folders to distribute projects.

See Also:
ProjectProcessing, ProjectManager

Constructor Summary
ProjectStoragePlugin()
          Constructor.
 
Method Summary
 void activateProject(java.lang.String name, java.lang.String activeName)
          Activates a Project by copying it from the dynamic directory to the active directory and also changing the name.
 void closeProject(java.lang.String name)
          Moves a Project from active to closed state.
 Scale[] createStandardScales()
          Generates the standard Scales ACR, CCR and DCR.
 void deleteProject(java.lang.String name, int state)
          Deletes a Project permanently.
 void duplicateProject(java.lang.String name, java.lang.String newname)
          Duplicates a Project in dynamic state.
 boolean existsSharedFolder()
          Checks for the existence and accessebility of a shared folder
protected  ConfigManager getConfigManager()
          Returns the unique instance of ConfigManager.
 java.lang.String getProjectPath(java.lang.String name, int state)
          Retrieves the path to a specifc Project in a specific state.
 boolean isUniqueProjectName(java.lang.String name, int state)
          Checks it a Project name is unique within a specific project state domain.
 java.util.Hashtable listActiveProjects()
          Used by the client to discover available projects.
 java.util.Hashtable listProjects(int state)
          Lists Projects.
 java.util.Hashtable listProjectsAndTests(int state)
          Lists Projects and Tests.
 Project newProject(java.lang.String name)
          Creates a new Project.
 Project openProject(java.lang.String name)
          Opens a Project that is in dynamic state.
 Project openProjectPassive(java.lang.String name)
          Opens a Project for AudioJury Client
 Scale[] openScales()
          Opens Scales from a scale.conf file.
 Test openTest(java.lang.String testname, java.lang.String proj_path)
          Opens a Test within a specific Project.
 void reactivateProject(java.lang.String name)
          Moves a Project from closed state back to active state.
 void registerObserver(java.util.Observer observer)
          Registers an observer so that the observer will be notified when status of the ProjectStoragePlugin changes.
 void renameProject(java.lang.String name, java.lang.String newname)
          Renames a Project in dynamic state.
 void saveProject(Project project)
          Saves a Project object to disk.
 void saveScales(Scale[] scales)
          Saves Scale objects in a stream file named scale.conf
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectStoragePlugin

public ProjectStoragePlugin()
Constructor.

Method Detail

registerObserver

public void registerObserver(java.util.Observer observer)
Registers an observer so that the observer will be notified when status of the ProjectStoragePlugin changes.

Parameters:
observer - An observer.

existsSharedFolder

public boolean existsSharedFolder()
Checks for the existence and accessebility of a shared folder

Returns:
True if a shared folders is defined, exists and is writable. False otherwise.

createStandardScales

public Scale[] createStandardScales()
Generates the standard Scales ACR, CCR and DCR.

Specified by:
createStandardScales in interface ProjectProcessing
Returns:
An array of standard Scales.

openScales

public Scale[] openScales()
                   throws ProjectOperationException
Opens Scales from a scale.conf file. The scale is located in the project base directory.

Specified by:
openScales in interface ProjectProcessing
Returns:
An array of Scales loaded from file.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

saveScales

public void saveScales(Scale[] scales)
                throws ProjectOperationException
Saves Scale objects in a stream file named scale.conf

Specified by:
saveScales in interface ProjectProcessing
Parameters:
scales - An array of Scales.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

listProjectsAndTests

public java.util.Hashtable listProjectsAndTests(int state)
                                         throws ProjectOperationException
Lists Projects and Tests.

Specified by:
listProjectsAndTests in interface ProjectProcessing
Parameters:
state - List projects in this state. State identifiers are defined in audiojury.domain.Project
Returns:
A hashtable with project names as keys. Each entry consists of another hashtable, listing the tests in the respective projects. The keys of this hashtable are test names and the entries are paths to tests.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
See Also:
audiojury.domain.Project#

listProjects

public java.util.Hashtable listProjects(int state)
                                 throws ProjectOperationException
Lists Projects.

Specified by:
listProjects in interface ProjectProcessing
Parameters:
state - List projects in this state. State identifiers are defined in audiojury.domain.Project
Returns:
A hashtable with project names as keys. Each entry is the path to the respective project.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
See Also:
audiojury.domain.Project#

listActiveProjects

public java.util.Hashtable listActiveProjects()
                                       throws ProjectOperationException
Used by the client to discover available projects. The keys in the table are strings of project names.

Specified by:
listActiveProjects in interface ProjectProcessing
Returns:
A hashtable where the keys are project name strings.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

isUniqueProjectName

public boolean isUniqueProjectName(java.lang.String name,
                                   int state)
                            throws ProjectOperationException
Checks it a Project name is unique within a specific project state domain.

Specified by:
isUniqueProjectName in interface ProjectProcessing
Parameters:
name - A name candidate.
state - The project state domain to check against. Project states are defined in audiojury.domain.Project
Returns:
True if the project name has not been used, and therefore is unique. False otherwise.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

duplicateProject

public void duplicateProject(java.lang.String name,
                             java.lang.String newname)
                      throws ProjectOperationException,
                             NotUniqueNameException
Duplicates a Project in dynamic state.

Specified by:
duplicateProject in interface ProjectProcessing
Parameters:
name - The name of the project to duplicate.
newname - The name of the copy that will be created.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
NotUniqueNameException - if the proposed name is not unique.

renameProject

public void renameProject(java.lang.String name,
                          java.lang.String newname)
                   throws ProjectOperationException,
                          NotUniqueNameException
Renames a Project in dynamic state.

Specified by:
renameProject in interface ProjectProcessing
Parameters:
name - The current name of the Project.
newname - The new desired name of the Project.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
NotUniqueNameException - if the proposed name is not unique.

closeProject

public void closeProject(java.lang.String name)
                  throws ProjectOperationException
Moves a Project from active to closed state.

Specified by:
closeProject in interface ProjectProcessing
Parameters:
name - The name of the Project to close. The project must be in active state for the closure to be possible.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation.

reactivateProject

public void reactivateProject(java.lang.String name)
                       throws ProjectOperationException
Moves a Project from closed state back to active state.

Specified by:
reactivateProject in interface ProjectProcessing
Parameters:
name - The name of the Project to reactivate.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

activateProject

public void activateProject(java.lang.String name,
                            java.lang.String activeName)
                     throws ProjectOperationException
Activates a Project by copying it from the dynamic directory to the active directory and also changing the name. If a shared folder exists the project is also copied there.

Specified by:
activateProject in interface ProjectProcessing
Parameters:
name - The name of the Project to activate
activeName - The name the Project should have in active state.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

deleteProject

public void deleteProject(java.lang.String name,
                          int state)
                   throws ProjectOperationException
Deletes a Project permanently.

Specified by:
deleteProject in interface ProjectProcessing
Parameters:
name - Name of the Project to delete.
state - In which state to look for the Project.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

saveProject

public void saveProject(Project project)
                 throws ProjectOperationException
Saves a Project object to disk.

Specified by:
saveProject in interface ProjectProcessing
Parameters:
project - A Project object to save.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation

openProject

public Project openProject(java.lang.String name)
                    throws ProjectOperationException,
                           NoProjectFoundException
Opens a Project that is in dynamic state.

Specified by:
openProject in interface ProjectProcessing
Parameters:
name - The name of the Project.
Returns:
The opened Project.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
NoProjectFoundException - if no project was found with the specified name.

openProjectPassive

public Project openProjectPassive(java.lang.String name)
                           throws ProjectOperationException,
                                  NoProjectFoundException
Opens a Project for AudioJury Client

Parameters:
name - The name of the Project.
Returns:
The opened Project.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
NoProjectFoundException - if no project was found with the specified name.

newProject

public Project newProject(java.lang.String name)
                   throws ProjectOperationException,
                          NotUniqueNameException
Creates a new Project.

Specified by:
newProject in interface ProjectProcessing
Parameters:
name - The desired name of the new Project.
Returns:
A new Project object.
Throws:
ProjectOperationException - if there was an unhandled exception while performing the operation
NotUniqueNameException - if the proposed name is not unique.

getConfigManager

protected ConfigManager getConfigManager()
Returns the unique instance of ConfigManager.

Returns:
A ConfigManager instance.

getProjectPath

public java.lang.String getProjectPath(java.lang.String name,
                                       int state)
Retrieves the path to a specifc Project in a specific state.

Parameters:
name - The name of the Project to get the path to.
state - The state of the Project to get the path to.
Returns:
String with the path to the specified Project.

openTest

public Test openTest(java.lang.String testname,
                     java.lang.String proj_path)
              throws java.io.IOException,
                     java.lang.ClassNotFoundException
Opens a Test within a specific Project.

Parameters:
testname - The name of the Test to open.
proj_path - The path to the Project containing the Test.
Returns:
The opened Test.
Throws:
java.io.IOException - if there was an unhandled IO error during the operation.
java.lang.ClassNotFoundException - if the class of a serialized object cannot be found.