fr.gouv.culture.sdx.application
Class Application

java.lang.Object
  extended by fr.gouv.culture.sdx.utils.AbstractSdxObject
      extended by fr.gouv.culture.sdx.application.Application
All Implemented Interfaces:
Describable, Encodable, Identifiable, Localizable, Saveable, SdxObject, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

public class Application
extends AbstractSdxObject
implements Saveable

An SDX application, from which searches can be done.

This class represents an SDX 2 application. There can be many applications within an SDX installation. The applications within the installation are referenced and managed by the Framework. The aim of an application is to make documents available and searchable.

An application is created from an XML configuration file. This file and all other files needed by the application must reside within one and only one directory hierarchy on the server. BTW, there is also a reference to the application in {TOMCAT_HOME}/webapps/sdx/WEB-INF/sdx/applications -pb This directory is called the base directory, a directory hierarchy, and must be directly within the SDX installation directory.

All files created by SDX regarding the management of an application and it's users and groups will be placed in subdirectories within the directory where the configuration file is located. it could look like this (for an application whose id is 'sdxworld') :

   -webapps
     -sdx
       -sdxworld
         -conf
           application.xconf
           -dbs (databases needed by SDX)
           -repos (repositories needed by SDX)
           -users
         index.xsp (or any valid 'welcome page')
         ...
         -xsl
           index.xsl
           ...

 

An application can be either public, private or restricted. A public application is searchable from other applications. A private application is not searchable from other applications. A restricted application may be searchable from other applications, if they qualify. Qualification is done from hosts and public ids. This could change in the future.

An appplication has four identification properties :

Other than basic properties, an application manages document bases, users and groups. It keeps track of the objects using Database objects and a filesystem store.

An application can also be used to search document bases within other applications.

After creating an Application object, you must remember to : 1) provide a super.getLog() 2) configure the application 3) initialize the application The methods are enableLogging(), configure() and init().


Nested Class Summary
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject
SdxObject.ConfigurationNode
 
Field Summary
static java.lang.String APP_CONFIG_FILENAME
          The configuration file name of an application.
static java.lang.String APPLICATION_CONFIGURATION_DIRECTORY
          The directory name where application configuration files reside.
static java.lang.String CLASS_NAME_SUFFIX
           
 java.lang.String DATABASES_DIR_NAME
          The name for the directory that contains the databases
static java.lang.String ELEMENT_NAME_USER_DOCUMENT_BASE
          The element used to define a user document base.
protected  int sessionObjectLimit
          The number of results and terms objects that will be stored in session before being subject our first-in first-out removal strategy
static java.lang.String USER_DATABASE_ID
          The *fixed* id of the user document base for this application.
static java.lang.String USER_DOCUMENT_BASE_ID
          The *fixed* id of the user document base for this application.
 
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized
 
Fields inherited from interface fr.gouv.culture.sdx.utils.save.Saveable
ALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM
 
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
DEFAULT_ENCODING
 
Constructor Summary
Application()
          Builds an application that must be configured afterwards.
 
