org.sakaiproject.component.legacy.site
Class BaseSiteService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.site.BaseSiteService
All Implemented Interfaces:
EntityProducer, SiteService, StorageUser
Direct Known Subclasses:
DbSiteService

public abstract class BaseSiteService
extends Object
implements SiteService, StorageUser

BaseSiteService is a base implementation of the SiteService.

Author:
Sakai Software Development Team

Nested Class Summary
protected static interface BaseSiteService.Storage
          Storage
 
Nested classes inherited from class org.sakaiproject.service.legacy.site.SiteService
SiteService.SelectionType, SiteService.SortType
 
Nested classes inherited from class org.sakaiproject.service.legacy.entity.EntityProducer
EntityProducer.ChangeType
 
Field Summary
protected  int m_cacheCleanerSeconds
          The # seconds to cache gets. 0 disables the cache.
protected  int m_cacheSeconds
          The # seconds to cache the site queries. 0 disables the cache.
protected  EntityManager m_entityManager
          Dependency: EntityManager.
protected  Logger m_logger
          Dependency: logging service
protected  boolean m_regenerateIds
          If true, run the regenerate ids pass on all sites at startup.
protected  String m_relativeAccessPoint
          The initial portion of a relative access point URL.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  SiteCache m_siteCache
          A site cache.
protected  BaseSiteService.Storage m_storage
          Storage manager for this service.
 
Fields inherited from interface org.sakaiproject.service.legacy.site.SiteService
GROUP_SUBTYPE, MAIN_CONTAINER, PAGE_SUBTYPE, REFERENCE_ROOT, SECURE_ADD_SITE, SECURE_ADD_USER_SITE, SECURE_REMOVE_SITE, SECURE_UPDATE_GROUP_MEMBERSHIP, SECURE_UPDATE_SITE, SECURE_UPDATE_SITE_MEMBERSHIP, SECURE_VIEW_ROSTER, SERVICE_NAME, SITE_ERROR, SITE_SUBTYPE, SITE_TEMPLATE, SITE_VISIT, SITE_VISIT_UNPUBLISHED, TOOL_SUBTYPE, URL_ERROR, USER_SITE_TEMPLATE
 
Constructor Summary
BaseSiteService()
           
 
Method Summary
protected  void addLiveProperties(BaseSite site)
          Create the live properties for the site.
protected  void addLiveUpdateProperties(BaseSite site)
          Update the live properties for a site for when modified.
 Site addSite(String id, Site other)
          Add a new site.
 Site addSite(String id, String type)
          Add a new site.
protected  String adjustSkin(String skin, boolean published)
          Adjust a skin value to be just a (folder) name, with no extension, and if missing, be null.
 boolean allowAccessSite(String id)
          check permissions for accessing (i.e. visiting) a site
 boolean allowAddSite(String id)
          check permissions for addSite().
 boolean allowRemoveSite(String id)
          check permissions for removeSite().
 boolean allowUnjoinSite(String id)
          check permissions for unjoin() - unjoining the site and removing all role relationships.
 boolean allowUpdateGroupMembership(String id)
          check permissions for updating a site's groups' memberships
 boolean allowUpdateSite(String id)
          check permissions for updating a site
 boolean allowUpdateSiteMembership(String id)
          check permissions for updating a site's membership
 boolean allowViewRoster(String id)
          check permissions for viewing project site participants
 String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
          Archive the resources for the given site.
protected  String convertReferenceUrl(String url)
          Return the url unchanged, unless it's a reference, then return the reference url
 int countSites(SiteService.SelectionType type, Object ofType, String criteria, Map propertyCriteria)
          Count the Site objets that meet specified criteria.
 void destroy()
          Returns to uninitialized state.
protected  void disableAuthorizationGroup(String ref)
          Remove a site's realm.
protected  void disableAzg(Site site)
          Disable the site and site group azgs for a site that's being deleted.
protected  void disableRelated(Site site)
          Sync up with all other services for a site that is going away.
