org.sakaiproject.component.legacy.user
Class BaseUserDirectoryService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.user.BaseUserDirectoryService
All Implemented Interfaces:
EntityProducer, StorageUser, UserDirectoryService, UserFactory
Direct Known Subclasses:
DbUserService

public abstract class BaseUserDirectoryService
extends Object
implements UserDirectoryService, StorageUser, UserFactory

BaseUserDirectoryService is a Sakai user directory services implementation.

Version:
$Revision: 6016 $
Author:
University of Michigan, Sakai Software Development Team
See Also:
org.chefproject.core.User

Nested Class Summary
 class BaseUserDirectoryService.BaseUserEdit
          BaseUserEdit is an implementation of the CHEF UserEdit object.
protected static interface BaseUserDirectoryService.Storage
          Storage
 
Nested classes inherited from class org.sakaiproject.service.legacy.entity.EntityProducer
EntityProducer.ChangeType
 
Field Summary
protected  User m_anon
          An anon. user.
protected  int m_cacheCleanerSeconds
          The # seconds to cache gets. 0 disables the cache.
protected  int m_cacheSeconds
          The # seconds to cache gets. 0 disables the cache.
protected  Cache m_callCache
          A cache of calls to the service and the results.
protected  boolean m_caseSensitiveId
          Configuration: case sensitive user id.
protected  String M_curUserKey
          Key for current service caching of current user
protected  EntityManager m_entityManager
          Dependency: EntityManager.
protected  Logger m_logger
          Dependency: logging service
protected  UserDirectoryProvider m_provider
          A user directory provider.
protected  String m_relativeAccessPoint
          The initial portion of a relative access point URL.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  BaseUserDirectoryService.Storage m_storage
          Storage manager for this service.
 
Fields inherited from interface org.sakaiproject.service.legacy.user.UserDirectoryService
REFERENCE_ROOT, SECURE_ADD_USER, SECURE_REMOVE_USER, SECURE_UPDATE_USER_ANY, SECURE_UPDATE_USER_OWN, SERVICE_NAME
 
Constructor Summary
BaseUserDirectoryService()
           
 
Method Summary
protected  void addLiveProperties(BaseUserDirectoryService.BaseUserEdit edit)
          Create the live properties for the user.
protected  void addLiveUpdateProperties(BaseUserDirectoryService.BaseUserEdit edit)
          Update the live properties for a user for when modified.
 UserEdit addUser(String id)
          Add a new user to the directory.
 User addUser(String id, String firstName, String lastName, String email, String pw, String type, ResourceProperties properties)
          Add a new user to the directory, complete in one operation.
 boolean allowAddUser(String id)
          check permissions for addUser().
 boolean allowRemoveUser(String id)
          check permissions for removeUser().
 boolean allowUpdateUser(String id)
          check permissions for updating a user (i.s. using getUserEditClone() and calling commitEditClone())
 String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
          Archive the resources for the given site.
 User authenticate(String eid, String password)
          Authenticate a user / password.
protected  boolean authenticateViaProvider(String id, UserEdit user, String password)
          Authenticate user by provider information
 void cancelEdit(UserEdit user)
          Cancel the changes made to a UserEdit object, and release the lock.
protected  String cleanId(String id)
          Adjust the id - trim it to null, and lower case IF we are case insensitive.
 void commitEdit(UserEdit user)
          Commit the changes made to a UserEdit object, and release the lock.
 int countSearchUsers(String criteria)
          Count all the users that match this criteria in id or target, first or last name.
 int countUsers()
          Count all the users.
 void destroy()
          Returns to uninitialized state.
 void destroyAuthentication()
          Remove authentication for the current user.
 UserEdit editUser(String id)
          Get a locked user object for editing.
protected  BaseUserDirectoryService.BaseUserEdit findUser(String id)
          Find the user object, in cache or storage (only - no provider check).
protected  BaseUserDirectoryService.BaseUserEdit findUserByEid(String eid)
          Find the user object, by the eid (not id) in cache or storage (only - no provider check).
 Collection findUsersByEmail(String email)
          Find the user objects which have this email address.
