net.sourceforge.sconman
Class Project

java.lang.Object
  extended by net.sourceforge.sconman.Category
      extended by net.sourceforge.sconman.Project
All Implemented Interfaces:
IXMLSerializable

public class Project
extends Category
implements IXMLSerializable

The Projectis the main point for content management, as it's the root of the Categorytree of contents, and the place where ContentTypes are defined, and IAgents work on.

TODO: Add a MetadataManager that handle content metadata storage, independent from the repository itself. This should allow to build a manager that do not use the repository to store metadata

Author:
mikeshadow

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.sconman.Category
Category.RepositoryIndexSynchronizer
 
Field Summary
 
Fields inherited from class net.sourceforge.sconman.Category
allowedContentTypes, allowedContentTypesCSV, categories, defaultLanguage, descriptor, id, MODIFY_PERMISSION, parent, project, properties, repository, VIEW_PERMISSION
 
Constructor Summary
Project(java.io.InputStream is, java.lang.String projectPath, java.lang.String projectName)
          Loads a project.
Project(java.lang.String projectPath)
          Loads a previously stored project in the specified project path
Project(java.lang.String projectPath, java.lang.String id)
          Creates a new project at the specified projectPath
Project(java.lang.String projectPath, java.lang.String id, IRepository repo)
          Creates a new project at the specified projectPath and repository
 
Method Summary
 IAgent addAgent(java.lang.String name, java.lang.String classname, long period)
          Adds an IAgentimplementation that will work within the project's context.
 void addContent(User actor, java.io.File file, IProgressObserver po)
          Adds a file or directory (all the files in the directory tree) to the project.
(package private)  void addContentType(ContentType ctype)
          Adds a new content type for this project
(package private)  ContentType addContentType(java.lang.String id, java.lang.String fileExtensions, java.lang.String defaultCategory, IContentTypeHandler hanlder)
          Adds a new content type for this project
 ContentType addContentType(User actor, java.lang.String id, java.lang.String fileExtensions, java.lang.String defaultCategory, IContentTypeHandler hanlder)
           
 void addLanguage(Language language)
          Adds a new language to the project
 void addSCMEventListener(ISCMEventListener listener)
          Adds a new observer of project events
 void close()
          Free resources and notify listeners
 void deserializeXML(org.kxml2.io.KXmlParser in)
          Deserialize from XML
 IAgent getAgent(java.lang.String id)
          Returns an agent
 java.util.Collection getAgents()
          Returns all the agents working on this project
 ISearchResults getAllContents()
          Returns all the Contentstored in the project
 java.util.logging.Logger getChangeLogger()
          Returns the change logger
(package private)  Content getContent(java.lang.String uri)
          Returns the specified content, given its URI
 Content getContent(User actor, java.lang.String uri)
          Returns the specified content, given its URI, checking user permissions
 ContentType getContentType(java.lang.String id)
          Returns a content type
(package private)  java.util.Collection getContentTypes()
          Returns all the ContentTypes
 java.util.Collection getContentTypes(User actor)
          Returns the ContentTypes visible to the user
(package private)  ISCMEventListener getEventMulticaster()
          Returns the event multicaster
(package private)  java.util.Map getExtensionToContentTypeMap()
          Returns the extension to content type map
 ContentType getFileContentType(java.lang.String fext)
          Returns a file's associated ContentType.
(package private)  IndexManager getIndexManager()
          Returns the index manager
 Language getLanguage(java.lang.String locale)
           
 java.util.Collection getLanguageLocales()
          Return all the languages added to the project
 java.lang.String getLanguageName(java.lang.String userLocale, java.lang.String locale)
          Returns the language id in the user locale
 java.util.Collection getLanguages()
          Return all the languages added to the project
(package private) static java.io.File getProjectConfigurationFile(java.lang.String projectPath)
          Returns the project's configuration file, known the project's id
 java.lang.String getProjectPath()
          Returns the project's absolute path in the file system
 java.util.Map getProjectRoles(User actor)
           
 IProjectSynchronizer getProjectSynchronizer()
          Returns the project synchronizer manager (@link IProjectSynchronizer)
(package private)  Content getRepositoryContent(java.lang.String uri)
          Reads a content from the repository, known its URI
 Content getRepositoryContent(User actor, java.lang.String uri)
          Reads a content from the repository, known its URI
 SecurityContext getSecurityContext()
          Returns the SecurityContextthat handles Users, Roles, and permissions
 ISubscriptionHandler getSubscriptionHandler()
          Returns the subscriptions handler
 boolean isRunningAgentManager()
          Check if the agent execution shedule of the Project is running.
(package private)  void regenerateIndex()
           
 void regenerateIndex(User user)
          Regenerates index