protected  void doSave(BaseSite site, boolean isNew, EntityProducer.ChangeType change)
          Comlete the save process.
protected  void enableAuthorizationGroup(String ref, String templateId, String userId, String fallbackTemplate)
          Setup the realm for an active site.
protected  void enableAzg(BaseSite site)
          Enable the site and site group AuthzGroups.
protected  void enableAzgSecurityAdvisor()
          Establish a security advisor to allow the "embedded" azg work to occur with no need for additional security permissions.
protected  void enableRelated(BaseSite site, EntityProducer.ChangeType change)
          Sync up with all other services for a site that exists.
protected  void enforceGroupSubMembership(String siteId)
          Adjust any site groups for this site so that the group membership is a subset of the site's membership.
 Group findGroup(String refOrId)
          Access a Group object, given a reference string or id.
 SitePage findPage(String id)
          Access the Page that has this id, if one is defined, else return null. The page may be on any Site.
 ToolConfiguration findTool(String id)
          Access the ToolConfiguration that has this id, if one is defined, else return null.
protected  String getAccessPoint(boolean relative)
          Access the partial URL that forms the root of resource URLs.
 Time getDate(Entity r)
          Access the resource date.
protected  Site getDefinedSite(String id)
          Access an already defined site object.
 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.
 Site getSite(String id)
          Access a site object.
 String getSiteDisplay(String id)
          Form a display of the site title and id for this site.
 List getSites(SiteService.SelectionType type, Object ofType, String criteria, Map propertyCriteria, SiteService.SortType sort, PagingPosition page)
          Access a list of Site objets that meet specified criteria.
 String getSiteSkin(String id)
          Compute the skin to use for the (optional) site specified in the id parameter.
 String getSiteSpecialId(String site)
          Extract the special id for this special site from the site id or reference.
 List getSiteTypes()
          Access a unique list of String site types for any site type defined for any site, sorted by type.
 String getSiteUserId(String site)
          Extract the user id for this user site from the site id or reference.
 Site getSiteVisit(String id)
          Access a site object for purposes of having the user visit the site - visitation permissions are in effect.
 String getSpecialSiteId(String special)
          Form the site id for this special site.
 String getUserSiteId(String userId)
          Form the site id for this user's site.
protected  String groupAzgTemplate(Site site)
          Figure the authorization group template for a group of this site, based on type and if it's a user site.
 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.
 boolean isSpecialSite(String site)
          Is this site (id or reference) a special site?
 boolean isUserSite(String site)
          Is this site (id or reference) a user site?
 void join(String id)
          Cause the current user to join the site as defined by the site's joinable flag and joiner role.
 String merge(String siteId, Element el, String creatorId)
          Merge the site information from the archive into the given site.
 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.
 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  BaseSiteService.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
protected  void regenerateAllSiteIds()
          Regenerate the page and tool ids for all sites.
 void removeSite(Site site)
          Remove this site's information.
 void save(Site site)
          Save any updates to this site - it must be a defined site (the id must exist) and the user must have update permissions.
protected  void saveGroupAzgs(Site site)
          Save group azgs that are modified.
 void saveGroupMembership(Site site)
          Save only site group membership updates to this site - it must be a defined site (the id must exist) and the user must have site group membership update permissions.
protected  void saveSiteAzg(Site site)
          Save the site's azg if modified.
 void saveSiteInfo(String id, String description, String infoUrl)
          Save a site's information display fields: description and info url
 void saveSiteMembership(Site site)
          Save only site membership updates to this site - it must be a defined site (the id must exist) and the user must have site membership update permissions.
 void setCacheCleanerMinutes(String time)
          Set the # minutes between cache cleanings.
 void setCacheMinutes(String time)
          Set the # minutes to cache the site queries.
 void setEntityManager(EntityManager service)
          Dependency: EntityManager.
 void setLogger(Logger service)
          Dependency: logging service.
 void setRegenerateIds(String value)
          Configuration: regenerate all site;'s page and tool ids to assure uniqueness.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: ServerConfigurationService.
 void setSiteSecurity(String siteId, Set updateUsers, Set visitUnpUsers, Set visitUsers)
          Establish the internal security for this site.
 void setUserSecurity(String userId, Set updateSites, Set visitUnpSites, Set visitSites)
          Establish the internal security for user for all sites.
