org.sakaiproject.component.legacy.authzGroup
Class BaseAuthzGroupService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.authzGroup.BaseAuthzGroupService
All Implemented Interfaces:
AuthzGroupService, EntityProducer, StorageUser
Direct Known Subclasses:
DbAuthzGroupService

public abstract class BaseAuthzGroupService
extends Object
implements AuthzGroupService, StorageUser

BaseAuthzGroupService is a Sakai azGroup service implementation.

To support the public view feature, an AuthzGroup named TEMPLATE_PUBVIEW must exist, with a role named ROLE_PUBVIEW - all the abilities in this role become the public view abilities for any resource.

Author:
Sakai Software Development Team

Nested Class Summary
protected static interface BaseAuthzGroupService.Storage
          Storage
 
Nested classes inherited from class org.sakaiproject.service.legacy.entity.EntityProducer
EntityProducer.ChangeType
 
Field Summary
protected  EntityManager m_entityManager
          Dependency: EntityManager.
protected  Logger m_logger
          Dependency: logging service
protected  GroupProvider m_provider
          A provider of additional Abilities for a userId.
protected  String m_relativeAccessPoint
          The initial portion of a relative access point URL.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  BaseAuthzGroupService.Storage m_storage
          Storage manager for this service.
 
Fields inherited from interface org.sakaiproject.service.legacy.authzGroup.AuthzGroupService
ANON_ROLE, AUTH_ROLE, REFERENCE_ROOT, SECURE_ADD_AUTHZ_GROUP, SECURE_REMOVE_AUTHZ_GROUP, SECURE_UPDATE_AUTHZ_GROUP, SECURE_UPDATE_OWN_AUTHZ_GROUP, SERVICE_NAME
 
Constructor Summary
BaseAuthzGroupService()
           
 
Method Summary
 AuthzGroup addAuthzGroup(String id)
          Add a new AuthzGroup
 AuthzGroup addAuthzGroup(String id, AuthzGroup other, String userId)
          Add a new AuthzGroup, as a copy of another AuthzGroup (except for id), and give a user "maintain" access based on the other's definition of "maintain".
protected  void addLiveProperties(BaseAuthzGroup azGroup)
          Create the live properties for the azGroup.
protected  void addLiveUpdateProperties(BaseAuthzGroup azGroup)
          Update the live properties for an AuthzGroup for when modified.
 boolean allowAdd(String id)
          Check permissions for adding an AuthzGroup.
 boolean allowJoinGroup(String authzGroupId)
          Check permissions for the current user joining a group.
 boolean allowRemove(String id)
          Check permissions for removing an AuthzGroup.
 boolean allowUnjoinGroup(String authzGroupId)
          Check permissions for the current user unjoining a group.
 boolean allowUpdate(String id)
          Check permissions for updating an AuthzGroup.
 String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
          Archive the resources for the given site.
protected  String authzGroupId(String ref)
          Access the azGroup id extracted from an AuthzGroup reference.
 String authzGroupReference(String id)
          Access the internal reference which can be used to access the AuthzGroup from within the system.
protected  void completeSave(AuthzGroup azGroup)
          Complete the saving of the group, once id and security checks have been cleared.
 int countAuthzGroups(String criteria)
          Count the AuthzGroups that meet specified criteria.
 void destroy()
          Returns to uninitialized state.
protected  String getAccessPoint(boolean relative)
          Access the partial URL that forms the root of resource URLs.
 Set getAllowedFunctions(String role, Collection azGroups)
          Get the set of functions that users with this role in these AuthzGroups are allowed to perform.
 AuthzGroup getAuthzGroup(String id)
          Access an AuthzGroup.
 List getAuthzGroups(String criteria, PagingPosition page)
          Access a list of AuthzGroups that meet specified criteria, naturally sorted.
 Set getAuthzGroupsIsAllowed(String userId, String function, Collection azGroups)
          Get the set of AuthzGroup ids in which this user is allowed to perform this function.
 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.
 String getUserRole(String userId, String azGroupId)
          Get the role name for this user in this AuthzGroup, if the user has membership (the membership gives the user a single role).
 Set getUsersIsAllowed(String function, Collection azGroups)
          Get the set of user ids of users who are allowed to perform the function in the named AuthzGroups.
 Map getUsersRole(Collection userIds, String azGroupId)
          Get the role name for each user in the userIds Collection in this AuthzGroup, for each of these users who have membership (membership gives the user a single role).
 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 isAllowed(String user, String function, Collection azGroups)
          Test if this user is allowed to perform the function in the named AuthzGroups.
 boolean isAllowed(String user, String function, String azGroupId)
          Test if this user is allowed to perform the function in the named AuthzGroup.
 boolean isDraft(Entity r)
          Check if this resource is in draft mode.
 void joinGroup(String authzGroupId, String roleId)
          Cause the current user to join the given AuthzGroup with this role, using SECURE_UPDATE_OWN_AUTHZ_GROUP security.
 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.
 AuthzGroup newAuthzGroup(String id, AuthzGroup other, String userId)
          Create a new AuthzGroup, as a copy of another AuthzGroup (except for id), and give a user "maintain" access based on the other's definition of "maintain", but do not store - it can be saved with a save() call
 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 rsource 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 rsource given just an id.