Method Summary
 void addIdentity(Identity identity, java.lang.String password, Repository repository, IndexParameters params, org.xml.sax.ContentHandler handler)
          Adds a user or group to this application.
 void addMember(Group group, java.lang.String id)
          Adds a member to a group.
 void addMembers(Group group, java.lang.String[] ids)
          Adds members to a group.
 void backup(SaveParameters save_config)
          Save the application data objects
 boolean changePassword(java.lang.String username, java.lang.String oldPass, java.lang.String newPass)
           
 void checkIntegrity()
          Check the application integrity
 void checkIntegrity(java.lang.String dbId)
          Optimize an application's documentbase
 void checkIntegrity(java.lang.String[] dbIds)
          Optimize the application by optimizing the documentbases sent in the array
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          Sets the configuration options to build the application.
protected  void configureEntityCatalogs(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the entity catalogs of the application if needed.
protected  void configureFieldLists(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the fields lists of the application.
protected  void configureSessionObjectLimit(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the maximum number of objects should be store in session.
protected  void configureUserDocumentBase(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the SDX users document base if needed.
 void deleteIdentity(Identity identity)
          Removes an identity (user or group) from this application.
protected  java.lang.String getClassNameSuffix()
          Sub classes should element this method to return their class name suffix for SAX output
 java.lang.String getDataDirPath()
          Gets the path of the directory wich contains system datas (ie, databases, Lucene indexes, SDX user database, SDX thesaurus, etc.)
 java.lang.String getDefaultAdminGroupId()
          Returns the id of the default admin group.
 java.lang.String getDefaultAdminUserId()
          Returns the id of the default admin user.
 DocumentBase getDefaultDocumentBase()
          Gets the default DocumentBase for this application.
 DocumentBase getDocumentBase(java.lang.String dbId)
          Gets a DocumentBase in this application.
 java.util.Enumeration getDocumentBasesIds()
          Gets an enumeration of DocumentBase ids in this application.
 org.apache.avalon.framework.logger.Logger getLogger()
          Gets the application's super.getLog().
 java.lang.String[] getMembers(java.lang.String groupname)
          Returns the members of a group.
 java.util.Hashtable getParents(java.lang.String id)
          Returns the parents of an identity.
 java.lang.String getPath()
          Gets the name of the subdirectory in which this application's data resides.
 Repository getRepository(java.lang.String id)
          Gets a repository in this document base.
 Searchable getSearchable(java.lang.String id)
           
 int getSessionObjectLimit()
           
 org.apache.excalibur.source.SourceValidity getSourceValidity()
          Gets the source validity of the application.
 SDXThesaurus getThesaurus(java.lang.String id)
          Gets the SDXThesaurus of an application identified by its id.
 UserDatabase getUserDatabase()
          Return userDatabase for special usages, should be unuseful
 void getUserDocument(java.lang.String username, java.util.Hashtable groups, org.apache.cocoon.xml.XMLConsumer consumer)
          Returns the document where the user information is stored.
 UserInformation getUserInformation()
          Returns information about an anonymous user.
 UserInformation getUserInformation(java.lang.String username)
          Returns information about a user.
 void init()
          Initializes the application and makes the necessary data structures available.
protected  boolean initToSax()
          Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML
protected  void initVolatileObjectsToSax()
          Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called
 boolean isMember(Identity identity, java.lang.String groupName)
          Checks if an identity (user or group) belongs to a group.
 boolean isUsingSDXUserDatabase()
          Indicates if this application uses the internal SDX users database.
 void loadApplication(java.lang.String file_path)
          Load the application from a previous backup, restoring all functionnality If file path is null, get the most recent backup file found.
 void optimize()
          Optimize the application by optimizing all documentbases
 void optimize(java.lang.String dbId)
          Optimize an application's documentbase
 void optimize(java.lang.String[] dbIds)
          Optimize the application by optimizing the documentbases sent in the array
 void replaceMembers(Group group, java.lang.String[] ids)
          Replace members of a group.
 void restore(SaveParameters save_config)
          Restore the application data objects
 void restoreDocumentBases(SaveParameters save_config)
           
 void restoreThesauri(SaveParameters save_config)
           
 void saveApplication()
          Save the application for backup or quick deployment purpose
 boolean validateUser(java.lang.String username, java.lang.String password)
          Checks if a user and a plain text password match.
 
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_DOCUMENT_BASE_ID

public static final java.lang.String USER_DOCUMENT_BASE_ID
The *fixed* id of the user document base for this application.

See Also:
Constant Field Values

USER_DATABASE_ID

public static final java.lang.String USER_DATABASE_ID
The *fixed* id of the user document base for this application.

See Also:
Constant Field Values

APPLICATION_CONFIGURATION_DIRECTORY

public static final java.lang.String APPLICATION_CONFIGURATION_DIRECTORY
The directory name where application configuration files reside.

See Also:
Constant Field Values

APP_CONFIG_FILENAME

public static final java.lang.String APP_CONFIG_FILENAME
The configuration file name of an application.

See Also:
Constant Field Values

ELEMENT_NAME_USER_DOCUMENT_BASE

public static final java.lang.String ELEMENT_NAME_USER_DOCUMENT_BASE
The element used to define a user document base.

See Also:
Constant Field Values

DATABASES_DIR_NAME

public java.lang.String DATABASES_DIR_NAME
The name for the directory that contains the databases


sessionObjectLimit

protected int sessionObjectLimit
The number of results and terms objects that will be stored in session before being subject our first-in first-out removal strategy


CLASS_NAME_SUFFIX

public static final java.lang.String CLASS_NAME_SUFFIX
See Also:
Constant Field Values
Constructor Detail

Application

public Application()
Builds an application that must be configured afterwards.

Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Sets the configuration options to build the application.

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Overrides:
configure in class AbstractSdxObject
Parameters:
configuration - The configuration object, previously populated in FrameworkImpl, that will allow the application to configure itself.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
we should link to this in the future when we have better documentation capabilities

configureEntityCatalogs

protected void configureEntityCatalogs(org.apache.avalon.framework.configuration.Configuration configuration)
                                throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the entity catalogs of the application if needed. At this point, we could have a element from the configuration file wich contains sub-elements.

Parameters:
configuration -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureFieldLists

protected void configureFieldLists(org.apache.avalon.framework.configuration.Configuration configuration)
                            throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the fields lists of the application. At this point, we could have a element containing a list of fields lists identified by their @id. These fields lists could be used by the application's documents bases.

Parameters:
configuration -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureUserDocumentBase

protected void configureUserDocumentBase(org.apache.avalon.framework.configuration.Configuration configuration)
                                  throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the SDX users document base if needed. At this point, we could have a element.

Parameters:
configuration -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureSessionObjectLimit

protected void configureSessionObjectLimit(org.apache.avalon.framework.configuration.Configuration configuration)
Configures the maximum number of objects should be store in session. At this point, we could have an attribute sdx:application/@sessionObjectLimit

Parameters:
configuration -

init

public void init()
          throws SDXException,
                 org.apache.avalon.framework.configuration.ConfigurationException,
                 org.apache.avalon.framework.service.ServiceException,
                 org.apache.avalon.framework.context.ContextException
Initializes the application and makes the necessary data structures available.

Throws:
SDXException
org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.service.ServiceException
org.apache.avalon.framework.context.ContextException

getLogger

public org.apache.avalon.framework.logger.Logger getLogger()
Gets the application's super.getLog().

Returns:
The super.getLog().

getPath

public java.lang.String getPath()
Gets the name of the subdirectory in which this application's data resides.

Returns:
The path.

getDataDirPath

public java.lang.String getDataDirPath()
Gets the path of the directory wich contains system datas (ie, databases, Lucene indexes, SDX user database, SDX thesaurus, etc.) By default, it's the same path as the conf file path. This can be change with the sdx:application/@datadir attribute (cf. application.xconf)

Returns:
The path to the datadir

getRepository

public Repository getRepository(java.lang.String id)
                         throws SDXException
Gets a repository in this document base.

Parameters:
id - The repository's id, null for getting default repository
Returns:
The repository object
Throws:
SDXException

getDocumentBase

public DocumentBase getDocumentBase(java.lang.String dbId)
                             throws SDXException
Gets a DocumentBase in this application.

Parameters:
dbId - The documentBase's id.
Returns:
The documentBase object.
Throws:
SDXException

getDocumentBasesIds

public java.util.Enumeration getDocumentBasesIds()
Gets an enumeration of DocumentBase ids in this application. used to display information and open functionality for this application.

Returns:
The Enumeration of documentBase object.

getDefaultDocumentBase

public DocumentBase getDefaultDocumentBase()
Gets the default DocumentBase for this application.

Returns:
The default documentBase, null if there is no default document base.

getThesaurus

public SDXThesaurus getThesaurus(java.lang.String id)
                          throws SDXException
Gets the SDXThesaurus of an application identified by its id.

Parameters:
id - The id of the SDXThesaurus
Returns:
SDXThesaurus
Throws:
SDXException

getSearchable

public Searchable getSearchable(java.lang.String id)

isUsingSDXUserDatabase

public boolean isUsingSDXUserDatabase()
Indicates if this application uses the internal SDX users database.


getUserDatabase

public UserDatabase getUserDatabase()
Return userDatabase for special usages, should be unuseful


getDefaultAdminGroupId

public java.lang.String getDefaultAdminGroupId()
Returns the id of the default admin group. The id will be null if the group has been deleted from the application after start-up


getDefaultAdminUserId

public java.lang.String getDefaultAdminUserId()
Returns the id of the default admin user. The id will be null if the user has been deleted from the application after start-up.


addMember

public void addMember(Group group,
                      java.lang.String id)
               throws SDXException
Adds a member to a group. The member should be in the database.

Parameters:
group - The group.
id - Id of an identity to add as a member.
Throws:
SDXException

addMembers

public void addMembers(Group group,
                       java.lang.String[] ids)
                throws SDXException
Adds members to a group. The members should be in the database.

Parameters:
group - The group.
ids - Array of ids to add as a member.
Throws:
SDXException

replaceMembers

public void replaceMembers(Group group,
                           java.lang.String[] ids)
                    throws SDXException
Replace members of a group. All members are deleted before add the ids.

Parameters:
group - The group.
ids - Array of ids to add as a member.
Throws:
SDXException

getParents

public java.util.Hashtable getParents(java.lang.String id)
                               throws SDXException
Returns the parents of an identity.

Parameters:
id - name of the user (or the group).
Returns:
A Hashtable of group object by id.
Throws:
SDXException

getMembers

public java.lang.String[] getMembers(java.lang.String groupname)
                              throws SDXException
Returns the members of a group.

Parameters:
groupname - The groupname.
Returns:
An array of strings containing the names of the members (users or groups) belonging to the group; the values are also the group name.
Throws:
SDXException

addIdentity

public void addIdentity(Identity identity,
                        java.lang.String password,
                        Repository repository,
                        IndexParameters params,
                        org.xml.sax.ContentHandler handler)
                 throws SDXException,
                        org.xml.sax.SAXException,
                        org.apache.cocoon.ProcessingException
Adds a user or group to this application.

Parameters:
identity - The user or group.
password - The unencoded password given to this user (may be null).
repository - The repository where the user document is stored (if null, default repository will be used).
params - The parameters of this adding process (may be null).
handler - A content handler where information on the adding process will be sent (may be null).
Throws:
SDXException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

changePassword

public boolean changePassword(java.lang.String username,
                              java.lang.String oldPass,
                              java.lang.String newPass)
                       throws SDXException
Throws:
SDXException

deleteIdentity

public void deleteIdentity(Identity identity)
                    throws SDXException
Removes an identity (user or group) from this application.

Parameters:
identity - The identity to remove (only it's name is needed).
Throws:
SDXException

validateUser

public boolean validateUser(java.lang.String username,
                            java.lang.String password)
                     throws SDXException
Checks if a user and a plain text password match.

If the password is null, there is a match if no password has been given to the user. If the password is an empty string, then an empty string must have been given as a password for this user at creation time.

Otherwise, there is a match if the password exactly matches (including case) the user password.

Parameters:
username - The username to check.
password - The password to check (may be null).
Throws:
SDXException

isMember

public boolean isMember(Identity identity,
                        java.lang.String groupName)
                 throws SDXException
Checks if an identity (user or group) belongs to a group.

Parameters:
identity - The username to check.
groupName - The password to check (may be null).
Throws:
SDXException

getUserInformation

public UserInformation getUserInformation(java.lang.String username)
                                   throws SDXException
Returns information about a user.

Parameters:
username - The username (if null, anonymous user information is returned).
Returns:
The UserInformation object.
Throws:
SDXException

getUserInformation

public UserInformation getUserInformation()
                                   throws SDXException
Returns information about an anonymous user.

Throws:
SDXException

getUserDocument

public void getUserDocument(java.lang.String username,
                            java.util.Hashtable groups,
                            org.apache.cocoon.xml.XMLConsumer consumer)
                     throws SDXException
Returns the document where the user information is stored.

Parameters:
username - The username (if null, anonymous user information will be sent).
groups - The groups the user belongs to (may be null).
consumer - The XMLconsumer to feed with the information.
Throws:
SDXException

getSessionObjectLimit

public int getSessionObjectLimit()

getClassNameSuffix

protected java.lang.String getClassNameSuffix()
Description copied from class: AbstractSdxObject
Sub classes should element this method to return their class name suffix for SAX output

Specified by:
getClassNameSuffix in class AbstractSdxObject

initToSax

protected boolean initToSax()
Description copied from class: AbstractSdxObject
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML

Specified by:
initToSax in class AbstractSdxObject

initVolatileObjectsToSax

protected void initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called

Specified by:
initVolatileObjectsToSax in class AbstractSdxObject

optimize

public void optimize()
Optimize the application by optimizing all documentbases


optimize

public void optimize(java.lang.String[] dbIds)
Optimize the application by optimizing the documentbases sent in the array


optimize

public void optimize(java.lang.String dbId)
Optimize an application's documentbase


checkIntegrity

public void checkIntegrity()
Check the application integrity


checkIntegrity

public void checkIntegrity(java.lang.String[] dbIds)
Optimize the application by optimizing the documentbases sent in the array


checkIntegrity

public void checkIntegrity(java.lang.String dbId)
Optimize an application's documentbase


saveApplication

public void saveApplication()
Save the application for backup or quick deployment purpose


loadApplication

public void loadApplication(java.lang.String file_path)
                     throws SDXException
Load the application from a previous backup, restoring all functionnality If file path is null, get the most recent backup file found.

Throws:
SDXException

backup

public void backup(SaveParameters save_config)
            throws SDXException
Save the application data objects

Specified by:
backup in interface Saveable
Throws:
SDXException
See Also:
Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)

restore

public void restore(SaveParameters save_config)
             throws SDXException
Restore the application data objects

Specified by:
restore in interface Saveable
Throws:
SDXException
See Also:
Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)

restoreDocumentBases

public void restoreDocumentBases(SaveParameters save_config)
                          throws SDXException
Throws:
SDXException

restoreThesauri

public void restoreThesauri(SaveParameters save_config)
                     throws SDXException
Throws:
SDXException

getSourceValidity

public org.apache.excalibur.source.SourceValidity getSourceValidity()
Gets the source validity of the application. Commonly used with Cocoon to cache data.

Returns:
SourceValidity


Copyright © 2000-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.