protected  String siteAzgTemplate(Site site)
          Figure the site's authorization group template, based on type and if it's a user site.
 boolean siteExists(String id)
          Is this a valid site id?
 String siteGroupReference(String siteId, String groupId)
          Access the internal reference which can be used to access the site group from within the system.
protected  String siteId(String ref)
          Access the site id extracted from a site reference.
 String sitePageReference(String siteId, String pageId)
          Access the internal reference which can be used to access the site page from within the system.
 String siteReference(String id)
          Access the internal reference which can be used to access the site from within the system.
 String siteToolReference(String siteId, String toolId)
          Access the internal reference which can be used to access the site tool from within the system.
 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 unjoin(String id)
          Cause the current user to unjoin the site, removing all role relationships.
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.
 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 BaseSiteService.Storage m_storage
Storage manager for this service.


m_relativeAccessPoint

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


m_siteCache

protected SiteCache m_siteCache
A site cache.


m_logger

protected Logger m_logger
Dependency: logging service


m_regenerateIds

protected boolean m_regenerateIds
If true, run the regenerate ids pass on all sites at startup.


m_cacheSeconds

protected int m_cacheSeconds
The # seconds to cache the site queries. 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.

Constructor Detail

BaseSiteService

public BaseSiteService()
Method Detail

newStorage

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

siteId

protected String siteId(String ref)
Access the site id extracted from a site reference.

Parameters:
ref - The site reference string.
Returns:
The the site id extracted from a site 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 user does not have access

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

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.

addLiveUpdateProperties

protected void addLiveUpdateProperties(BaseSite site)
Update the live properties for a site for when modified.


addLiveProperties

protected void addLiveProperties(BaseSite site)
Create the live properties for the site.


convertReferenceUrl

protected String convertReferenceUrl(String url)
Return the url unchanged, unless it's a reference, then return the reference url


setLogger

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

Parameters:
service - The logging service.

setRegenerateIds

public void setRegenerateIds(String value)
Configuration: regenerate all site;'s page and tool ids to assure uniqueness.

Parameters:
value - The regenerate ids value

setCacheMinutes

public void setCacheMinutes(String time)
Set the # minutes to cache the site queries.

Parameters:
time - The # minutes to cache the site queries (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.

regenerateAllSiteIds

protected void regenerateAllSiteIds()
Regenerate the page and tool ids for all sites.


init

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


destroy

public void destroy()
Returns to uninitialized state.


allowAccessSite

public boolean allowAccessSite(String id)
Description copied from interface: SiteService
check permissions for accessing (i.e. visiting) a site

Specified by:
allowAccessSite in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to access the site, false if not.

getDefinedSite

protected Site getDefinedSite(String id)
                       throws IdUnusedException
Access an already defined site object.

Parameters:
id - The site id string.
Returns:
A site object containing the site information
Throws:
IdUnusedException - if not found

siteExists

public boolean siteExists(String id)
Description copied from interface: SiteService
Is this a valid site id?

Specified by:
siteExists in interface SiteService
Parameters:
id - The site id string.
Returns:
True if a site with this id is defined, false if not.

getSite

public Site getSite(String id)
             throws IdUnusedException
Description copied from interface: SiteService
Access a site object.

Specified by:
getSite in interface SiteService
Parameters:
id - The site id string.
Returns:
A site object containing the site information.
Throws:
IdUnusedException - if not found.

getSiteVisit

public Site getSiteVisit(String id)
                  throws IdUnusedException,
                         PermissionException
Description copied from interface: SiteService
Access a site object for purposes of having the user visit the site - visitation permissions are in effect.

Specified by:
getSiteVisit in interface SiteService
Parameters:
id - The site id string.
Returns:
A site object containing the site information.
Throws:
PermissionException - if the current user does not have permission to visit this site.
IdUnusedException - if not found.