protected  String getAccessPoint(boolean relative)
          Access the partial URL that forms the root of resource URLs.
 User getAnonymousUser()
          Access the anonymous user object.
 User getCurrentUser()
          Access the user object associated with the "current" request.
 Time getDate(Entity r)
          Access the resource date.
 Entity getEntity(Reference ref)
          Access the referenced Entity - the entity will belong to the service.
 Collection getEntityAuthzGroups(Reference ref)
          Access a collection of authorization group ids for security on the for the referenced entity - the entity will belong to the service.
 String getEntityDescription(Reference ref)
          Create an entity description for the entity referenced - the entity will belong to the service.
 ResourceProperties getEntityResourceProperties(Reference ref)
          Access the resource properties for the referenced entity - the entity will belong to the service.
 String getEntityUrl(Reference ref)
          Access a URL for the referenced entity - the entity will belong to the service.
 HttpAccess getHttpAccess()
          Get the HttpAccess object that supports entity access via the access servlet for my entities.
 String getLabel()
          
 String getOwnerId(Entity r)
          Access the resource owner user id.
 User getUser(String id)
          Access a user object.
 User getUserByEid(String eid)
          Access a user object, given an enterprise id.
 List getUsers()
          Access all user objects - known to us (not from external providers).
 List getUsers(Collection ids)
          Access a bunch of user object.
 List getUsers(int first, int last)
          Find all the users within the record range given (sorted by sort name).
 void importEntities(String fromContext, String toContext, List ids)
          import Entites from the source context into the destination context
 void init()
          Final initialization, once all dependencies are set.
 boolean isDraft(Entity r)
          Check if this resource is in draft mode.
 String merge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport)
          Merge the resources from the archive into the given site.
 UserEdit mergeUser(Element el)
          Add a new user to the directory, from a definition in XML
 Entity newContainer(Element element)
          Construct a new container resource, from an XML element.
 Entity newContainer(Entity other)
          Construct a new container resource, as a copy of another
 Entity newContainer(String ref)
          Construct a new continer given just an id.
 Edit newContainerEdit(Element element)
          Construct a new container resource, from an XML element.
 Edit newContainerEdit(Entity other)
          Construct a new container resource, as a copy of another
 Edit newContainerEdit(String ref)
          Construct a new continer given just an id.
 Entity newResource(Entity container, Element element)
          Construct a new resource, from an XML element.
 Entity newResource(Entity container, Entity other)
          Construct a new resource from another resource of the same type.
 Entity newResource(Entity container, String id, Object[] others)
          Construct a new resource given just an id.
 Edit newResourceEdit(Entity container, Element element)
          Construct a new resource, from an XML element.
 Edit newResourceEdit(Entity container, Entity other)
          Construct a new resource from another resource of the same type.
 Edit newResourceEdit(Entity container, String id, Object[] others)
          Construct a new resource given just an id.
protected abstract  BaseUserDirectoryService.Storage newStorage()
          Construct storage for this service.
 UserEdit newUser()
          Create a new User (UserEdit) object.
 boolean parseEntityReference(String reference, Reference ref)
          If the service recognizes the reference as its own, parse it and fill in the Reference
 void removeUser(UserEdit user)
          Remove this user's information from the directory - it must be a user with a lock from editUser()
 List searchUsers(String criteria, int first, int last)
          Search all the users that match this criteria in id or email, first or last name, returning a subset of records within the record range given (sorted by sort name).
 void setCacheCleanerMinutes(String time)
          Set the # minutes between cache cleanings.
 void setCacheMinutes(String time)
          Set the # minutes to cache a get.
 void setCaseSensitiveId(String value)
          Configuration: case sensitive user id
 void setEntityManager(EntityManager service)
          Dependency: EntityManager.
 void setLogger(Logger service)
          Dependency: logging service.
 void setProvider(UserDirectoryProvider provider)
          Configuration: set the user directory provider helper service.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: ServerConfigurationService.
 Object[] storageFields(Entity r)
          Collect the fields that need to be stored outside the XML (for the resource).
 void syncWithSiteChange(Site site, EntityProducer.ChangeType change)
          Synchronize any entities related to the Site given this change in the Site, possibly a structural change where a tool is added or removed, or the site is new, or being deleted.
