Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.directory.ejb
Class DirectoryManagerBean

java.lang.Object
  extended by org.nuxeo.ecm.platform.directory.ejb.DirectoryManagerBean
All Implemented Interfaces:
DirectoryManager, DirectoryService, DirectoryManagerLocal

public class DirectoryManagerBean
extends java.lang.Object
implements DirectoryManagerLocal

Facade Bean provide Remoting API for DirectoryService

Author:
George Lefter, Olivier Grisel

Field Summary
 
Fields inherited from interface org.nuxeo.ecm.directory.api.DirectoryService
NAME
 
Constructor Summary
DirectoryManagerBean()
           
 
Method Summary
 boolean authenticate(long sessionId, java.lang.String username, java.lang.String password)
          Checks that the credentials provided by the UserManager match those registered in the directory.
 void close(long sessionId)
          Closes the session and all open result sets obtained from this session.
 void commit(long sessionId)
          Commits any changes on this session.
 DocumentModel createEntry(long sessionId, DocumentModel entry)
          Creates an entry in a directory.
 DocumentModel createEntry(long sessionId, java.util.Map<java.lang.String,java.lang.Object> map)
          Creates an entry in a directory.
 void deleteEntry(long sessionId, DocumentModel docModel)
          Deletes a directory entry.
 void deleteEntry(long sessionId, java.lang.String id)
          Deletes a directory entry by id.
 void deleteEntry(long sessionId, java.lang.String id, java.util.Map<java.lang.String,java.lang.String> map)
          Deletes a directory entry by id and secondary ids.
 java.util.List<Directory> getDirectories()
           
 Directory getDirectory(java.lang.String name)
           
 java.lang.String getDirectoryIdField(java.lang.String directoryName)
           
 java.util.List<java.lang.String> getDirectoryNames()
           
 java.lang.String getDirectoryPasswordField(java.lang.String directoryName)
           
 java.lang.String getDirectorySchema(java.lang.String directoryName)
           
 DocumentModelList getEntries(long sessionId)
          Retrieves all the entries in the directory.
 DocumentModel getEntry(long sessionId, java.lang.String id)
          Retrieves a directory entry using its id.
 DocumentModel getEntry(long sessionId, java.lang.String id, boolean fetchReferences)
          Retrieves a directory entry using its id.
 java.lang.String getIdField(long sessionId)
          The Id field is the name of the field that is used a primary key: unique and not null value in the whole directory.
 java.lang.String getParentDirectoryName(java.lang.String directoryName)
          Returns the name of the parent directory of specified directory, if applicable.
 java.lang.String getPasswordField(long sessionId)
           
 java.util.List<java.lang.String> getProjection(long sessionId, java.util.Map<java.lang.String,java.io.Serializable> filter, java.util.Set<java.lang.String> fulltext, java.lang.String columnName)
           
 java.util.List<java.lang.String> getProjection(long sessionId, java.util.Map<java.lang.String,java.io.Serializable> filter, java.lang.String columnName)
          Executes a query using filter and return only the column columnName.
 boolean hasEntry(long sessionId, java.lang.String id)
          Returns true if session has an entry with given id.
 void initialize()
           
 boolean isAuthenticating(long sessionId)
          Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).
 boolean isReadOnly(long sessionId)
           
 Session open(java.lang.String directoryName)
          Opens a session on specified directory.
 DocumentModelList query(long sessionId, java.util.Map<java.lang.String,java.io.Serializable> filter)
          Executes a simple query.
 DocumentModelList query(long sessionId, java.util.Map<java.lang.String,java.io.Serializable> filter, java.util.Set<java.lang.String> fulltext)
          Executes a simple query.
 DocumentModelList query(long sessionId, java.util.Map<java.lang.String,java.io.Serializable> filter, java.util.Set<java.lang.String> fulltext, java.util.Map<java.lang.String,java.lang.String> orderBy)
          Executes a simple query.
 DocumentModelList query(long sessionId, java.util.Map<java.lang.String,java.io.Serializable> filter, java.util.Set<java.lang.String> fulltext, java.util.Map<java.lang.String,java.lang.String> orderBy, boolean fetchReferences)
           
 void registerDirectory(java.lang.String directoryName, DirectoryFactory factory)
           
 void rollback(long sessionId)
          Rollbacks any changes on this session.
 void unregisterDirectory(java.lang.String directoryName, DirectoryFactory factory)
           
 void updateEntry(long sessionId, DocumentModel docModel)
          Updates a directory entry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryManagerBean

public DirectoryManagerBean()
Method Detail

initialize

@PostConstruct
public void initialize()

authenticate

public boolean authenticate(long sessionId,
                            java.lang.String username,
                            java.lang.String password)
                     throws DirectoryException
Description copied from interface: DirectoryManager
Checks that the credentials provided by the UserManager match those registered in the directory. If username is not in the directory, this should return false instead of throrwing an exception.

Specified by:
authenticate in interface DirectoryManager
Returns:
true is the credentials match those stored in the directory
Throws:
DirectoryException

close

public void close(long sessionId)
           throws DirectoryException
Description copied from interface: DirectoryManager
Closes the session and all open result sets obtained from this session.

Releases this Connection object's resources immediately instead of waiting for them to be automatically released.

TODO: should this operation auto-commit pending changes?

Specified by:
close in interface DirectoryManager
Throws:
DirectoryException - if a communication error occurs

commit

public void commit(long sessionId)
            throws DirectoryException
Description copied from interface: DirectoryManager
Commits any changes on this session.

Specified by:
commit in interface DirectoryManager
Throws:
DirectoryException - if a communication error occurs

In this case the session will be automatically rollbacked


createEntry

public DocumentModel createEntry(long sessionId,
                                 java.util.Map<java.lang.String,java.lang.Object> map)
                          throws DirectoryException
Description copied from interface: DirectoryManager
Creates an entry in a directory.

Specified by:
createEntry in interface DirectoryManager
map - A map with keys and values that should be stored in a directory

Note: The values in the map should be of type String

Returns:
The new entry created in the directory
Throws:
DirectoryException - if a communication exception occurs or if an entry with the same id already exists.

deleteEntry

public void deleteEntry(long sessionId,
                        DocumentModel docModel)
                 throws DirectoryException
Description copied from interface: DirectoryManager
Deletes a directory entry.

Specified by:
deleteEntry in interface DirectoryManager
docModel - The entry to delete
Throws:
DirectoryException - if a communication error occurs

deleteEntry

public void deleteEntry(long sessionId,
                        java.lang.String id)
                 throws DirectoryException
Description copied from interface: DirectoryManager
Deletes a directory entry by id.

Specified by:
deleteEntry in interface DirectoryManager
id - the id of the entry to delete
Throws:
DirectoryException - if a communication error occurs

deleteEntry

public void deleteEntry(long sessionId,
                        java.lang.String id,
                        java.util.Map<java.lang.String,java.lang.String> map)
                 throws DirectoryException
Description copied from interface: DirectoryManager
Deletes a directory entry by id and secondary ids.

This is used for hierarchical vocabularies, where the actual unique key is the couple (parent, id).

Specified by:
deleteEntry in interface DirectoryManager
Parameters:
sessionId - the session id.
id - the id of the entry to delete.
map - a map of seconday key values.
Throws:
DirectoryException - if a communication error occurs.

getEntries

public DocumentModelList getEntries(long sessionId)
                             throws DirectoryException
Description copied from interface: DirectoryManager
Retrieves all the entries in the directory.

Specified by:
getEntries in interface DirectoryManager
Returns:
a collection with all the entries in the directory
Throws:
DirectoryException
SizeLimitExceededException - if the number of results is larger than the limit configured for the directory

getEntry

public DocumentModel getEntry(long sessionId,
                              java.lang.String id)
                       throws DirectoryException
Description copied from interface: DirectoryManager
Retrieves a directory entry using its id.

TODO what happens when the entry is not found? return null if not found?

Specified by:
getEntry in interface DirectoryManager
id - the entry id
Returns:
a DocumentModel representing the entry
Throws:
DirectoryException

getEntry

public DocumentModel getEntry(long sessionId,
                              java.lang.String id,
                              boolean fetchReferences)
                       throws DirectoryException
Description copied from interface: DirectoryManager
Retrieves a directory entry using its id.