allowUpdateSite

public boolean allowUpdateSite(String id)
Description copied from interface: SiteService
check permissions for updating a site

Specified by:
allowUpdateSite in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to update the site, false if not.

allowUpdateSiteMembership

public boolean allowUpdateSiteMembership(String id)
Description copied from interface: SiteService
check permissions for updating a site's membership

Specified by:
allowUpdateSiteMembership in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to update the site's membership, false if not.

allowUpdateGroupMembership

public boolean allowUpdateGroupMembership(String id)
Description copied from interface: SiteService
check permissions for updating a site's groups' memberships

Specified by:
allowUpdateGroupMembership in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to update the site's groups' memberships, false if not.

save

public void save(Site site)
          throws IdUnusedException,
                 PermissionException
Description copied from interface: SiteService
Save any updates to this site - it must be a defined site (the id must exist) and the user must have update permissions.

Specified by:
save in interface SiteService
Parameters:
site - The site, modified, to save.
Throws:
PermissionException - If the end user does not have permission to update the site.
IdUnusedException - If the site's id is not a defined site id.

saveSiteMembership

public void saveSiteMembership(Site site)
                        throws IdUnusedException,
                               PermissionException
Description copied from interface: SiteService
Save only site membership updates to this site - it must be a defined site (the id must exist) and the user must have site membership update permissions.

Specified by:
saveSiteMembership in interface SiteService
Parameters:
site - The site, modified, to save.
Throws:
IdUnusedException - If the site's id is not a defined site id.
PermissionException - If the end user does not have permission to update the membership of the site.

saveGroupMembership

public void saveGroupMembership(Site site)
                         throws IdUnusedException,
                                PermissionException
Description copied from interface: SiteService
Save only site group membership updates to this site - it must be a defined site (the id must exist) and the user must have site group membership update permissions.

Specified by:
saveGroupMembership in interface SiteService
Parameters:
site - The site, modified, to save.
Throws:
PermissionException - If the end user does not have permission to update the membership of the site.
IdUnusedException - If the site's id is not a defined site id.

doSave

protected void doSave(BaseSite site,
                      boolean isNew,
                      EntityProducer.ChangeType change)
Comlete the save process.

Parameters:
site - The site to save.

enableAzgSecurityAdvisor

protected void enableAzgSecurityAdvisor()
Establish a security advisor to allow the "embedded" azg work to occur with no need for additional security permissions.


saveSiteAzg

protected void saveSiteAzg(Site site)
Save the site's azg if modified.

Parameters:
site - The site to save.

saveGroupAzgs

protected void saveGroupAzgs(Site site)
Save group azgs that are modified.

Parameters:
site - The site to save.

saveSiteInfo

public void saveSiteInfo(String id,
                         String description,
                         String infoUrl)
                  throws IdUnusedException,
                         PermissionException
Description copied from interface: SiteService
Save a site's information display fields: description and info url

Specified by:
saveSiteInfo in interface SiteService
Parameters:
id - The site id to update.
description - The updated description.
infoUrl - The updated infoUrl
Throws:
PermissionException - If the end user does not have permission to update the site.
IdUnusedException - If the site's id is not a defined site id.

allowAddSite

public boolean allowAddSite(String id)
Description copied from interface: SiteService
check permissions for addSite().

Specified by:
allowAddSite in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to addSite(id), false if not.

addSite

public Site addSite(String id,
                    String type)
             throws IdInvalidException,
                    IdUsedException,
                    PermissionException
Description copied from interface: SiteService
Add a new site. The site will exist with just an id once done, so remove() it if you don't want to keep it.

Specified by:
addSite in interface SiteService
Parameters:
id - The site id.
type - The site type.
Returns:
The new site object.
Throws:
IdUsedException - if the site id is already used.
IdInvalidException - if the site id is invalid.
PermissionException - if the current user does not have permission to add a site.

addSite

public Site addSite(String id,
                    Site other)
             throws IdInvalidException,
                    IdUsedException,
                    PermissionException