protected  void unlock(String lock, String resource)
          Check security permission.
protected  void unlock2(String lock1, String lock2, String resource)
          Check security permission.
protected  boolean unlockCheck(String lock, String resource)
          Check security permission.
protected  boolean unlockCheck2(String lock1, String lock2, String resource)
          Check security permission.
protected  String userId(String ref)
          Access the user id extracted from a user reference.
 String userReference(String id)
          Access the internal reference which can be used to access the resource from within the system.
 boolean willArchiveMerge()
          
 boolean willImport()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_storage

protected BaseUserDirectoryService.Storage m_storage
Storage manager for this service.


m_relativeAccessPoint

protected String m_relativeAccessPoint
The initial portion of a relative access point URL.


m_anon

protected User m_anon
An anon. user.


m_provider

protected UserDirectoryProvider m_provider
A user directory provider.


M_curUserKey

protected final String M_curUserKey
Key for current service caching of current user


m_callCache

protected Cache m_callCache
A cache of calls to the service and the results.


m_logger

protected Logger m_logger
Dependency: logging service


m_cacheSeconds

protected int m_cacheSeconds
The # seconds to cache gets. 0 disables the cache.


m_cacheCleanerSeconds

protected int m_cacheCleanerSeconds
The # seconds to cache gets. 0 disables the cache.


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: ServerConfigurationService.


m_entityManager

protected EntityManager m_entityManager
Dependency: EntityManager.


m_caseSensitiveId

protected boolean m_caseSensitiveId
Configuration: case sensitive user id.

Constructor Detail

BaseUserDirectoryService

public BaseUserDirectoryService()
Method Detail

newStorage

protected abstract BaseUserDirectoryService.Storage newStorage()
Construct storage for this service.


getAccessPoint

protected String getAccessPoint(boolean relative)
Access the partial URL that forms the root of resource URLs.

Parameters:
relative - if true, form within the access path only (i.e. starting with /content)
Returns:
the partial URL that forms the root of resource URLs.

userReference

public String userReference(String id)
Access the internal reference which can be used to access the resource from within the system.

Specified by:
userReference in interface UserDirectoryService
Parameters:
id - The user id string.
Returns:
The the internal reference which can be used to access the resource from within the system.

userId

protected String userId(String ref)
Access the user id extracted from a user reference.

Parameters:
ref - The user reference string.
Returns:
The the user id extracted from a user reference.

unlockCheck

protected boolean unlockCheck(String lock,
                              String resource)
Check security permission.

Parameters:
lock - The lock id string.
resource - The resource reference string, or null if no resource is involved.
Returns:
true if allowd, false if not

unlockCheck2

protected boolean unlockCheck2(String lock1,
                               String lock2,
                               String resource)
Check security permission.

Parameters:
lock1 - The lock id string.
lock2 - The lock id string.
resource - The resource reference string, or null if no resource is involved.
Returns:
true if either allowed, false if not

unlock

protected void unlock(String lock,
                      String resource)
               throws PermissionException
Check security permission.

Parameters:
lock - The lock id string.
resource - The resource reference string, or null if no resource is involved.
Throws:
PermissionException - Thrown if the user does not have access

unlock2

protected void unlock2(String lock1,
                       String lock2,
                       String resource)
                throws PermissionException
Check security permission.

Parameters:
lock1 - The lock id string.
lock2 - The lock id string.
resource - The resource reference string, or null if no resource is involved.
Throws:
PermissionException - Thrown if the user does not have access to either.

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

setProvider

public void setProvider(UserDirectoryProvider provider)
Configuration: set the user directory provider helper service.

Parameters:
provider - the user directory provider helper service.

setCacheMinutes

public void setCacheMinutes(String time)
Set the # minutes to cache a get.

Parameters:
time - The # minutes to cache a get (as an integer string).

setCacheCleanerMinutes