(package private)  void remove()
          Removes the project
 void remove(User user)
          Removes the project
 void removeAgent(java.lang.String id)
          Removes an agent from this project
 void removeContentType(User actor, java.lang.String id)
          Removes a content type, known its id
 void removeLanguage(java.lang.String locale)
          Removes a language from the project
 void removeSCMEventListener(ISCMEventListener listener)
          Removes an observer of project events
(package private)  void save()
          Saves the project state
 void save(User user)
          Saves the project state
(package private)  ISearchResults search(Query query, boolean visible)
          Return all the contents that match the query
(package private)  ISearchResults search(Query query, boolean visible, boolean reverseOrder)
          Return all the contents that match the query
(package private)  ISearchResults searchFuture(Query query)
          Searches old contents (those whose toDate property is before today)
(package private)  ISearchResults searchOld(Query query)
          Searches old contents (those whose toDate property is before today)
 void serializeXML(org.kxml2.io.KXmlSerializer out)
          Serialize to XML
 void setSubscriptionHandler(ISubscriptionHandler handler)
          Sets the subscription handler for this project
 void startAgents(User actor)
          Starts the agent execution shedule.
 void stopAgents(User actor)
          Stops the agent execution shedule
 java.lang.String toString()
          A String representation for this object
 
Methods inherited from class net.sourceforge.sconman.Category
addAllowedContentType, addAllowedContentType, addCategory, addCategory, addCategory, addCategoryClause, addContent, addContent, addContent, addContent, addContent, canModify, canRemove, canView, cloneContents, cloneContents, cloneContents, deserializeSharedFieldsXML, getAllCategories, getAllContents, getAllContents, getAllContents, getAllowedContentTypes, getAllowedContentTypes, getAllRepositories, getAsList, getAsList, getCategories, getCategories, getCategory, getCategory, getCategoryToHistorifyOldContents, getContent, getContents, getContents, getContents, getContents, getContents, getContentURIFromFilePathInRepository, getDefaultlanguage, getDefaultLocale, getDefinedAllowedContentTypes, getDescription, getDescription, getFutureContents, getHistoryDays, getId, getName, getName, getOldContents, getOldContents, getParent, getParent, getPath, getProject, getProperties, getProperty, getRepository, getValidCategoriesFor, getValidCategoriesFor, index, isSubscribed, isSystem, reindex, removeAllContents, removeAllowedContentType, removeAllowedContentType, removeCategory, removeCategory, removeCategory, removeContents, safeSearch, safeSearch, safeSearch, safeSearch, safeSearch, safeUserContentsSearch, search, search, serializeSharedFieldsXML, setCategoryToHistorifyOldContents, setDefaultLanguage, setDefaultLocale, setDescription, setHistoryDays, setId, setName, setProperty, setRepository, subscribe, synchronize, synchronize, synchronizeAll, synchronizeAll, unindex, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Project

public Project(java.lang.String projectPath,
               java.lang.String id)
        throws java.io.IOException
Creates a new project at the specified projectPath

Parameters:
projectPath - The project directory path where configuration file, the index, and defalut repository will be stored
id - The project id
Throws:
java.io.IOException

Project

public Project(java.lang.String projectPath,
               java.lang.String id,
               IRepository repo)
        throws java.io.IOException
Creates a new project at the specified projectPath and repository

Parameters:
projectPath - The project directory path where configuration file, the index, and defalut repository will be stored
id - The project id
repo - The project default repository
Throws:
java.io.IOException

Project

public Project(java.lang.String projectPath)
        throws java.io.IOException
Loads a previously stored project in the specified project path

Parameters:
projectPath - The filesystem path where the project was loaded
Throws:
java.io.IOException - Thrown if the project cannot be loaded

Project

public Project(java.io.InputStream is,
               java.lang.String projectPath,
               java.lang.String projectName)
        throws java.io.IOException
Loads a project.

Parameters:
is - InputStream with the project configuration
Throws:
java.io.IOException
Method Detail

close

public void close()
Free resources and notify listeners


getChangeLogger

public java.util.logging.Logger getChangeLogger()
Returns the change logger

Returns:

toString

public java.lang.String toString()
Description copied from class: Category
A String representation for this object

Overrides:
toString in class Category
Returns:
String representation

getIndexManager

IndexManager getIndexManager()
Returns the index manager

Returns:
The index manager

setSubscriptionHandler

public void setSubscriptionHandler(ISubscriptionHandler handler)
Sets the subscription handler for this project

Parameters:
handler -

getSubscriptionHandler

public ISubscriptionHandler getSubscriptionHandler()
Returns the subscriptions handler

Returns:

getProjectSynchronizer

public IProjectSynchronizer getProjectSynchronizer()
Returns the project synchronizer manager (@link IProjectSynchronizer)

Returns:
The (@link IProjectSynchronizer)

addLanguage

public void addLanguage(Language language)
Adds a new language to the project