protected abstract  BaseAuthzGroupService.Storage newStorage()
          Construct storage for this service.
 boolean parseEntityReference(String reference, Reference ref)
          If the service recognizes the reference as its own, parse it and fill in the Reference
 void refreshUser(String userId)
          Refresh this user's AuthzGroup external definitions.
 void removeAuthzGroup(AuthzGroup azGroup)
          Remove this AuthzGroup.
 void removeAuthzGroup(String azGroupId)
          Remove the AuthzGroup with this id, if it exists (fails quietly if not).
protected  void removeSiteSecurity(AuthzGroup azGroup)
          Update the site security when an AuthzGroup is deleted, if it is a site AuthzGroup.
 void save(AuthzGroup azGroup)
          Save the changes made to the AuthzGroup. The AuthzGroup must already exist, and the user must have permission to update.
 void setEntityManager(EntityManager service)
          Dependency: EntityManager.
 void setLogger(Logger service)
          Dependency: logging service.
 void setProvider(GroupProvider provider)
          Configuration: set the azGroup 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.
 void unjoinGroup(String authzGroupId)
          Cause the current user to unjoin the given AuthzGroup, using SECURE_UPDATE_OWN_AUTHZ_GROUP security.
protected  void unlock(String lock, String resource)
          Check security permission.
protected  boolean unlockCheck(String lock, String resource)
          Check security permission.
protected  void updateSiteSecurity(AuthzGroup azGroup)
          Update the site security based on the values in the AuthzGroup, if it is a site AuthzGroup.
 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 BaseAuthzGroupService.Storage m_storage
Storage manager for this service.


m_relativeAccessPoint

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


m_provider

protected GroupProvider m_provider
A provider of additional Abilities for a userId.


m_logger

protected Logger m_logger
Dependency: logging service


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: ServerConfigurationService.


m_entityManager

protected EntityManager m_entityManager
Dependency: EntityManager.

Constructor Detail

BaseAuthzGroupService

public BaseAuthzGroupService()
Method Detail

newStorage

protected abstract BaseAuthzGroupService.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.

authzGroupId

protected String authzGroupId(String ref)
Access the azGroup id extracted from an AuthzGroup reference.

Parameters:
ref - The azGroup reference string.
Returns:
The the azGroup id extracted from an AuthzGroup 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

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 azGroup does not have access

addLiveProperties

protected void addLiveProperties(BaseAuthzGroup azGroup)
Create the live properties for the azGroup.


addLiveUpdateProperties

protected void addLiveUpdateProperties(BaseAuthzGroup azGroup)
Update the live properties for an AuthzGroup for when modified.


setLogger

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

Parameters:
service - The logging service.

setProvider

public void setProvider(GroupProvider provider)
Configuration: set the azGroup provider helper service.

Parameters:
provider - the azGroup provider helper service.

setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: ServerConfigurationService.

Parameters:
service - The ServerConfigurationService.

setEntityManager

public void setEntityManager(EntityManager service)
Dependency: EntityManager.

Parameters:
service - The EntityManager.

init

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


destroy

public void destroy()
Returns to uninitialized state.


getAuthzGroups

public List getAuthzGroups(String criteria,
                           PagingPosition page)
Access a list of AuthzGroups that meet specified criteria, naturally sorted.

Specified by:
getAuthzGroups in interface AuthzGroupService
Parameters:
criteria - Selection criteria: AuthzGroups returned will match this string somewhere in their id, or provider group id.
page - The PagePosition subset of items to return.
Returns:
The List (AuthzGroup) that meet specified criteria.

countAuthzGroups

public int countAuthzGroups(String criteria)
Count the AuthzGroups that meet specified criteria.

Specified by:
countAuthzGroups in interface AuthzGroupService
Parameters:
criteria - Selection criteria: AuthzGroups returned will match this string somewhere in their id, or provider group id.
Returns:
The count of AuthzGroups that meet specified criteria.

getAuthzGroup

public AuthzGroup getAuthzGroup(String id)
                         throws IdUnusedException
Access an AuthzGroup.

Specified by:
getAuthzGroup in interface AuthzGroupService
Parameters:
id - The id string.
Returns:
The AuthzGroup.
Throws:
IdUnusedException - if not found.

joinGroup