public void setCacheCleanerMinutes(String time)
Set the # minutes between cache cleanings.

Parameters:
time - The # minutes between cache cleanings. (as an integer string).

setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: ServerConfigurationService.

Parameters:
service - The ServerConfigurationService.

setEntityManager

public void setEntityManager(EntityManager service)
Dependency: EntityManager.

Parameters:
service - The EntityManager.

setCaseSensitiveId

public void setCaseSensitiveId(String value)
Configuration: case sensitive user id

Parameters:
value - The case sensitive user ide.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Returns to uninitialized state. You can use this method to release resources thet your Service allocated when Turbine shuts down.


getUser

public User getUser(String id)
             throws IdUnusedException
Access a user object.

Specified by:
getUser in interface UserDirectoryService
Parameters:
id - The user id string.
Returns:
A user object containing the user information
Throws:
IdUnusedException - if not found

getUserByEid

public User getUserByEid(String eid)
                  throws IdUnusedException
Access a user object, given an enterprise id.

Specified by:
getUserByEid in interface UserDirectoryService
Parameters:
eid - The user eid string.
Returns:
A user object containing the user information
Throws:
IdUnusedException - if not found

getUsers

public List getUsers(Collection ids)
Access a bunch of user object.

Specified by:
getUsers in interface UserDirectoryService
Parameters:
ids - The Collection (String) of user ids.
Returns:
A List (User) of user objects for valid ids.

getCurrentUser

public User getCurrentUser()
Access the user object associated with the "current" request.

Specified by:
getCurrentUser in interface UserDirectoryService
Returns:
The current user (may be anon).

allowUpdateUser

public boolean allowUpdateUser(String id)
check permissions for updating a user (i.s. using getUserEditClone() and calling commitEditClone())

Specified by:
allowUpdateUser in interface UserDirectoryService
Parameters:
id - The user id.
Returns:
true if the user is allowed to update the user, false if not.

editUser

public UserEdit editUser(String id)
                  throws IdUnusedException,
                         PermissionException,
                         InUseException
Get a locked user object for editing. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
editUser in interface UserDirectoryService
Parameters:
id - The user id string.
Returns:
A UserEdit object for editing.
Throws:
IdUnusedException - if not found, or if not an UserEdit object
PermissionException - if the current user does not have permission to mess with this user.
InUseException - if the current user does not have permission to mess with this user.

commitEdit

public void commitEdit(UserEdit user)
Commit the changes made to a UserEdit object, and release the lock.

Specified by:
commitEdit in interface UserDirectoryService
Parameters:
user - The UserEdit object to commit.

cancelEdit

public void cancelEdit(UserEdit user)
Cancel the changes made to a UserEdit object, and release the lock.

Specified by:
cancelEdit in interface UserDirectoryService
Parameters:
user - The UserEdit object to commit.

getUsers

public List getUsers()
Access all user objects - known to us (not from external providers).

Specified by:
getUsers in interface UserDirectoryService
Returns:
A list of user objects containing each user's information.

getUsers

public List getUsers(int first,
                     int last)
Find all the users within the record range given (sorted by sort name).

Specified by:
getUsers in interface UserDirectoryService
Parameters:
first - The first record position to return.
last - The last record position to return.
Returns:
A list (User) of all the users within the record range given (sorted by sort name).

countUsers

public int countUsers()
Count all the users.

Specified by:
countUsers in interface UserDirectoryService
Returns:
The count of all users.

searchUsers

public List searchUsers(String criteria,
                        int first,
                        int last)
Search all the users that match this criteria in id or email, first or last name, returning a subset of records within the record range given (sorted by sort name).

Specified by:
searchUsers in interface UserDirectoryService
Parameters:
criteria - The search criteria.
first - The first record position to return.
last - The last record position to return.
Returns:
A list (User) of all the aliases matching the criteria, within the record range given (sorted by sort name).

countSearchUsers

public int countSearchUsers(String criteria)
Count all the users that match this criteria in id or target, first or last name.

Specified by:
countSearchUsers in interface UserDirectoryService
Returns:
The count of all users matching the criteria.