Description copied from interface: SiteService
Add a new site. Will be structured just like .

Specified by:
addSite in interface SiteService
Parameters:
id - The site id.
other - The site to make this site a structural copy of.
Returns:
The new site object.
Throws:
IdUsedException - if the site id is already used.
PermissionException - if the current user does not have permission to add a site.
IdInvalidException - if the site id is invalid.

allowRemoveSite

public boolean allowRemoveSite(String id)
Description copied from interface: SiteService
check permissions for removeSite().

Specified by:
allowRemoveSite in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to removeSite(id), false if not.

removeSite

public void removeSite(Site site)
                throws PermissionException
Description copied from interface: SiteService
Remove this site's information.

Specified by:
removeSite in interface SiteService
Throws:
PermissionException - if the current user does not have permission to remove this site.

siteReference

public String siteReference(String id)
Description copied from interface: SiteService
Access the internal reference which can be used to access the site from within the system.

Specified by:
siteReference in interface SiteService
Parameters:
id - The site id.
Returns:
The the internal reference which can be used to access the site from within the system.

sitePageReference

public String sitePageReference(String siteId,
                                String pageId)
Description copied from interface: SiteService
Access the internal reference which can be used to access the site page from within the system.

Specified by:
sitePageReference in interface SiteService
Parameters:
siteId - The site id.
pageId - The page id.
Returns:
The the internal reference which can be used to access the site page from within the system.

siteToolReference

public String siteToolReference(String siteId,
                                String toolId)
Description copied from interface: SiteService
Access the internal reference which can be used to access the site tool from within the system.

Specified by:
siteToolReference in interface SiteService
Parameters:
siteId - The site id.
toolId - The tool id.
Returns:
The the internal reference which can be used to access the site tool from within the system.

siteGroupReference

public String siteGroupReference(String siteId,
                                 String groupId)
Description copied from interface: SiteService
Access the internal reference which can be used to access the site group from within the system.

Specified by:
siteGroupReference in interface SiteService
Parameters:
siteId - The site id.
groupId - The group id.
Returns:
The the internal reference which can be used to access the site group from within the system.

isUserSite

public boolean isUserSite(String site)
Description copied from interface: SiteService
Is this site (id or reference) a user site?

Specified by:
isUserSite in interface SiteService
Parameters:
site - The site id or reference.
Returns:
true if this is a user site, false if not.

getSiteUserId

public String getSiteUserId(String site)
Description copied from interface: SiteService
Extract the user id for this user site from the site id or reference.

Specified by:
getSiteUserId in interface SiteService
Parameters:
site - The site id or reference.
Returns:
The user id associated with this site.

getUserSiteId

public String getUserSiteId(String userId)
Description copied from interface: SiteService
Form the site id for this user's site.

Specified by:
getUserSiteId in interface SiteService
Parameters:
userId - The user id.
Returns:
The site id for this user's site.

isSpecialSite

public boolean isSpecialSite(String site)
Description copied from interface: SiteService
Is this site (id or reference) a special site?

Specified by:
isSpecialSite in interface SiteService
Parameters:
site - The site id or reference.
Returns:
true if this is a special site, false if not.

getSiteSpecialId

public String getSiteSpecialId(String site)
Description copied from interface: SiteService
Extract the special id for this special site from the site id or reference.

Specified by:
getSiteSpecialId in interface SiteService
Parameters:
site - The site id or reference.
Returns:
The special id associated with this site.

getSpecialSiteId

public String getSpecialSiteId(String special)
Description copied from interface: SiteService
Form the site id for this special site.

Specified by:
getSpecialSiteId in interface SiteService
Parameters:
special - The special id.
Returns:
The site id for this user's site.

getSiteDisplay

public String getSiteDisplay(String id)
Description copied from interface: SiteService
Form a display of the site title and id for this site.

Specified by:
getSiteDisplay in interface SiteService
Parameters:
id - The site id.
Returns:
A display of the site title and id for this site.

