org.openi.project
Class ProjectFactory

java.lang.Object
  extended byorg.openi.project.ProjectFactory

public class ProjectFactory
extends java.lang.Object

Author:
plucas TODO - factory needs to cache the projects

Method Summary
static Project createProject(java.lang.String baseDirName, java.lang.String projectId)
          Separate from getProject to avoid creating a project when there just might be a typo, error, security flaw.
static Project getProject(java.lang.String baseDirName, java.lang.String projectId)
          Currently not cached - loads project from file each time.
static java.util.Map getProjectMap(java.lang.String baseDirName)
          Always returns all available projects underneath the baseDirName.
static java.util.Map getProjectsByCategory(java.lang.String baseDirName)
           
static java.util.Map getProjectsByCategory(java.lang.String baseDirName, java.lang.String username)
          Returns map of categories, each category contains a list of projects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProjectMap

public static java.util.Map getProjectMap(java.lang.String baseDirName)
Always returns all available projects underneath the baseDirName. The map does not contain any category grouping. (Although the project object has a getCategory method). If you need grouping by category use the getProjectsByCategory method. Directories underneath baseDirName are filtered using ProjectDirectoryFilter (filters WEB-INF, META-INF, CVS directories). If a subdirectory does not have a project.xml file, an IOException is trapped, logged, but processing continues. XXX: should this be a private method?

Returns:
projects key=projectId, value=project

getProjectsByCategory

public static java.util.Map getProjectsByCategory(java.lang.String baseDirName)
Parameters:
baseDirName -
Returns:
See Also:
This signature is intended to generate maps for application admins only. Acutally, this should probably be eliminated once app admin configuration is extracted from web.xml

getProjectsByCategory

public static java.util.Map getProjectsByCategory(java.lang.String baseDirName,
                                                  java.lang.String username)
Returns map of categories, each category contains a list of projects. Key=categoryName, value=Category object If a project.categoryName is null, it is replaced with "General" Categories are included only if the user has access to at least one project in that category Because we have the notion of project maps per user, this means caching (if ever) will need to be per user - session. Probably best to not cache the map at all. If caching is needed, cache at getProject.

Parameters:
baseDirName -

getProject

public static Project getProject(java.lang.String baseDirName,
                                 java.lang.String projectId)
                          throws java.io.IOException
Currently not cached - loads project from file each time.

Parameters:
baseDirName - - base directory that contains all projects
projectId - - must match the directory name (relative to baseDirName)
Returns:
Throws:
java.io.IOException

createProject

public static Project createProject(java.lang.String baseDirName,
                                    java.lang.String projectId)
                             throws java.io.IOException
Separate from getProject to avoid creating a project when there just might be a typo, error, security flaw.

Throws:
java.io.IOException