findUsersByEmail

public Collection findUsersByEmail(String email)
Find the user objects which have this email address.

Specified by:
findUsersByEmail in interface UserDirectoryService
Parameters:
email - The email address string.
Returns:
A Collection (User) of user objects which have this email address (may be empty).

getAnonymousUser

public User getAnonymousUser()
Access the anonymous user object.

Specified by:
getAnonymousUser in interface UserDirectoryService
Returns:
the anonymous user object.

allowAddUser

public boolean allowAddUser(String id)
check permissions for addUser().

Specified by:
allowAddUser in interface UserDirectoryService
Parameters:
id - The user id.
Returns:
true if the user is allowed to addUser(id), false if not.

addUser

public UserEdit addUser(String id)
                 throws IdInvalidException,
                        IdUsedException,
                        PermissionException
Add a new user to the directory. Must commit() to make official, or cancel() when done!

Specified by:
addUser in interface UserDirectoryService
Parameters:
id - The user id.
Returns:
An edit clone to the new user object.
Throws:
IdInvalidException - if the user id is invalid.
IdUsedException - if the user id is already used.
PermissionException - if the current user does not have permission to add a user.

addUser

public User addUser(String id,
                    String firstName,
                    String lastName,
                    String email,
                    String pw,
                    String type,
                    ResourceProperties properties)
             throws IdInvalidException,
                    IdUsedException,
                    PermissionException
Add a new user to the directory, complete in one operation.

Specified by:
addUser in interface UserDirectoryService
Parameters:
id - The user id.
firstName - The user first name.
lastName - The user last name.
email - The user email.
pw - The user password.
type - The user type.
properties - Other user properties.
Returns:
The User object created.
Throws:
PermissionException - if the current user does not have permission to add a user.
IdInvalidException - if the user id is invalid.
IdUsedException - if the user id is already used.

mergeUser

public UserEdit mergeUser(Element el)
                   throws IdInvalidException,
                          IdUsedException,
                          PermissionException
Add a new user to the directory, from a definition in XML

Specified by:
mergeUser in interface UserDirectoryService
Parameters:
el - The XML DOM Element defining the user.
Returns:
An edit clone to the new user object.
Throws:
IdInvalidException - if the user id is invalid.
IdUsedException - if the user id is already used.
PermissionException - if the current user does not have permission to add a user.

allowRemoveUser

public boolean allowRemoveUser(String id)
check permissions for removeUser().

Specified by:
allowRemoveUser in interface UserDirectoryService
Parameters:
id - The user id.
Returns:
true if the user is allowed to removeUser(id), false if not.

removeUser

public void removeUser(UserEdit user)
                throws PermissionException
Remove this user's information from the directory - it must be a user with a lock from editUser()

Specified by:
removeUser in interface UserDirectoryService
Parameters:
user - The locked user object to remove.
Throws:
PermissionException - if the current user does not have permission to remove this user.

authenticate

public User authenticate(String eid,
                         String password)
Authenticate a user / password.

Specified by:
authenticate in interface UserDirectoryService
Parameters:
eid - The user id.
password - The password.
Returns:
The User object of the authenticated user if successfull, null if not.

authenticateViaProvider

protected boolean authenticateViaProvider(String id,
                                          UserEdit user,
                                          String password)
Authenticate user by provider information

Parameters:
id - The id string
user - The UserEdit object
password - The password string
Returns:

destroyAuthentication

public void destroyAuthentication()
Remove authentication for the current user.

Specified by:
destroyAuthentication in interface UserDirectoryService

findUser

protected BaseUserDirectoryService.BaseUserEdit findUser(String id)
Find the user object, in cache or storage (only - no provider check).

Parameters:
id - The user id.
Returns:
The user object found in cache or storage, or null if not found.

findUserByEid

protected BaseUserDirectoryService.BaseUserEdit findUserByEid(String eid)
Find the user object, by the eid (not id) in cache or storage (only - no provider check).

Returns:
The user object found in cache or storage, or null if not found.

addLiveProperties