findTool

public ToolConfiguration findTool(String id)
Description copied from interface: SiteService
Access the ToolConfiguration that has this id, if one is defined, else return null. The tool may be on any Site and on any SitePage.

Specified by:
findTool in interface SiteService
Parameters:
id - The id of the tool.
Returns:
The ToolConfiguration that has this id, if one is defined, else return null.

findPage

public SitePage findPage(String id)
Access the Page that has this id, if one is defined, else return null. The page may be on any Site.

Specified by:
findPage in interface SiteService
Parameters:
id - The id of the page.
Returns:
The SitePage that has this id, if one is defined, else return null.

allowViewRoster

public boolean allowViewRoster(String id)
Description copied from interface: SiteService
check permissions for viewing project site participants

Specified by:
allowViewRoster in interface SiteService
Parameters:
id - The site id.
Returns:
true if the site is allowed to addSite(id), false if not.

join

public void join(String id)
          throws IdUnusedException,
                 PermissionException
Description copied from interface: SiteService
Cause the current user to join the site as defined by the site's joinable flag and joiner role.

Specified by:
join in interface SiteService
Parameters:
id - The site id.
Throws:
IdUnusedException - if the id is not a valid site id.
PermissionException - if the current user does not have permission to join this site.

unjoin

public void unjoin(String id)
            throws IdUnusedException,
                   PermissionException
Description copied from interface: SiteService
Cause the current user to unjoin the site, removing all role relationships.

Specified by:
unjoin in interface SiteService
Parameters:
id - The site id.
Throws:
PermissionException - if the current user does not have permission to unjoin this site.
IdUnusedException - if the id is not a valid site id.

allowUnjoinSite

public boolean allowUnjoinSite(String id)
Description copied from interface: SiteService
check permissions for unjoin() - unjoining the site and removing all role relationships.

Specified by:
allowUnjoinSite in interface SiteService
Parameters:
id - The site id.
Returns:
true if the user is allowed to unjoin(id), false if not.

getSiteSkin

public String getSiteSkin(String id)
Description copied from interface: SiteService
Compute the skin to use for the (optional) site specified in the id parameter. If no site specified, or if the site has no skin defined, use the configured default skin.

Specified by:
getSiteSkin in interface SiteService
Parameters:
id - The (optional) site id.
Returns:
A skin to use for this site.

getSiteTypes

public List getSiteTypes()
Access a unique list of String site types for any site type defined for any site, sorted by type.

Specified by:
getSiteTypes in interface SiteService
Returns:
A list (String) of all used site types.

getSites

public List getSites(SiteService.SelectionType type,
                     Object ofType,
                     String criteria,
                     Map propertyCriteria,
                     SiteService.SortType sort,
                     PagingPosition page)
Description copied from interface: SiteService
Access a list of Site objets that meet specified criteria.

Specified by:
getSites in interface SiteService
Parameters:
type - The SelectionType specifying what sort of selection is intended.
ofType - Site type criteria: null for any type; a String to match a single type; A String[], List or Set to match any type in the collection.
criteria - Additional selection criteria: sites returned will match this string somewhere in their id, title, description, or skin.
propertyCriteria - Additional selection criteria: sites returned will have a property named to match each key in the map, whose values match (somewhere in their value) the value in the map (may be null or empty).
sort - A SortType indicating the desired sort. For no sort, set to SortType.NONE.
page - The PagePosition subset of items to return.
Returns:
The List (Site) of Site objets that meet specified criteria.

countSites

public int countSites(SiteService.SelectionType type,
                      Object ofType,
                      String criteria,
                      Map propertyCriteria)
Description copied from interface: SiteService
Count the Site objets that meet specified criteria.

Specified by:
countSites in interface SiteService
Parameters:
type - The SelectionType specifying what sort of selection is intended.
ofType - Site type criteria: null for any type; a String to match a single type; A String[], List or Set to match any type in the collection.
criteria - Additional selection criteria: sits returned will match this string somewhere in their id, title, description, or skin.
propertyCriteria - Additional selection criteria: sites returned will have a property named to match each key in the map, whose values match (somewhere in their value) the value in the map (may be null or empty).
Returns:
The count of Site objets that meet specified criteria.