public void joinGroup(String authzGroupId,
                      String roleId)
               throws IdUnusedException,
                      PermissionException
Cause the current user to join the given AuthzGroup with this role, using SECURE_UPDATE_OWN_AUTHZ_GROUP security.

Specified by:
joinGroup in interface AuthzGroupService
Parameters:
authzGroupId - the id of the AuthzGroup.
roleId - the name of the Role.
Throws:
IdUnusedException - if the authzGroupId or role are not defined.
PermissionException - if the current user does not have permission to join this AuthzGroup.

unjoinGroup

public void unjoinGroup(String authzGroupId)
                 throws IdUnusedException,
                        PermissionException
Cause the current user to unjoin the given AuthzGroup, using SECURE_UPDATE_OWN_AUTHZ_GROUP security.

Specified by:
unjoinGroup in interface AuthzGroupService
Parameters:
authzGroupId - the id of the AuthzGroup.
Throws:
PermissionException - if the current user does not have permission to unjoin this site.
IdUnusedException - if the authzGroupId or role are not defined.

allowJoinGroup

public boolean allowJoinGroup(String authzGroupId)
Check permissions for the current user joining a group.

Specified by:
allowJoinGroup in interface AuthzGroupService
Parameters:
authzGroupId - The AuthzGroup id.
Returns:
true if the user is allowed to join the group, false if not.

allowUnjoinGroup

public boolean allowUnjoinGroup(String authzGroupId)
Check permissions for the current user unjoining a group.

Specified by:
allowUnjoinGroup in interface AuthzGroupService
Parameters:
authzGroupId - The AuthzGroup id.
Returns:
true if the user is allowed to unjoin the group, false if not.

allowUpdate

public boolean allowUpdate(String id)
Check permissions for updating an AuthzGroup.

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

save

public void save(AuthzGroup azGroup)
          throws IdUnusedException,
                 PermissionException
Save the changes made to the AuthzGroup. The AuthzGroup must already exist, and the user must have permission to update.

Specified by:
save in interface AuthzGroupService
Parameters:
azGroup - The AuthzGroup to save.
Throws:
PermissionException - if the current user does not have permission to update the AuthzGroup.
IdUnusedException - if the AuthzGroup id is not defined.

completeSave

protected void completeSave(AuthzGroup azGroup)
Complete the saving of the group, once id and security checks have been cleared.

Parameters:
azGroup -

allowAdd

public boolean allowAdd(String id)
Check permissions for adding an AuthzGroup.

Specified by:
allowAdd in interface AuthzGroupService
Parameters:
id - The authzGroup id.
Returns:
true if the current user is allowed add the AuthzGroup, false if not.

addAuthzGroup

public AuthzGroup addAuthzGroup(String id)
                         throws IdInvalidException,
                                IdUsedException,
                                PermissionException
Add a new AuthzGroup

Specified by:
addAuthzGroup in interface AuthzGroupService
Parameters:
id - The AuthzGroup id.
Returns:
The new AuthzGroup.
Throws:
PermissionException - if the current user does not have permission to add the AuthzGroup.
IdInvalidException - if the id is invalid.
IdUsedException - if the id is already used.

addAuthzGroup

public AuthzGroup addAuthzGroup(String id,
                                AuthzGroup other,
                                String userId)
                         throws IdInvalidException,
                                IdUsedException,
                                PermissionException
Add a new AuthzGroup, as a copy of another AuthzGroup (except for id), and give a user "maintain" access based on the other's definition of "maintain".

Specified by:
addAuthzGroup in interface AuthzGroupService
Parameters:
id - The id.
other - The AuthzGroup to copy into this new AuthzGroup.
userId - Optional user id to get "maintain" access, or null if none.
Returns:
The new AuthzGroup object.
Throws:
PermissionException - if the current user does not have permission to add the AuthzGroup.
IdUsedException - if the id is already used.
IdInvalidException - if the id is invalid.

newAuthzGroup

public AuthzGroup newAuthzGroup(String id,
                                AuthzGroup other,
                                String userId)
                         throws IdUsedException
Create a new AuthzGroup, as a copy of another AuthzGroup (except for id), and give a user "maintain" access based on the other's definition of "maintain", but do not store - it can be saved with a save() call

Specified by:
newAuthzGroup in interface AuthzGroupService
Parameters:
id - The id.
other - The AuthzGroup to copy into this new AuthzGroup (or null if none).
userId - Optional user id to get "maintain" access, or null if none.
Returns:
The new AuthzGroup object.
Throws:
IdUsedException - if the id is already used.

allowRemove

public boolean allowRemove(String id)
Check permissions for removing an AuthzGroup.

Specified by:
allowRemove in interface AuthzGroupService
Parameters:
id - The AuthzGroup id.
Returns:
true if the user is allowed to remove the AuthzGroup, false if not.