protected void addLiveProperties(BaseUserDirectoryService.BaseUserEdit edit)
Create the live properties for the user.


addLiveUpdateProperties

protected void addLiveUpdateProperties(BaseUserDirectoryService.BaseUserEdit edit)
Update the live properties for a user for when modified.


cleanId

protected String cleanId(String id)
Adjust the id - trim it to null, and lower case IF we are case insensitive.

Parameters:
id - The id to clean up.
Returns:
A cleaned up id.

getLabel

public String getLabel()

Specified by:
getLabel in interface EntityProducer
Returns:
a short string identifying the resources kept here, good for a file name or label.

willArchiveMerge

public boolean willArchiveMerge()

Specified by:
willArchiveMerge in interface EntityProducer
Returns:
true if the serice wants to be part of archive / merge, false if not.

willImport

public boolean willImport()

Specified by:
willImport in interface EntityProducer
Returns:
true if the serice wants to be part of import, false if not.

getHttpAccess

public HttpAccess getHttpAccess()
Get the HttpAccess object that supports entity access via the access servlet for my entities.

Specified by:
getHttpAccess in interface EntityProducer
Returns:
The HttpAccess object for my entities, or null if I do not support access.

parseEntityReference

public boolean parseEntityReference(String reference,
                                    Reference ref)
If the service recognizes the reference as its own, parse it and fill in the Reference

Specified by:
parseEntityReference in interface EntityProducer
Parameters:
reference - The reference string to examine.
ref - The Reference object to set with the results of the parse from a recognized reference.
Returns:
true if the reference belonged to the service, false if not.

getEntityDescription

public String getEntityDescription(Reference ref)
Create an entity description for the entity referenced - the entity will belong to the service.

Specified by:
getEntityDescription in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The entity description, or null if one cannot be made.

getEntityResourceProperties

public ResourceProperties getEntityResourceProperties(Reference ref)
Access the resource properties for the referenced entity - the entity will belong to the service.

Specified by:
getEntityResourceProperties in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The ResourceProperties object for the entity, or null if it has none.

getEntity

public Entity getEntity(Reference ref)
Access the referenced Entity - the entity will belong to the service.

Specified by:
getEntity in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The Entity, or null if not found.

getEntityAuthzGroups

public Collection getEntityAuthzGroups(Reference ref)
Access a collection of authorization group ids for security on the for the referenced entity - the entity will belong to the service.

Specified by:
getEntityAuthzGroups in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The entity's collection of authorization group ids, or null if this cannot be done.

getEntityUrl

public String getEntityUrl(Reference ref)
Access a URL for the referenced entity - the entity will belong to the service.

Specified by:
getEntityUrl in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The entity's URL, or null if it does not have one.

archive

public String archive(String siteId,
                      Document doc,
                      Stack stack,
                      String archivePath,
                      List attachments)
Archive the resources for the given site.

Specified by:
archive in interface EntityProducer
Parameters:
siteId - the id of the site.
doc - The document to contain the xml.
stack - The stack of elements, the top of which will be the containing element of the "service.name" element.
archivePath - The path to the folder where we are writing auxilary files.
attachments - A list of attachments - add to this if any attachments need to be included in the archive.
Returns:
A log of status messages from the archive.

merge

public String merge(String siteId,
                    Element root,
                    String archivePath,
                    String fromSiteId,
                    Map attachmentNames,
                    Map userIdTrans,
                    Set userListAllowImport)
Merge the resources from the archive into the given site.

Specified by:
merge in interface EntityProducer
Parameters:
siteId - The id of the site getting imported into.
root - The XML DOM tree of content to merge.
attachmentNames - A map of old attachment name (as found in the DOM) to new attachment name.
Returns:
A log of status messages from the merge.

importEntities

public void importEntities(String fromContext,
                           String toContext,
                           List ids)
import Entites from the source context into the destination context

Specified by:
importEntities in interface EntityProducer
Parameters:
fromContext - The source context
toContext - The destination context
ids - when null, all entities will be imported; otherwise, only entities with those ids will be imported