Specified by:
getEntry in interface DirectoryManager
id - the entry id
fetchReferences - boolean stating if references have to be fetched
Returns:
a DocumentModel representing the entry
Throws:
DirectoryException
See Also:
DirectoryManager.getEntry(long, String)

getIdField

public java.lang.String getIdField(long sessionId)
                            throws DirectoryException
Description copied from interface: DirectoryManager
The Id field is the name of the field that is used a primary key: unique and not null value in the whole directory. This field is also used as login field if the directory is authenticating.

Specified by:
getIdField in interface DirectoryManager
Returns:
the name of the id field
Throws:
DirectoryException

getPasswordField

public java.lang.String getPasswordField(long sessionId)
                                  throws DirectoryException
Specified by:
getPasswordField in interface DirectoryManager
Returns:
the name of the field to store the password if the directory is authenticating (can be null)
Throws:
DirectoryException

getProjection

public java.util.List<java.lang.String> getProjection(long sessionId,
                                                      java.util.Map<java.lang.String,java.io.Serializable> filter,
                                                      java.lang.String columnName)
                                               throws DirectoryException
Description copied from interface: DirectoryManager
Executes a query using filter and return only the column columnName.

Specified by:
getProjection in interface DirectoryManager
filter - the filter for the query
columnName - the column whose content should be returned
Returns:
the list with the values of columnName for the entries matching filter
Throws:
DirectoryException
SizeLimitExceededException - if the number of results is larger than the limit configured for the directory

getProjection

public java.util.List<java.lang.String> getProjection(long sessionId,
                                                      java.util.Map<java.lang.String,java.io.Serializable> filter,
                                                      java.util.Set<java.lang.String> fulltext,
                                                      java.lang.String columnName)
                                               throws DirectoryException
Specified by:
getProjection in interface DirectoryManager
Throws:
DirectoryException

isAuthenticating

public boolean isAuthenticating(long sessionId)
                         throws DirectoryException
Description copied from interface: DirectoryManager
Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).

Specified by:
isAuthenticating in interface DirectoryManager
Returns:
true is the directory is authentication aware
Throws:
DirectoryException

isReadOnly

public boolean isReadOnly(long sessionId)
                   throws DirectoryException
Specified by:
isReadOnly in interface DirectoryManager
Throws:
DirectoryException

query

public DocumentModelList query(long sessionId,
                               java.util.Map<java.lang.String,java.io.Serializable> filter)
                        throws DirectoryException
Description copied from interface: DirectoryManager
Executes a simple query. The conditions will be 'AND'-ed. Search is done with exact match.

Specified by:
query in interface DirectoryManager
filter - a filter to apply to entries in directory
Returns:
a list of document models containing the entries matched by the query
Throws:
DirectoryException - if a communication error occurs
SizeLimitExceededException - if the number of results is larger than the limit configured for the directory

query

public DocumentModelList query(long sessionId,
                               java.util.Map<java.lang.String,java.io.Serializable> filter,
                               java.util.Set<java.lang.String> fulltext)
                        throws DirectoryException
Description copied from interface: DirectoryManager
Executes a simple query. The conditions will be 'AND'-ed.

fieldNames present in the fulltext set are treated as a fulltext match.

Specified by:
query in interface DirectoryManager
filter - a filter to apply to entries in directory
fulltext - a set of field that should be treated as a fulltext search
Returns:
a list of document models containing the entries matched by the query
Throws:
DirectoryException - if a communication error occurs
SizeLimitExceededException - if the number of results is larger than the limit configured for the directory

query

public DocumentModelList query(long sessionId,
                               java.util.Map<java.lang.String,java.io.Serializable> filter,
                               java.util.Set<java.lang.String> fulltext,
                               java.util.Map<java.lang.String,java.lang.String> orderBy)
                        throws DirectoryException
Description copied from interface: DirectoryManager
Executes a simple query. The conditions will be 'AND'-ed and the result will be sorted by the orderBy criteria list.

fieldNames present in the fulltext set are treated as a fulltext match.