removeAuthzGroup

public void removeAuthzGroup(AuthzGroup azGroup)
                      throws PermissionException
Remove this AuthzGroup.

Specified by:
removeAuthzGroup in interface AuthzGroupService
Parameters:
azGroup - The AuthzGroup to remove.
Throws:
PermissionException - if the current user does not have permission to remove this AuthzGroup.

removeAuthzGroup

public void removeAuthzGroup(String azGroupId)
                      throws PermissionException
Remove the AuthzGroup with this id, if it exists (fails quietly if not).

Specified by:
removeAuthzGroup in interface AuthzGroupService
Parameters:
azGroupId - The AuthzGroup id.
Throws:
PermissionException - if the current user does not have permission to remove this AthzGroup.

authzGroupReference

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

Specified by:
authzGroupReference in interface AuthzGroupService
Parameters:
id - The AuthzGroup id.
Returns:
The the internal reference which can be used to access the AuthzGroup from within the system.

isAllowed

public boolean isAllowed(String user,
                         String function,
                         String azGroupId)
Test if this user is allowed to perform the function in the named AuthzGroup.

Specified by:
isAllowed in interface AuthzGroupService
Parameters:
user - The user id.
function - The function to open.
azGroupId - The AuthzGroup id to consult, if it exists.
Returns:
true if this user is allowed to perform the function in the named AuthzGroup, false if not.

isAllowed

public boolean isAllowed(String user,
                         String function,
                         Collection azGroups)
Test if this user is allowed to perform the function in the named AuthzGroups.

Specified by:
isAllowed in interface AuthzGroupService
Parameters:
user - The user id.
function - The function to open.
azGroups - A collection of AuthzGroup ids to consult.
Returns:
true if this user is allowed to perform the function in the named AuthzGroups, false if not.

getUsersIsAllowed

public Set getUsersIsAllowed(String function,
                             Collection azGroups)
Get the set of user ids of users who are allowed to perform the function in the named AuthzGroups.

Specified by:
getUsersIsAllowed in interface AuthzGroupService
Parameters:
function - The function to check.
azGroups - A collection of the ids of AuthzGroups to consult.
Returns:
the Set (String) of user ids of users who are allowed to perform the function in the named AuthzGroups.

getAllowedFunctions

public Set getAllowedFunctions(String role,
                               Collection azGroups)
Get the set of functions that users with this role in these AuthzGroups are allowed to perform.

Specified by:
getAllowedFunctions in interface AuthzGroupService
Parameters:
role - The role name.
azGroups - A collection of AuthzGroup ids to consult.
Returns:
the Set (String) of functions that users with this role in these AuthzGroups are allowed to perform

getAuthzGroupsIsAllowed

public Set getAuthzGroupsIsAllowed(String userId,
                                   String function,
                                   Collection azGroups)
Get the set of AuthzGroup ids in which this user is allowed to perform this function.

Specified by:
getAuthzGroupsIsAllowed in interface AuthzGroupService
Parameters:
userId - The user id.
function - The function to check.
azGroups - The Collection of AuthzGroup ids to search; if null, search them all.
Returns:
the Set (String) of AuthzGroup ids in which this user is allowed to perform this function.

getUserRole

public String getUserRole(String userId,
                          String azGroupId)
Get the role name for this user in this AuthzGroup, if the user has membership (the membership gives the user a single role).

Specified by:
getUserRole in interface AuthzGroupService
Parameters:
userId - The user id.
azGroupId - The AuthzGroup id to consult, if it exists.
Returns:
the role name for this user in this AuthzGroup, if the user has active membership, or null if not.

getUsersRole

public Map getUsersRole(Collection userIds,
                        String azGroupId)
Get the role name for each user in the userIds Collection in this AuthzGroup, for each of these users who have membership (membership gives the user a single role).

Specified by:
getUsersRole in interface AuthzGroupService
Parameters:
userIds - The user ids as a Collection of String.
azGroupId - The AuthzGroup id to consult, if it exists.
Returns:
A Map (userId (String) -> role name (String)) of role names for each user who have active membership; if the user does not, it will not be in the Map.

refreshUser

public void refreshUser(String userId)
Refresh this user's AuthzGroup external definitions.

Specified by:
refreshUser in interface AuthzGroupService
Parameters:
userId - The user id.

updateSiteSecurity

protected void updateSiteSecurity(AuthzGroup azGroup)
Update the site security based on the values in the AuthzGroup, if it is a site AuthzGroup.

Parameters:
azGroup - The AuthzGroup.

removeSiteSecurity

protected void removeSiteSecurity(AuthzGroup azGroup)
Update the site security when an AuthzGroup is deleted, if it is a site AuthzGroup.

Parameters:
azGroup - The AuthzGroup.

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

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