fr.gouv.culture.sdx.application
Class Application

java.lang.Object
  extended byfr.gouv.culture.sdx.application.Application
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.cocoon.xml.XMLizable

public class Application
extends java.lang.Object
implements org.apache.cocoon.xml.XMLizable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.context.Contextualizable

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 logger 2) configure the application 3) initialize the application The methods are enableLogging(), configure() and init().


Field Summary
static java.lang.String APPLICATION_FIELD_LISTS
          String representation for a key in the Properties object : application-level repositories.
static java.lang.String APPLICATION_ID
          String representation for a key in the Properties object : application's id.
static java.lang.String APPLICATION_REPOSITORIES
          String representation for a key in the Properties object : application-level repositories.
 java.lang.String DATABASES_DIR_NAME
          The name for the directory that contains the databases
static java.lang.String DEFAULT_DATABASE_CONF
          The key name for the default database type this application in the "props" object.
static java.lang.String DOCUMENTBASES_DIR_PATH
          String representation for a key in the Properties object : directory for the location of the DBs.
static java.lang.String ELEMENT_NAME_USER_DOCUMENT_BASE
          The element used to define a user document base.
static java.lang.String HSQL_DATABASE
          The key name for the potention hsql db of this application in the "props" object.
static java.lang.String REPOSITORIES_DIR_PATH
          String representation for a key in the Properties object : directory for the location of the repositories.
static java.lang.String SDX_DATABASE_DIR_PATH
          The key name for the database directory of this application in the "props" object.
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 THESAURI_DIR_PATH
          String representation for a key in the Properties object : directory for the location of the thesauri.
static java.lang.String USER_DOCUMENT_BASE_ID
          The *fixed* id of the user document base for this application.
static java.lang.String USERS_DIR_PATH
          String representation for a key in the Properties object : directory for the location of the users info.
static java.lang.String USERS_DOCUMENTBASE_DIR_PATH
          String representation for a key in the Properties object : directory for the location of the users' documents.
 
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.
 boolean changePassword(java.lang.String username, java.lang.String oldPass, java.lang.String newPass)
           
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
          Sets the application ComponentManager.
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          Sets the configuration options to build the application.
protected  void configureFieldLists(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  void configureSessionObjectLimit(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  void configureUserDocumentBase(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void contextualize(org.apache.avalon.framework.context.Context context)
          Contextualize this class.
 void deleteIdentity(Identity identity)
          Removes an identity (user or group) from this application.
 void enableLogging(org.apache.avalon.framework.logger.Logger logger)
          Sets the logger for this application.
 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.
 java.lang.String getId()
          Gets the id of this application.
 java.util.Locale getLocale()
          Returns the locale for the application
 org.apache.avalon.framework.logger.Logger getLogger()
          Gets the application's logger.
 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()
           
 SDXThesaurus getThesaurus(java.lang.String 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.
 java.lang.String getXmlLang()
          Returns the xml:lang attibute value from the configuration
 void init()
          Initializes the application and makes the necessary data structures available.
 boolean isMember(Identity identity, java.lang.String groupName)
          Checks if an identity (user or group) belongs to a group.
 void replaceMembers(Group group, java.lang.String[] ids)
          Replace members of a group.
 void setProperties(java.util.Hashtable props)
          Sets the properties object.
 void toSAX(org.xml.sax.ContentHandler handler)
          Could send an XML representation of something, but currently has no function.
 boolean validateUser(java.lang.String username, java.lang.String password)
          Checks if a user and a plain text password match.
 
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

APPLICATION_ID

public static final java.lang.String APPLICATION_ID
String representation for a key in the Properties object : application's id.

See Also:
Constant Field Values

APPLICATION_REPOSITORIES

public static final java.lang.String APPLICATION_REPOSITORIES
String representation for a key in the Properties object : application-level repositories.

See Also:
Constant Field Values

APPLICATION_FIELD_LISTS

public static final java.lang.String APPLICATION_FIELD_LISTS
String representation for a key in the Properties object : application-level repositories.

See Also:
Constant Field Values

DOCUMENTBASES_DIR_PATH

public static final java.lang.String DOCUMENTBASES_DIR_PATH
String representation for a key in the Properties object : directory for the location of the DBs.

See Also:
Constant Field Values

REPOSITORIES_DIR_PATH

public static final java.lang.String REPOSITORIES_DIR_PATH
String representation for a key in the Properties object : directory for the location of the repositories.

See Also:
Constant Field Values

USERS_DIR_PATH

public static final java.lang.String USERS_DIR_PATH
String representation for a key in the Properties object : directory for the location of the users info.

See Also:
Constant Field Values

USERS_DOCUMENTBASE_DIR_PATH

public static final java.lang.String USERS_DOCUMENTBASE_DIR_PATH
String representation for a key in the Properties object : directory for the location of the users' documents.

See Also:
Constant Field Values

THESAURI_DIR_PATH

public static final java.lang.String THESAURI_DIR_PATH
String representation for a key in the Properties object : directory for the location of the thesauri.

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

DEFAULT_DATABASE_CONF

public static final java.lang.String DEFAULT_DATABASE_CONF
The key name for the default database type this application in the "props" object.

See Also:
Constant Field Values

SDX_DATABASE_DIR_PATH

public static final java.lang.String SDX_DATABASE_DIR_PATH
The key name for the database directory of this application in the "props" object.

See Also:
Constant Field Values

HSQL_DATABASE

public static final java.lang.String HSQL_DATABASE
The key name for the potention hsql db of this application in the "props" object.

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

Constructor Detail

Application

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

Method Detail

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
Sets the logger for this application.

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
Parameters:
logger - The logger.

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Contextualize this class.

Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Parameters:
context - The context provided by Cocoon.
Throws:
org.apache.avalon.framework.context.ContextException

compose

public void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
             throws org.apache.avalon.framework.component.ComponentException
Sets the application ComponentManager.

Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Parameters:
componentManager - The componentManager. Provided by the framework component.
Throws:
org.apache.avalon.framework.component.ComponentException

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
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

configureFieldLists

protected void configureFieldLists(org.apache.avalon.framework.configuration.Configuration configuration)
                            throws org.apache.avalon.framework.configuration.ConfigurationException
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
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

configureSessionObjectLimit

protected void configureSessionObjectLimit(org.apache.avalon.framework.configuration.Configuration configuration)

init

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

Throws:
SDXException
org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.component.ComponentException

setProperties

public void setProperties(java.util.Hashtable props)
Sets the properties object.

Parameters:
props - The properties.

getLogger

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

Returns:
The logger.

getId

public java.lang.String getId()
Gets the id of this application.

Returns:
The id.

getPath

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

Returns:
The path.

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.

getXmlLang

public java.lang.String getXmlLang()
Returns the xml:lang attibute value from the configuration


getLocale

public java.util.Locale getLocale()
Returns the locale for the application


getThesaurus

public SDXThesaurus getThesaurus(java.lang.String id)
                          throws SDXException
Throws:
SDXException

getSearchable

public Searchable getSearchable(java.lang.String id)

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

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

toSAX

public void toSAX(org.xml.sax.ContentHandler handler)
           throws org.xml.sax.SAXException,
                  org.apache.cocoon.ProcessingException
Could send an XML representation of something, but currently has no function.

Specified by:
toSAX in interface org.apache.cocoon.xml.XMLizable
Parameters:
handler - A SAX content handler to feed with events.
Throws:
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

getSessionObjectLimit

public int getSessionObjectLimit()


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