Specified by:
query in interface DirectoryManager
filter - a filter to apply to entries in directory
fulltext - a set of field that should be treated as a fulltext search
orderBy - a LinkedHashMap with the 'order by' criterias.The key of an entry of this map represents the column name and the value of the same entry represent the column order,which may be 'asc' or 'desc'.
Returns:
a list of document models containing the entries matched by the query
Throws:
DirectoryException - if a communication error occurs
SizeLimitExceededException - if the number of results is larger than the limit configured for the directory

query

public DocumentModelList query(long sessionId,
                               java.util.Map<java.lang.String,java.io.Serializable> filter,
                               java.util.Set<java.lang.String> fulltext,
                               java.util.Map<java.lang.String,java.lang.String> orderBy,
                               boolean fetchReferences)
                        throws DirectoryException
Specified by:
query in interface DirectoryManager
Throws:
DirectoryException

rollback

public void rollback(long sessionId)
              throws DirectoryException
Description copied from interface: DirectoryManager
Rollbacks any changes on this session.

Specified by:
rollback in interface DirectoryManager
Throws:
DirectoryException - if a communication error occurs

In this case, the session will be automatically rollbacked anyway


updateEntry

public void updateEntry(long sessionId,
                        DocumentModel docModel)
                 throws DirectoryException
Description copied from interface: DirectoryManager
Updates a directory entry.

Specified by:
updateEntry in interface DirectoryManager
docModel - The entry to update
Throws:
DirectoryException - if a communication error occurs

getDirectoryNames

public java.util.List<java.lang.String> getDirectoryNames()
                                                   throws DirectoryException
Specified by:
getDirectoryNames in interface DirectoryService
Throws:
DirectoryException

getDirectorySchema

public java.lang.String getDirectorySchema(java.lang.String directoryName)
                                    throws DirectoryException
Specified by:
getDirectorySchema in interface DirectoryService
Throws:
DirectoryException

open

public Session open(java.lang.String directoryName)
             throws DirectoryException
Description copied from interface: DirectoryService
Opens a session on specified directory.

This method prefers to throw rather than returning null.

Specified by:
open in interface DirectoryService
Returns:
the session
Throws:
DirectoryException - in case the session cannot be created

getDirectory

public Directory getDirectory(java.lang.String name)
                       throws DirectoryException
Specified by:
getDirectory in interface DirectoryService
Throws:
DirectoryException

getDirectories

public java.util.List<Directory> getDirectories()
                                         throws DirectoryException
Specified by:
getDirectories in interface DirectoryService
Throws:
DirectoryException

getDirectoryIdField

public java.lang.String getDirectoryIdField(java.lang.String directoryName)
                                     throws DirectoryException
Specified by:
getDirectoryIdField in interface DirectoryService
Throws:
DirectoryException

getDirectoryPasswordField

public java.lang.String getDirectoryPasswordField(java.lang.String directoryName)
                                           throws DirectoryException
Specified by:
getDirectoryPasswordField in interface DirectoryService
Throws:
DirectoryException

registerDirectory

public void registerDirectory(java.lang.String directoryName,
                              DirectoryFactory factory)
Specified by:
registerDirectory in interface DirectoryService

unregisterDirectory

public void unregisterDirectory(java.lang.String directoryName,
                                DirectoryFactory factory)
Specified by:
unregisterDirectory in interface DirectoryService

getParentDirectoryName

public java.lang.String getParentDirectoryName(java.lang.String directoryName)
                                        throws DirectoryException
Description copied from interface: DirectoryService
Returns the name of the parent directory of specified directory, if applicable.

Specified by:
getParentDirectoryName in interface DirectoryService
Returns:
the name, or null
Throws:
DirectoryException

createEntry

public DocumentModel createEntry(long sessionId,
                                 DocumentModel entry)
                          throws DirectoryException
Description copied from interface: DirectoryManager
Creates an entry in a directory.

Specified by:
createEntry in interface DirectoryManager
entry - the document model representing the entry to create
Returns:
The new entry created in the directory
Throws:
DirectoryException - if a communication exception occurs or if an entry with the same id already exists.

hasEntry

public boolean hasEntry(long sessionId,
                        java.lang.String id)
                 throws DirectoryException
Description copied from interface: DirectoryManager
Returns true if session has an entry with given id.

Specified by:
hasEntry in interface DirectoryManager
Throws:
DirectoryException

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.