Parameters:
locale - The Locale String representation

removeLanguage

public void removeLanguage(java.lang.String locale)
Removes a language from the project

Parameters:
locale - The String representation of the Locale to remove

getLanguages

public java.util.Collection getLanguages()
Return all the languages added to the project

Returns:
A Colletion of String objects

getLanguageLocales

public java.util.Collection getLanguageLocales()
Return all the languages added to the project

Returns:
A Collection of Localeobjects

getLanguageName

public java.lang.String getLanguageName(java.lang.String userLocale,
                                        java.lang.String locale)
Returns the language id in the user locale

Parameters:
userLocale - The user locale
locale - The language whose id is requested
Returns:
The language id

getLanguage

public Language getLanguage(java.lang.String locale)
Parameters:
locale -
Returns:

getEventMulticaster

ISCMEventListener getEventMulticaster()
Returns the event multicaster

Returns:
The event multicaster

addSCMEventListener

public void addSCMEventListener(ISCMEventListener listener)
Adds a new observer of project events

Parameters:
listener - The listener/observer to add

removeSCMEventListener

public void removeSCMEventListener(ISCMEventListener listener)
Removes an observer of project events

Parameters:
listener - The listener/observer to remove

save

public void save(User user)
          throws SCMException
Saves the project state

Throws:
java.io.IOException
SCMException

save

void save()
    throws java.io.IOException
Saves the project state

Throws:
java.io.IOException

remove

void remove()
      throws SCMException
Removes the project

Throws:
SCMException - Thrown if the project doesn't exist

remove

public void remove(User user)
            throws SCMException
Removes the project

Throws:
SCMException - Thrown if the project doesn't exist

getProjectConfigurationFile

static java.io.File getProjectConfigurationFile(java.lang.String projectPath)
Returns the project's configuration file, known the project's id

Parameters:
id - The project's id
Returns:
The configuration file

getProjectPath

public java.lang.String getProjectPath()
Returns the project's absolute path in the file system

Returns:
The project's absolute path

getContentTypes

java.util.Collection getContentTypes()
Returns all the ContentTypes

Returns:
All the project's content types

getContentTypes

public java.util.Collection getContentTypes(User actor)
Returns the ContentTypes visible to the user

Parameters:
actor - The user that performs the action
Returns:
The ContentTypes that the user can see

getContentType

public ContentType getContentType(java.lang.String id)
Returns a content type

Parameters:
id - The content type id
Returns:
The requested content type

getExtensionToContentTypeMap

java.util.Map getExtensionToContentTypeMap()
Returns the extension to content type map

Returns:
The map that returns a ContentType, known a file extension

addContentType

void addContentType(ContentType ctype)
Adds a new content type for this project

Parameters:
ctype - The new content type to add

addContentType

public ContentType addContentType(User actor,
                                  java.lang.String id,
                                  java.lang.String fileExtensions,
                                  java.lang.String defaultCategory,
                                  IContentTypeHandler hanlder)
                           throws SCMSecurityException
Throws:
SCMSecurityException

addContentType

ContentType addContentType(java.lang.String id,
                           java.lang.String fileExtensions,
                           java.lang.String defaultCategory,
                           IContentTypeHandler hanlder)
Adds a new content type for this project

Parameters:
id - The content type id
fileExtensions - A CSV string with the file extensions, or null if the content type doesn't have an associated file
defaultCategory - The default category to use
hanler - The IContentTypeHandlerto use when adding contents of this type.
Returns:
The new content type

removeContentType

public void removeContentType(User actor,
                              java.lang.String id)
                       throws SCMSecurityException
Removes a content type, known its id

Parameters:
id - The content type id
Throws:
SCMSecurityException

getFileContentType

public ContentType getFileContentType(java.lang.String fext)
Returns a file's associated ContentType. If the file extension is unknown, the default content type will be returned and the extension added to it.

Parameters:
fext - The file extension. Is case insensitive, as it will be lower cased.
Returns:
The requested content type

addAgent

public IAgent addAgent(java.lang.String name,
                       java.lang.String classname,
                       long period)
Adds an IAgentimplementation that will work within the project's context. Remember to start agents calling startAgents(net.sourceforge.sconman.User)

Parameters:
id - The agent id. Must be unique among agents defined in the project
classname - The agent classname. Must implement IAgent
period - The periodicity, in miliseconds, for the agent execution
Returns:
The newly created agent

removeAgent

public void removeAgent(java.lang.String id)
Removes an agent from this project

Parameters:
id - The id of the agent to remove

getAgent

public IAgent getAgent(java.lang.String id)
Returns an agent

Parameters:
id - The agent id
Returns:
The requested agent

getAgents

public java.util.Collection getAgents()
Returns all the agents working on this project

Returns:
A collection of IAgentobjects

startAgents