syncWithSiteChange

public void syncWithSiteChange(Site site,
                               EntityProducer.ChangeType change)
Synchronize any entities related to the Site given this change in the Site, possibly a structural change where a tool is added or removed, or the site is new, or being deleted.

Specified by:
syncWithSiteChange in interface EntityProducer
Parameters:
site - The site that has just changed.
change - The ChangeType for the site (newly added, updated, or just removed).

newUser

public UserEdit newUser()
Create a new User (UserEdit) object.

Specified by:
newUser in interface UserFactory
Returns:
a new UserEdit object.

newContainer

public Entity newContainer(String ref)
Construct a new continer given just an id.

Specified by:
newContainer in interface StorageUser
Parameters:
ref - The container reference.
Returns:
The new containe Resource.

newContainer

public Entity newContainer(Element element)
Construct a new container resource, from an XML element.

Specified by:
newContainer in interface StorageUser
Parameters:
element - The XML.
Returns:
The new container resource.

newContainer

public Entity newContainer(Entity other)
Construct a new container resource, as a copy of another

Specified by:
newContainer in interface StorageUser
Parameters:
other - The other contianer to copy.
Returns:
The new container resource.

newResource

public Entity newResource(Entity container,
                          String id,
                          Object[] others)
Construct a new resource given just an id.

Specified by:
newResource in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
id - The id for the new object.
others - (options) array of objects to load into the Resource's fields.
Returns:
The new resource.

newResource

public Entity newResource(Entity container,
                          Element element)
Construct a new resource, from an XML element.

Specified by:
newResource in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
element - The XML.
Returns:
The new resource from the XML.

newResource

public Entity newResource(Entity container,
                          Entity other)
Construct a new resource from another resource of the same type.

Specified by:
newResource in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
other - The other resource.
Returns:
The new resource as a copy of the other.

newContainerEdit

public Edit newContainerEdit(String ref)
Construct a new continer given just an id.

Specified by:
newContainerEdit in interface StorageUser
Parameters:
ref - The container reference.
Returns:
The new containe Resource.

newContainerEdit

public Edit newContainerEdit(Element element)
Construct a new container resource, from an XML element.

Specified by:
newContainerEdit in interface StorageUser
Parameters:
element - The XML.
Returns:
The new container resource.

newContainerEdit

public Edit newContainerEdit(Entity other)
Construct a new container resource, as a copy of another

Specified by:
newContainerEdit in interface StorageUser
Parameters:
other - The other contianer to copy.
Returns:
The new container resource.

newResourceEdit

public Edit newResourceEdit(Entity container,
                            String id,
                            Object[] others)
Construct a new resource given just an id.

Specified by:
newResourceEdit in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
id - The id for the new object.
others - (options) array of objects to load into the Resource's fields.
Returns:
The new resource.

newResourceEdit

public Edit newResourceEdit(Entity container,
                            Element element)
Construct a new resource, from an XML element.

Specified by:
newResourceEdit in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
element - The XML.
Returns:
The new resource from the XML.

newResourceEdit

public Edit newResourceEdit(Entity container,
                            Entity other)
Construct a new resource from another resource of the same type.

Specified by:
newResourceEdit in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
other - The other resource.
Returns:
The new resource as a copy of the other.

storageFields

public Object[] storageFields(Entity r)
Collect the fields that need to be stored outside the XML (for the resource).

Specified by:
storageFields in interface StorageUser
Returns:
An array of field values to store in the record outside the XML (for the resource).

isDraft

public boolean isDraft(Entity r)
Check if this resource is in draft mode.

Specified by:
isDraft in interface StorageUser
Parameters:
r - The resource.
Returns:
true if the resource is in draft mode, false if not.

getOwnerId

public String getOwnerId(Entity r)
Access the resource owner user id.

Specified by:
getOwnerId in interface StorageUser
Parameters:
r - The resource.
Returns:
The resource owner user id.

getDate

public Time getDate(Entity r)
Access the resource date.

Specified by:
getDate in interface StorageUser
Parameters:
r - The resource.
Returns:
The resource date.