setSiteSecurity

public void setSiteSecurity(String siteId,
                            Set updateUsers,
                            Set visitUnpUsers,
                            Set visitUsers)
Description copied from interface: SiteService
Establish the internal security for this site. Previous security settings are replaced for this site. Assigning a user with update implies the two reads; assigning a user with unp read implies the other read.

Specified by:
setSiteSecurity in interface SiteService
Parameters:
siteId - The id of the site.
updateUsers - The set of String User Ids who have update access.
visitUnpUsers - The set of String User Ids who have visit unpublished access.
visitUsers - The set of String User Ids who have visit access.

setUserSecurity

public void setUserSecurity(String userId,
                            Set updateSites,
                            Set visitUnpSites,
                            Set visitSites)
Description copied from interface: SiteService
Establish the internal security for user for all sites. Previous security settings are replaced for this user. Assigning a user with update implies the two reads; assigning a user with unp read implies the other read.

Specified by:
setUserSecurity in interface SiteService
Parameters:
userId - The id of the user.
updateSites - The set of String site ids where the user has update access.
visitUnpSites - The set of String site ids where the user has visit unpublished access.
visitSites - The set of String site ids where the user has visit access.

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

enableRelated

protected void enableRelated(BaseSite site,
                             EntityProducer.ChangeType change)
Sync up with all other services for a site that exists.

Parameters:
site - The site.

disableRelated

protected void disableRelated(Site site)
Sync up with all other services for a site that is going away.

Parameters:
site - The site.

enableAzg

protected void enableAzg(BaseSite site)
Enable the site and site group AuthzGroups.

Parameters:
site - The site.

disableAzg

protected void disableAzg(Site site)
Disable the site and site group azgs for a site that's being deleted.

Parameters:
site - The site.

siteAzgTemplate

protected String siteAzgTemplate(Site site)
Figure the site's authorization group template, based on type and if it's a user site.

Parameters:
site - The site to figure the realm for.
Returns:
the site's authorization group template, based on type and if it's a user site.

groupAzgTemplate

protected String groupAzgTemplate(Site site)
Figure the authorization group template for a group of this site, based on type and if it's a user site.

Parameters:
site - The site to figure the authorization group templates for.
Returns:
the authorization group template for a group of this site, based on type and if it's a user site.

enableAuthorizationGroup

protected void enableAuthorizationGroup(String ref,
                                        String templateId,
                                        String userId,
                                        String fallbackTemplate)
Setup the realm for an active site.

Parameters:
ref - The reference for which the realm will be created (site, user).
templateId - The realm id of a template to use for the new realm.
userId - The user to get maintain in this realm.

disableAuthorizationGroup

protected void disableAuthorizationGroup(String ref)
Remove a site's realm.


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.

adjustSkin

protected String adjustSkin(String skin,
                            boolean published)
Adjust a skin value to be just a (folder) name, with no extension, and if missing, be null.

Parameters:
skin - The skin value to adjust.
Returns:
A defaulted and adjusted skin value.

merge

public String merge(String siteId,
                    Element el,
                    String creatorId)
Description copied from interface: SiteService
Merge the site information from the archive into the given site.

Specified by:
merge in interface SiteService
Parameters:
siteId - The target site id.
el - The XML DOM tree of content to merge.
creatorId - The site creator id for target site.
Returns:
A log of status messages from the archive.

findGroup

public Group findGroup(String refOrId)
Description copied from interface: SiteService
Access a Group object, given a reference string or id.

Specified by:
findGroup in interface SiteService
Parameters:
refOrId - The group reference or id string.
Returns:
The Group object if found, or null if not.

enforceGroupSubMembership

protected void enforceGroupSubMembership(String siteId)
Adjust any site groups for this site so that the group membership is a subset of the site's membership.

Parameters:
siteId - The site to adjust.