public void startAgents(User actor)
                 throws SCMSecurityException
Starts the agent execution shedule. All the agents defined for this project will begin its execution and will be reexecuted acording to their periods.

Throws:
SCMSecurityException

stopAgents

public void stopAgents(User actor)
                throws SCMSecurityException
Stops the agent execution shedule

Throws:
SCMSecurityException

isRunningAgentManager

public boolean isRunningAgentManager()
Check if the agent execution shedule of the Project is running.

Returns:

getSecurityContext

public SecurityContext getSecurityContext()
Returns the SecurityContextthat handles Users, Roles, and permissions

Returns:
The SecurityContext

addContent

public void addContent(User actor,
                       java.io.File file,
                       IProgressObserver po)
                throws SCMStorageException,
                       SCMSecurityException
Adds a file or directory (all the files in the directory tree) to the project. The ContentTypeis extracted from the filename. This method is useful for non supervised content addition, as massive content addition from a filesystem.

Parameters:
actor - The user that performs the action
file - The file or directory to add. If it's a directory, every file in the directory and subdirectories will be added
po - The IProgressObserverthat is observing the operation progress, or null if no one observes it
Throws:
SCMStorageException
SCMSecurityException

getAllContents

public ISearchResults getAllContents()
                              throws SCMStorageException
Returns all the Contentstored in the project

Returns:
All the contents
Throws:
SCMStorageException - If there's a problem with the index

getContent

Content getContent(java.lang.String uri)
             throws SCMStorageException
Returns the specified content, given its URI

Parameters:
uri - The contents URI
Returns:
The selected content
Throws:
SCMStorageException - Thrown if there's an error retrieving the content

getProjectRoles

public java.util.Map getProjectRoles(User actor)

getContent

public Content getContent(User actor,
                          java.lang.String uri)
                   throws SCMStorageException,
                          SCMSecurityException
Returns the specified content, given its URI, checking user permissions

Parameters:
actor - The user that request the content
uri - The contents URI
Returns:
The selected content
Throws:
SCMStorageException - Thrown if there's a problem retrieving the content
SCMSecurityException - Thrown if the user cannot get the content

getRepositoryContent

Content getRepositoryContent(java.lang.String uri)
                       throws SCMStorageException
Reads a content from the repository, known its URI

Parameters:
uri -
Returns:
The readed content
Throws:
SCMStorageException

getRepositoryContent

public Content getRepositoryContent(User actor,
                                    java.lang.String uri)
                             throws SCMStorageException,
                                    SCMSecurityException
Reads a content from the repository, known its URI

Parameters:
actor - The user that looks up the content
uri - The content's URI
Returns:
Throws:
SCMStorageException
SCMSecurityException

search

ISearchResults search(Query query,
                      boolean visible)
                throws SCMStorageException
Return all the contents that match the query

Parameters:
query -
visible -
Returns:
Throws:
SCMStorageException

search

ISearchResults search(Query query,
                      boolean visible,
                      boolean reverseOrder)
                throws SCMStorageException
Return all the contents that match the query

Parameters:
query -
visible -
Returns:
Throws:
SCMStorageException

searchOld

ISearchResults searchOld(Query query)
                   throws SCMStorageException
Searches old contents (those whose toDate property is before today)

Parameters:
query -
Returns:
Throws:
SCMStorageException

searchFuture

ISearchResults searchFuture(Query query)
                      throws SCMStorageException
Searches old contents (those whose toDate property is before today)

Parameters:
query -
Returns:
Throws:
SCMStorageException

regenerateIndex

public void regenerateIndex(User user)
                     throws SCMSecurityException,
                            SCMStorageException
Regenerates index

Parameters:
user -
Throws:
SCMSecurityException
SCMStorageException

regenerateIndex

void regenerateIndex()
               throws SCMStorageException
Throws:
SCMStorageException

serializeXML

public void serializeXML(org.kxml2.io.KXmlSerializer out)
                  throws java.io.IOException
Description copied from interface: IXMLSerializable
Serialize to XML

Specified by:
serializeXML in interface IXMLSerializable
Overrides:
serializeXML in class Category
Parameters:
out - The KXmlSerializer to do the output
Throws:
java.io.IOException - Thrown if there's an IO problem

deserializeXML

public void deserializeXML(org.kxml2.io.KXmlParser in)
                    throws org.xmlpull.v1.XmlPullParserException,
                           java.io.IOException
Description copied from interface: IXMLSerializable
Deserialize from XML

Specified by:
deserializeXML in interface IXMLSerializable
Overrides:
deserializeXML in class Category
Parameters:
in - The KXml pull parser
Throws:
org.xmlpull.v1.XmlPullParserException - Thrown if there's an XML problem
java.io.IOException - Thrown if there's an IO problem


Copyright null null. All Rights Reserved.