org.sakaiproject.component.legacy.content
Class BaseContentService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.content.BaseContentService
All Implemented Interfaces:
CacheRefresher, ContentHostingService, EntityProducer
Direct Known Subclasses:
DbContentService

public abstract class BaseContentService
extends Object
implements ContentHostingService, CacheRefresher

BaseContentService is an abstract base implementation of the Sakai ContentHostingService.

Version:
$Revision: 7328 $
Author:
University of Michigan, Sakai Software Development Team

Nested Class Summary
 class BaseContentService.BaseCollectionEdit
          ContentCollection implementation
 class BaseContentService.BaseResourceEdit
          ContentResource implementation
protected  class BaseContentService.CollectionStorageUser
          Storage user for collections - in the resource side, not container
protected  class BaseContentService.ResourceStorageUser
          Storage user for resources - in the resource side, not container
protected static interface BaseContentService.Storage
          Storage implementation
 
Nested classes inherited from class org.sakaiproject.service.legacy.entity.EntityProducer
EntityProducer.ChangeType
 
Field Summary
protected static String ATTACHMENTS_COLLECTION
          The collection id for the attachments collection
protected static String COLLECTION_DROPBOX
          The content root collection for dropboxes.
static String COLLECTION_SITE
          Collection id for the non-user sites.
static String COLLECTION_USER
          Collection id for the user sites.
protected static String DROPBOX_ID
           
protected  AliasService m_aliasService
          Dependency: AliasService.
protected  String m_bodyPath
          Optional path to external file system file store for body binary.
protected  String[] m_bodyVolumes
          Optional set of folders just within the m_bodyPath to distribute files among.
protected  Cache m_cache
          A Cache for this service - ContentResource and ContentCollection keyed by reference.
protected  boolean m_caching
          Configuration: cache, or not.
protected  EntityManager m_entityManager
          Dependency: EntityManager.
protected  Logger m_logger
          Dependency: logging service
protected  MemoryService m_memoryService
          Dependency: MemoryService.
protected  NotificationService m_notificationService
          Dependency: NotificationService.
protected  String m_relativeAccessPoint
          The initial portion of a relative access point URL.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  boolean m_shortRefs
          Configuration: short refs
protected  boolean m_siteAlias
          Configuration: alias for site
protected  long m_siteQuota
          The quota for content resource body bytes (in Kbytes) for any hierarchy in the /user/ or /group/ areas, or 0 if quotas are not enforced.
protected  SiteService m_siteService
          Dependency: SiteService.
protected  BaseContentService.Storage m_storage
          A Storage object for persistent storage.
protected static int MAXIMUM_ATTEMPTS_FOR_UNIQUENESS
          Number of times to attempt to find a unique resource id when copying or moving a resource
protected static int MAXIMUM_RESOURCE_ID_LENGTH
          Maximum number of characters in a valid resource-id
protected static String PROP_MEMBER_DROPBOX_DESCRIPTION
           
protected static String PROP_SITE_DROPBOX_DESCRIPTION
           
protected static int STREAM_BUFFER_SIZE
          The chunk size used when streaming (100k).
protected static boolean STREAM_CONTENT
          stream content requests if true, read all into memory and send if false.
 
Fields inherited from interface org.sakaiproject.service.legacy.content.ContentHostingService
EVENT_DROPBOX_MAINTAIN, EVENT_DROPBOX_OWN, EVENT_RESOURCE_ADD, EVENT_RESOURCE_READ, EVENT_RESOURCE_REMOVE, EVENT_RESOURCE_WRITE, PROP_ALTERNATE_REFERENCE, REFERENCE_ROOT, SERVICE_NAME
 
Constructor Summary
BaseContentService()
           
 
Method Summary
 ContentResourceEdit addAttachmentResource(String name)
          Create a new resource as an attachment to some other resource in the system, locked for update.
 ContentResource addAttachmentResource(String name, String type, byte[] content, ResourceProperties properties)
          Create a new resource as an attachment to some other resource in the system.
 ContentResource addAttachmentResource(String name, String site, String tool, String type, byte[] content, ResourceProperties properties)
          Create a new resource as an attachment to some other resource in the system.
 ContentCollectionEdit addCollection(String id)
          Create a new collection with the given resource id, locked for update.
 ContentCollection addCollection(String id, ResourceProperties properties)
          Create a new collection with the given resource id.
 ContentResource addDeleteResource(String id, String type, byte[] content, ResourceProperties properties, String uuid, String userId, int priority)
           
protected  void addLiveCollectionProperties(ContentCollectionEdit c)
          Create the live properties for a collection.
protected  void addLiveResourceProperties(ContentResourceEdit r)
          Create the live properties for a resource.
protected  void addLiveUpdateCollectionProperties(ContentCollectionEdit c)
          Create the live properties for a collection.
protected  void addLiveUpdateResourceProperties(ContentResourceEdit r)
          Update the live properties for a resource when modified (for a resource).
protected  void addProperties(ResourcePropertiesEdit p, ResourceProperties props)
          Add properties for a resource.
 ResourceProperties addProperty(String id, String name, String value)
          Add / update a property for a resource, either collection or resource.
 ContentResourceEdit addResource(String id)
          Create a new resource with the given resource id, locked for update.
 ContentResource addResource(String id, String type, byte[] content, ResourceProperties properties, int priority)
          Create a new resource with the given resource id.
 ContentResource addResource(String name, String collectionId, int limit, String type, byte[] content, ResourceProperties properties, int priority)
          Create a new resource with the given resource name used as a resource id within the specified collection or (if that id is already in use) with a resource id based on a variation on the name to achieve a unique id, provided a unique id can be found before a limit is reached on the number of attempts to achieve uniqueness.
 void addResourceToDeleteTable(ContentResourceEdit edit, String uuid, String userId)
          Store the resource in a separate delete table
protected  ContentCollectionEdit addValidPermittedCollection(String id)
          Create a new collection with the given resource id, locked for update.
 boolean allowAddAttachmentResource()
          check permissions for addAttachmentResource().
 boolean allowAddCollection(String id)
          check permissions for addCollection().
 boolean allowAddProperty(String id)
          check permissions for addProperty().
 boolean allowAddResource(String id)
          check permissions for addResource().
 boolean allowCopy(String id, String new_id)
          check permissions for copy().
 boolean allowGetCollection(String id)
          check permissions for getCollection().
 boolean allowGetProperties(String id)
          check permissions for getProperties().
 boolean allowGetResource(String id)
          check permissions for getResource().
 boolean allowRemoveCollection(String id)
          check permissions for removeCollection().
 boolean allowRemoveProperty(String id)
          check permissions for removeProperty().
 boolean allowRemoveResource(String id)
          check permissions for removeResource().
 boolean allowRename(String id, String new_id)
          check permissions for rename().
 boolean allowUpdateCollection(String id)
          check permissions for editCollection()
 boolean allowUpdateResource(String id)
          check permissions for updateResource().
 String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
          Archive the resources for the given site.
protected  void archiveCollection(ContentCollection collection, Document doc, Stack stack, String storagePath, String siteCollectionId, StringBuffer results)
          Archive the collection, then the members of the collection - recursively for collection members.
protected  String archiveResource(ContentResource resource, Document doc, Stack stack, String storagePath, String siteCollectionId)
          Archive a singe resource
 String archiveResources(List attachments, Document doc, Stack stack, String archivePath)
          Archive the specified list of resources.
protected  void assureResourceProperties(ContentResourceEdit r)
          Make sure that the entire set of properties are present, adding whatever is needed, replacing nothing that's there already.
protected  long bytes2k(long bytes)
          Convert bytes to Kbytes, rounding up, and counting even 0 bytes as 1 k.
 void cancelCollection(ContentCollectionEdit edit)
          Cancel the changes made object, and release the lock.
 void cancelResource(ContentResourceEdit edit)
          Cancel the changes made object, and release the lock.
 void checkCollection(String id)
          Check access to the collection with this local resource id.
protected  void checkExplicitLock(String id)
          Throws a PermissionException if the resource with the given Id is explicitly locked
 void checkResource(String id)
          Check access to the resource with this local resource id.
 void commitCollection(ContentCollectionEdit edit)
          Commit the changes made, and release the lock.
 void commitResource(ContentResourceEdit edit)
          Commit the changes made, and release the lock.
 void commitResource(ContentResourceEdit edit, int priority)
          Commit the changes made, and release the lock.
protected  void commitResourceEdit(ContentResourceEdit edit, int priority)
          Commit the changes made, and release the lock - no quota check.
protected  String convertLockIfDropbox(String lock, String id)
          If the id is for a resource in a dropbox, change the function to a dropbox check, which is to check for write.
 String copy(String id, String new_id)
          Copy a resource or collection.
 String copyCollection(ContentCollection thisCollection, String new_id)
          Copy a collection.
 String copyIntoFolder(String id, String folder_id)
          Copy a collection or resource from one location to another.
 String copyResource(ContentResource resource, String new_id)
          Copy a resource.
 void createDropboxCollection()
          Create the site's dropbox collection and one for each qualified user that the current user can make.
 void createDropboxCollection(String siteId)
          Create the site's dropbox collection and one for each qualified user that the current user can make.
protected  String deepcopyCollection(ContentCollection thisCollection, String new_folder_id)
          Make a deep copy of a collection.
 void destroy()
          Returns to uninitialized state.
protected  void disableDropbox(Site site)
          Remove resources area for a site.
protected  void disableResources(Site site)
          Remove resources area for a site.
 ContentCollectionEdit editCollection(String id)
          Access the collection with this local resource id, locked for update.
 ContentResourceEdit editResource(String id)
          Access the resource with this resource id, locked for update.
 void eliminateDuplicates(Collection resourceIds)
          Eliminate from the collection any duplicates as well as any items that are contained within another item whose resource-id is in the collection.
protected  void enableDropbox(Site site)
          Make sure a home in resources for dropbox exists for the site.
protected  void enableResources(Site site)
          Make sure a home in resources exists for the site.
protected  List filterArtifacts(List artifacts, String type, String primaryMimeType, String subMimeType)
           
protected  ContentCollection findCollection(String id)
          Access the collection with this local resource id.
protected  ContentResource findResource(String id)
          Access the resource with this resource id.
 List findResources(String type, String primaryMimeType, String subMimeType)
          Find the resources this user has read access to from all worksites of the appropriate type.
protected  Hashtable fixTypeAndId(String id, String type)
          Check the fixed type and id infomation: The same or better content type based on the known type for this id's extension, if any.
protected  void generateCollections(String target)
          Attempt to create any collections needed so that the parameter collection exists.
protected  String getAccessPoint(boolean relative)
          Access the partial URL that forms the root of resource URLs.
protected  void getAllResources(ContentCollection collection, List rv)
          Access a List of all the ContentResource objects in this collection (and below) which the current user has access.
 List getAllResources(String id)
          Access a List of all the ContentResource objects in this path (and below) which the current user has access.
protected  String getAlternateReferenceRoot(String id, String rootProperty)
          Compute an alternate root for a reference, based on the value of the specified property.
 ContentCollection getCollection(String id)
          Access the collection with this local resource id.
 Map getCollectionMap()
          Return a map of Worksite collections roots that the user has access to.
 String getContainingCollectionId(String id)
          Access the resource id of the collection which contains this collection or resource.
 int getDepth(String resourceId, String baseCollectionId)
          Get the depth of the resource/collection object in the hireachy based on the given collection id
 String getDropboxCollection()
          Access the default dropbox collection id for the current request.
 String getDropboxCollection(String siteId)
          Access the default dropbox collection id for the current request.
 String getDropboxDisplayName()
          Access the default dropbox collection display name for the current request.
 String getDropboxDisplayName(String siteId)
          Access the default dropbox collection display name for the site.
 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.
protected  List getFlatResources(String parentId)
          get all the resources under a given directory.
 HttpAccess getHttpAccess()
          Get the HttpAccess object that supports entity access via the access servlet for my entities.
 String getLabel()
          
 ResourceProperties getProperties(String id)
          Access the properties of a resource with this resource id, either collection or resource.
 String getReference(String id)
          Access the internal reference from a resource id.
 ContentResource getResource(String id)
          Access the resource with this resource id.
 String getSiteCollection(String siteId)
          Return the collection id of the root collection for this site id.
 String getUrl(String id)
          Access the resource URL from a resource id.
 String getUrl(String id, String rootProperty)
          Access the alternate URL which can be used to access the entity.
protected  void handleAccessCollection(HttpServletRequest req, HttpServletResponse res, Reference ref, Collection copyrightAcceptedRefs)
          Process the access request for a collection, producing the "apache" style HTML file directory listing (complete with index.html redirect if found).
protected  void handleAccessResource(HttpServletRequest req, HttpServletResponse res, Reference ref, Collection copyrightAcceptedRefs)
          Process the access request for a resource.
 void importEntities(String fromContext, String toContext, List resourceIds)
          import tool(s) contents from the source context into the destination context
 void init()
          Final initialization, once all dependencies are set.
 boolean isAttachmentResource(String id)
          Check whether a resource id or collection id references an entity in the attachments collection.
 boolean isDropboxMaintainer()
          Determine whether the default dropbox collection id for this user in this site is the site's entire dropbox collection or just the current user's collection within the site's dropbox.
 boolean isDropboxMaintainer(String siteId)
          Determine whether the default dropbox collection id for this user in some site is the site's entire dropbox collection or just the current user's collection within the site's dropbox.
 boolean isInheritingPubView(String id)
          Does this resource inherit public view by having it set in a containing folder (not counting it's own setting)?
protected  String isolateContainingId(String id)
          Find the containing collection id of a given resource id.
protected  String isolateName(String id)
          Find the resource name of a given resource id.
 boolean isPubView(String id)
          Does this resource support public view?
 boolean isRootCollection(String id)
          Test if this id (reference, or URL) refers to the root collection.
 String merge(String siteId, Element root, String archivePath, String mergeId, Map attachmentNames, Map userIdTrans, Set userListAllowImport)
          Merge the resources from the archive into the given site.
protected  ContentCollection mergeCollection(Element element)
          Merge in a collection from an XML DOM definition.
protected  ContentResource mergeResource(Element element)
          Merge in a resource from an XML DOM definition.
protected  ContentResource mergeResource(Element element, byte[] body)
          Merge in a resource from an XML DOM definition and a body bytes array.
protected  String moveCollection(ContentCollectionEdit thisCollection, String new_folder_id)
          Move a collection to a new folder.
 String moveIntoFolder(String id, String folder_id)
          Move a resource or collection to a (different) folder.
protected  String moveResource(ContentResourceEdit thisResource, String new_id)
          Move a resource to a new folder.
protected  String newName(String id, String folder_id)
          Calculate a candidate for a resource id for a resource being copied/moved into a new folder.
 ResourcePropertiesEdit newResourceProperties()
          Construct a stand-alone, not associated with any particular resource, ResourceProperties object.
protected abstract  BaseContentService.Storage newStorage()
          Construct a Storage object.
protected  boolean overQuota(ContentResourceEdit edit)
          Test if this resource edit would place the account" over quota.
 boolean parseEntityReference(String reference, Reference ref)
          If the service recognizes the reference as its own, parse it and fill in the Reference
 Object refresh(Object key, Object oldValue, Event event)
          Get a new value for this key whose value has already expired in the cache.
 void removeCollection(ContentCollectionEdit edit)
          Remove just a collection.
 void removeCollection(String id)
          Remove a collection and all members of the collection, internal or deeper.
 ResourceProperties removeProperty(String id, String name)
          Remove a property from a resource, either collection or resource.
protected  void removeRecursive(ContentCollection parent)
          used to remove any members of a collection whoes add was canceled.
 void removeResource(ContentResourceEdit edit)
          Remove a resource that is locked for update.
 void removeResource(String id)
          Remove a resource.
 String rename(String id, String new_id)
          Rename a collection or resource.
 void setAliasService(AliasService service)
          Dependency: AliasService.
 void setBodyPath(String value)
          Configuration: set the external file system path for body storage If set, the resource binary database table will not be used.
 void setBodyVolumes(String value)
          Configuration: set the external file system volume folders (folder just within the bodyPath) as a comma separated list of folder names.
 void setCaching(String value)
          Configuration: set the locks-in-db
 void setEntityManager(EntityManager service)
          Dependency: EntityManager.
 void setLogger(Logger service)
          Dependency: logging service.
 void setMemoryService(MemoryService service)
          Dependency: MemoryService.
 void setNotificationService(NotificationService service)
          Dependency: NotificationService.
 void setPubView(String id, boolean pubview)
          Set this resource or collection to the pubview setting.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: ServerConfigurationService.
 void setShortRefs(String value)
          Configuration: set the short refs
 void setSiteAlias(String value)
          Configuration: set the alias for site
 void setSiteQuota(String quota)
          Set the site quota.
 void setSiteService(SiteService service)
          Dependency: SiteService.
protected abstract  void setUuidInternal(String id, String uuid)
           
 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 syncWithSiteChangeDropbox(Site site, EntityProducer.ChangeType change)
          {@inheritDoc}
 void syncWithSiteChangeResources(Site site, EntityProducer.ChangeType change)
          {@inheritDoc}
protected  void unlock(String lock, String id)
          Check security permission.
protected  boolean unlockCheck(String lock, String id)
          Check security permission.
 ContentResource updateResource(String id, String type, byte[] content)
          Update the body and or content type of an existing resource with the given resource id.
 boolean willArchiveMerge()
          
 boolean willImport()
          
protected  void WTUserIdTrans(Element el, Map userIdTrans)
          Replace the WT user id with the new qualified id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sakaiproject.service.legacy.content.ContentHostingService
containsLockedNode, getCollectionSize, getLocks, getUuid, isLocked, lockObject, removeAllLocks, removeLock, resolveUuid, setUuid
 

Field Detail

ATTACHMENTS_COLLECTION

protected static final String ATTACHMENTS_COLLECTION
The collection id for the attachments collection

See Also:
Constant Field Values

MAXIMUM_ATTEMPTS_FOR_UNIQUENESS

protected static final int MAXIMUM_ATTEMPTS_FOR_UNIQUENESS
Number of times to attempt to find a unique resource id when copying or moving a resource

See Also:
Constant Field Values

MAXIMUM_RESOURCE_ID_LENGTH

protected static final int MAXIMUM_RESOURCE_ID_LENGTH
Maximum number of characters in a valid resource-id

See Also:
Constant Field Values

m_relativeAccessPoint

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


m_storage

protected BaseContentService.Storage m_storage
A Storage object for persistent storage.


m_cache

protected Cache m_cache
A Cache for this service - ContentResource and ContentCollection keyed by reference.


m_siteQuota

protected long m_siteQuota
The quota for content resource body bytes (in Kbytes) for any hierarchy in the /user/ or /group/ areas, or 0 if quotas are not enforced.


COLLECTION_USER

public static final String COLLECTION_USER
Collection id for the user sites.

See Also:
Constant Field Values

COLLECTION_SITE

public static final String COLLECTION_SITE
Collection id for the non-user sites.

See Also:
Constant Field Values

m_bodyPath

protected String m_bodyPath
Optional path to external file system file store for body binary.


m_bodyVolumes

protected String[] m_bodyVolumes
Optional set of folders just within the m_bodyPath to distribute files among.


m_logger

protected Logger m_logger
Dependency: logging service


m_memoryService

protected MemoryService m_memoryService
Dependency: MemoryService.


m_aliasService

protected AliasService m_aliasService
Dependency: AliasService.


m_siteService

protected SiteService m_siteService
Dependency: SiteService.


m_notificationService

protected NotificationService m_notificationService
Dependency: NotificationService.


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: ServerConfigurationService.


m_caching

protected boolean m_caching
Configuration: cache, or not.


m_entityManager

protected EntityManager m_entityManager
Dependency: EntityManager.


m_shortRefs

protected boolean m_shortRefs
Configuration: short refs


m_siteAlias

protected boolean m_siteAlias
Configuration: alias for site


STREAM_CONTENT

protected static final boolean STREAM_CONTENT
stream content requests if true, read all into memory and send if false.

See Also:
Constant Field Values

STREAM_BUFFER_SIZE

protected static final int STREAM_BUFFER_SIZE
The chunk size used when streaming (100k).

See Also:
Constant Field Values

COLLECTION_DROPBOX

protected static final String COLLECTION_DROPBOX
The content root collection for dropboxes.

See Also:
Constant Field Values

PROP_MEMBER_DROPBOX_DESCRIPTION

protected static final String PROP_MEMBER_DROPBOX_DESCRIPTION

PROP_SITE_DROPBOX_DESCRIPTION

protected static final String PROP_SITE_DROPBOX_DESCRIPTION

DROPBOX_ID

protected static final String DROPBOX_ID
See Also:
Constant Field Values
Constructor Detail

BaseContentService

public BaseContentService()
Method Detail

setLogger

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

Parameters:
service - The logging service.

setMemoryService

public void setMemoryService(MemoryService service)
Dependency: MemoryService.

Parameters:
service - The MemoryService.

setAliasService

public void setAliasService(AliasService service)
Dependency: AliasService.

Parameters:
service - The AliasService.

setSiteService

public void setSiteService(SiteService service)
Dependency: SiteService.

Parameters:
service - The SiteService.

setNotificationService

public void setNotificationService(NotificationService service)
Dependency: NotificationService.

Parameters:
service - The NotificationService.

setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: ServerConfigurationService.

Parameters:
service - The ServerConfigurationService.

setSiteQuota

public void setSiteQuota(String quota)
Set the site quota.

Parameters:
quota - The site quota (as a string).

setCaching

public void setCaching(String value)
Configuration: set the locks-in-db


setBodyPath

public void setBodyPath(String value)
Configuration: set the external file system path for body storage If set, the resource binary database table will not be used.

Parameters:
value - The complete path to the root of the external file system storage area for resource body bytes.

setBodyVolumes

public void setBodyVolumes(String value)
Configuration: set the external file system volume folders (folder just within the bodyPath) as a comma separated list of folder names. If set, files will be distributed over these folders.

Parameters:
value - The comma separated list of folder names within body path to distribute files among.

setEntityManager

public void setEntityManager(EntityManager service)
Dependency: EntityManager.

Parameters:
service - The EntityManager.

setShortRefs

public void setShortRefs(String value)
Configuration: set the short refs

Parameters:
value - The short refs value.

setSiteAlias

public void setSiteAlias(String value)
Configuration: set the alias for site

Parameters:
value - The alias for site value.

init

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


destroy

public void destroy()
Returns to uninitialized state.


newStorage

protected abstract BaseContentService.Storage newStorage()
Construct a Storage object.

Returns:
The new storage object.

setUuidInternal

protected abstract void setUuidInternal(String id,
                                        String uuid)
Parameters:
id - id of the resource to set the UUID for
uuid - the new UUID of the resource

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.

convertLockIfDropbox

protected String convertLockIfDropbox(String lock,
                                      String id)
If the id is for a resource in a dropbox, change the function to a dropbox check, which is to check for write.
You have full or no access to a dropbox.

Parameters:
lock - The lock we are checking.
id - The resource id.
Returns:
The lock to check.

unlockCheck

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

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

checkExplicitLock

protected void checkExplicitLock(String id)
                          throws PermissionException
Throws a PermissionException if the resource with the given Id is explicitly locked

Parameters:
id -
Throws:
PermissionException

unlock

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

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

addLiveCollectionProperties

protected void addLiveCollectionProperties(ContentCollectionEdit c)
Create the live properties for a collection.

Parameters:
c - The collection.

addLiveUpdateCollectionProperties

protected void addLiveUpdateCollectionProperties(ContentCollectionEdit c)
Create the live properties for a collection.

Parameters:
c - The collection.

addLiveResourceProperties

protected void addLiveResourceProperties(ContentResourceEdit r)
Create the live properties for a resource.

Parameters:
r - The resource.

addLiveUpdateResourceProperties

protected void addLiveUpdateResourceProperties(ContentResourceEdit r)
Update the live properties for a resource when modified (for a resource).

Parameters:
r - The resource.

assureResourceProperties

protected void assureResourceProperties(ContentResourceEdit r)
Make sure that the entire set of properties are present, adding whatever is needed, replacing nothing that's there already.

Parameters:
r - The resource.

addProperties

protected void addProperties(ResourcePropertiesEdit p,
                             ResourceProperties props)
Add properties for a resource.

Parameters:
props - The properties.

allowAddCollection

public boolean allowAddCollection(String id)
check permissions for addCollection().

Specified by:
allowAddCollection in interface ContentHostingService
Returns:
true if the user is allowed to addCollection(id), false if not.

addCollection

public ContentCollection addCollection(String id,
                                       ResourceProperties properties)
                                throws IdUsedException,
                                       IdInvalidException,
                                       PermissionException,
                                       InconsistentException
Create a new collection with the given resource id.

Specified by:
addCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
properties - A java Properties object with the properties to add to the new collection.
Returns:
a new ContentCollection object.
Throws:
IdUsedException - if the id is already in use.
IdInvalidException - if the id is invalid.
PermissionException - if the user does not have permission to add a collection, or add a member to a collection.
InconsistentException - if the containing collection does not exist.

addCollection

public ContentCollectionEdit addCollection(String id)
                                    throws IdUsedException,
                                           IdInvalidException,
                                           PermissionException,
                                           InconsistentException
Create a new collection with the given resource id, locked for update. Must commitCollection() to make official, or cancelCollection() when done!

Specified by:
addCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
a new ContentCollection object.
Throws:
IdUsedException - if the id is already in use.
IdInvalidException - if the id is invalid.
PermissionException - if the user does not have permission to add a collection, or add a member to a collection.
InconsistentException - if the containing collection does not exist.

addValidPermittedCollection

protected ContentCollectionEdit addValidPermittedCollection(String id)
                                                     throws IdUsedException,
                                                            InconsistentException
Create a new collection with the given resource id, locked for update. Must commitCollection() to make official, or cancelCollection() when done!

Parameters:
id - The id of the collection.
Returns:
a new ContentCollection object.
Throws:
IdUsedException - if the id is already in use.
InconsistentException - if the containing collection does not exist.

allowGetCollection

public boolean allowGetCollection(String id)
check permissions for getCollection().

Specified by:
allowGetCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
true if the user is allowed to getCollection(id), false if not.

checkCollection

public void checkCollection(String id)
                     throws IdUnusedException,
                            TypeException,
                            PermissionException
Check access to the collection with this local resource id.

Specified by:
checkCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Throws:
IdUnusedException - if the id does not exist.
TypeException - if the resource exists but is not a collection.
PermissionException - if the user does not have permissions to see this collection (or read through containing collections).

getCollection

public ContentCollection getCollection(String id)
                                throws IdUnusedException,
                                       TypeException,
                                       PermissionException
Access the collection with this local resource id. The collection internal members and properties are accessible from the returned Colelction object.

Specified by:
getCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
The ContentCollection object found.
Throws:
IdUnusedException - if the id does not exist.
TypeException - if the resource exists but is not a collection.
PermissionException - if the user does not have permissions to see this collection (or read through containing collections).

getAllResources

public List getAllResources(String id)
Access a List of all the ContentResource objects in this path (and below) which the current user has access.

Specified by:
getAllResources in interface ContentHostingService
Parameters:
id - A collection id.
Returns:
a List of the ContentResource objects.

getAllResources

protected void getAllResources(ContentCollection collection,
                               List rv)
Access a List of all the ContentResource objects in this collection (and below) which the current user has access.

Parameters:
collection - The collection.
rv - The list in which to accumulate resource objects.

findCollection

protected ContentCollection findCollection(String id)
                                    throws TypeException
Access the collection with this local resource id. Internal find does the guts of finding without security or event tracking. The collection internal members and properties are accessible from the returned Colelction object.

Parameters:
id - The id of the collection.
Returns:
The ContentCollection object found, or null if not.
Throws:
TypeException - if the resource exists but is not a collection.

allowUpdateCollection

public boolean allowUpdateCollection(String id)
check permissions for editCollection()

Specified by:
allowUpdateCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
true if the user is allowed to update the collection, false if not.

editCollection

public ContentCollectionEdit editCollection(String id)
                                     throws IdUnusedException,
                                            TypeException,
                                            PermissionException,
                                            InUseException
Access the collection with this local resource id, locked for update. Must commitCollection() to make official, or cancelCollection() when done! The collection internal members and properties are accessible from the returned Collection object.

Specified by:
editCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
The ContentCollection object found.
Throws:
IdUnusedException - if the id does not exist.
TypeException - if the resource exists but is not a collection.
PermissionException - if the user does not have permissions to see this collection (or read through containing collections).
InUseException - if the Collection is locked by someone else.

allowRemoveCollection

public boolean allowRemoveCollection(String id)
check permissions for removeCollection(). Note: for just this collection, not the members on down.

Specified by:
allowRemoveCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
true if the user is allowed to removeCollection(id), false if not.

removeCollection

public void removeCollection(ContentCollectionEdit edit)
                      throws TypeException,
                             PermissionException,
                             InconsistentException,
                             ServerOverloadException
Remove just a collection. It must be empty.

Specified by:
removeCollection in interface ContentHostingService
Throws:
TypeException - if the resource exists but is not a collection.
PermissionException - if the user does not have permissions to remove this collection, read through any containing
InconsistentException - if the collection has members, so that the removal would leave things in an inconsistent state.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and an attempt to access the resource body of any collection member fails.

removeCollection

public void removeCollection(String id)
                      throws IdUnusedException,
                             TypeException,
                             PermissionException,
                             InUseException,
                             ServerOverloadException
Remove a collection and all members of the collection, internal or deeper.

Specified by:
removeCollection in interface ContentHostingService
Parameters:
id - The id of the collection.
Throws:
IdUnusedException - if the id does not exist.
TypeException - if the resource exists but is not a collection.
PermissionException - if the user does not have permissions to remove this collection, read through any containing
InUseException - if the collection or a contained member is locked by someone else. collections, or remove any members of the collection.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and an attempt to access the resource body of any collection member fails.

commitCollection

public void commitCollection(ContentCollectionEdit edit)
Commit the changes made, and release the lock. The Object is disabled, and not to be used after this call.

Specified by:
commitCollection in interface ContentHostingService
Parameters:
edit - The ContentCollectionEdit object to commit.

cancelCollection

public void cancelCollection(ContentCollectionEdit edit)
Cancel the changes made object, and release the lock. The Object is disabled, and not to be used after this call.

Specified by:
cancelCollection in interface ContentHostingService
Parameters:
edit - The ContentCollectionEdit object to commit.

removeRecursive

protected void removeRecursive(ContentCollection parent)
used to remove any members of a collection whoes add was canceled.

Parameters:
parent -

allowAddResource

public boolean allowAddResource(String id)
check permissions for addResource().

Specified by:
allowAddResource in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to addResource(id), false if not.

addResource

public ContentResource addResource(String id,
                                   String type,
                                   byte[] content,
                                   ResourceProperties properties,
                                   int priority)
                            throws PermissionException,
                                   IdUsedException,
                                   IdInvalidException,
                                   InconsistentException,
                                   OverQuotaException,
                                   ServerOverloadException
Create a new resource with the given resource id.

Specified by:
addResource in interface ContentHostingService
Parameters:
id - The id of the new resource.
type - The mime type string of the resource.
content - An array containing the bytes of the resource's content.
properties - A java Properties object with the properties to add to the new resource.
priority - The notification priority for this commit.
Returns:
a new ContentResource object.
Throws:
PermissionException - if the user does not have permission to add a resource to the containing collection.
IdUsedException - if the resource id is already in use.
IdInvalidException - if the resource id is invalid.
InconsistentException - if the containing collection does not exist.
OverQuotaException - if this would result in being over quota.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

addResource

public ContentResource addResource(String name,
                                   String collectionId,
                                   int limit,
                                   String type,
                                   byte[] content,
                                   ResourceProperties properties,
                                   int priority)
                            throws PermissionException,
                                   IdUniquenessException,
                                   IdLengthException,
                                   IdInvalidException,
                                   InconsistentException,
                                   OverQuotaException,
                                   ServerOverloadException
Create a new resource with the given resource name used as a resource id within the specified collection or (if that id is already in use) with a resource id based on a variation on the name to achieve a unique id, provided a unique id can be found before a limit is reached on the number of attempts to achieve uniqueness.

Specified by:
addResource in interface ContentHostingService
Parameters:
name - The name of the new resource (such as a filename).
collectionId - The id of the collection to which the resource should be added.
limit - The maximum number of attempts at finding a unique id based on the given name.
type - The mime type string of the resource.
content - An array containing the bytes of the resource's content.
properties - A ResourceProperties object with the properties to add to the new resource.
priority - The notification priority for this commit.
Returns:
a new ContentResource object.
Throws:
PermissionException - if the user does not have permission to add a resource to the containing collection.
IdUniquenessException - if a unique resource id cannot be found before the limit on the number of attempts is reached.
IdLengthException - if the resource id exceeds the maximum number of characters for a valid resource id.
IdInvalidException - if the resource id is invalid.
InconsistentException - if the containing collection does not exist.
OverQuotaException - if this would result in being over quota.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

addResource

public ContentResourceEdit addResource(String id)
                                throws PermissionException,
                                       IdUsedException,
                                       IdInvalidException,
                                       InconsistentException
Create a new resource with the given resource id, locked for update. Must commitResource() to make official, or cancelResource() when done!

Specified by:
addResource in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
a new ContentResource object.
Throws:
PermissionException - if the user does not have permission to add a resource to the containing collection.
IdUsedException - if the resource id is already in use.
IdInvalidException - if the resource id is invalid.
InconsistentException - if the containing collection does not exist.

allowAddAttachmentResource

public boolean allowAddAttachmentResource()
check permissions for addAttachmentResource().

Specified by:
allowAddAttachmentResource in interface ContentHostingService
Returns:
true if the user is allowed to addAttachmentResource(), false if not.

isAttachmentResource

public boolean isAttachmentResource(String id)
Check whether a resource id or collection id references an entity in the attachments collection. This method makes no guarantees that a resource actually exists with this id.

Specified by:
isAttachmentResource in interface ContentHostingService
Parameters:
id - Assumed to be a valid resource id or collection id.
Returns:
true if the id (assuming it is a valid id for an existing resource or collection) references an entity in the hidden attachments area created through one of this class's addAttachmentResource methods.

addAttachmentResource

public ContentResource addAttachmentResource(String name,
                                             String type,
                                             byte[] content,
                                             ResourceProperties properties)
                                      throws IdInvalidException,
                                             InconsistentException,
                                             IdUsedException,
                                             PermissionException,
                                             OverQuotaException,
                                             ServerOverloadException
Create a new resource as an attachment to some other resource in the system. The new resource will be placed into a newly created collecion in the attachment collection, with an auto-generated id, and given the specified resource name within this collection.

Specified by:
addAttachmentResource in interface ContentHostingService
Parameters:
name - The name of the new resource, i.e. a partial id relative to the collection where it will live.
type - The mime type string of the resource.
content - An array containing the bytes of the resource's content.
properties - A ResourceProperties object with the properties to add to the new resource.
Returns:
a new ContentResource object.
Throws:
IdUsedException - if the resource name is already in use (not likely, as the containing collection is auto-generated!)
IdInvalidException - if the resource name is invalid.
InconsistentException - if the containing collection (or it's containing collection...) does not exist.
PermissionException - if the user does not have permission to add a collection, or add a member to a collection.
OverQuotaException - if this would result in being over quota.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

addAttachmentResource

public ContentResource addAttachmentResource(String name,
                                             String site,
                                             String tool,
                                             String type,
                                             byte[] content,
                                             ResourceProperties properties)
                                      throws IdInvalidException,
                                             InconsistentException,
                                             IdUsedException,
                                             PermissionException,
                                             OverQuotaException,
                                             ServerOverloadException
Create a new resource as an attachment to some other resource in the system. The new resource will be placed into a newly created collecion in the attachment collection, with an auto-generated id, and given the specified resource name within this collection.

Specified by:
addAttachmentResource in interface ContentHostingService
Parameters:
name - The name of the new resource, i.e. a partial id relative to the collection where it will live.
site - The string identifier for the site where the attachment is being added.
tool - The display-name for the tool through which the attachment is being added within the site's attachments collection.
type - The mime type string of the resource.
content - An array containing the bytes of the resource's content.
properties - A ResourceProperties object with the properties to add to the new resource.
Returns:
a new ContentResource object.
Throws:
IdUsedException - if the resource name is already in use (not likely, as the containing collection is auto-generated!)
IdInvalidException - if the resource name is invalid.
InconsistentException - if the containing collection (or it's containing collection...) does not exist.
PermissionException - if the user does not have permission to add a collection, or add a member to a collection.
OverQuotaException - if this would result in being over quota.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

addAttachmentResource

public ContentResourceEdit addAttachmentResource(String name)
                                          throws IdInvalidException,
                                                 InconsistentException,
                                                 IdUsedException,
                                                 PermissionException
Create a new resource as an attachment to some other resource in the system, locked for update. Must commitResource() to make official, or cancelResource() when done! The new resource will be placed into a newly created collecion in the attachment collection, with an auto-generated id, and given the specified resource name within this collection.

Specified by:
addAttachmentResource in interface ContentHostingService
Parameters:
name - The name of the new resource, i.e. a partial id relative to the collection where it will live.
Returns:
a new ContentResource object.
Throws:
IdUsedException - if the resource name is already in use (not likely, as the containing collection is auto-generated!)
IdInvalidException - if the resource name is invalid.
InconsistentException - if the containing collection (or it's containing collection...) does not exist.
PermissionException - if the user does not have permission to add a collection, or add a member to a collection.

allowUpdateResource

public boolean allowUpdateResource(String id)
check permissions for updateResource().

Specified by:
allowUpdateResource in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to updateResource(id), false if not.

updateResource

public ContentResource updateResource(String id,
                                      String type,
                                      byte[] content)
                               throws PermissionException,
                                      IdUnusedException,
                                      TypeException,
                                      InUseException,
                                      OverQuotaException,
                                      ServerOverloadException
Update the body and or content type of an existing resource with the given resource id.

Specified by:
updateResource in interface ContentHostingService
Parameters:
id - The id of the resource.
type - The mime type string of the resource (if null, no change).
content - An array containing the bytes of the resource's content (if null, no change).
Returns:
a new ContentResource object.
Throws:
PermissionException - if the user does not have permission to add a resource to the containing collection or write the resource.
IdUnusedException - if the resource id is not defined.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.
OverQuotaException - if this would result in being over quota.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

editResource

public ContentResourceEdit editResource(String id)
                                 throws PermissionException,
                                        IdUnusedException,
                                        TypeException,
                                        InUseException
Access the resource with this resource id, locked for update. For non-collection resources only. Must commitEdit() to make official, or cancelEdit() when done! The resource content and properties are accessible from the returned Resource object.

Specified by:
editResource in interface ContentHostingService
Parameters:
id - The id of the resource.
Returns:
the ContentResource object found.
Throws:
PermissionException - if the user does not have permissions to read the resource or read through any containing collection.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.

allowGetResource

public boolean allowGetResource(String id)
check permissions for getResource().

Specified by:
allowGetResource in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to getResource(id), false if not.

checkResource

public void checkResource(String id)
                   throws PermissionException,
                          IdUnusedException,
                          TypeException
Check access to the resource with this local resource id. For non-collection resources only.

Specified by:
checkResource in interface ContentHostingService
Parameters:
id - The id of the resource.
Throws:
PermissionException - if the user does not have permissions to read the resource or read through any containing collection.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.

getResource

public ContentResource getResource(String id)
                            throws PermissionException,
                                   IdUnusedException,
                                   TypeException
Access the resource with this resource id. For non-collection resources only. The resource content and properties are accessible from the returned Resource object.

Specified by:
getResource in interface ContentHostingService
Parameters:
id - The resource id.
Returns:
the ContentResource object found.
Throws:
PermissionException - if the user does not have permissions to read the resource or read through any containing collection.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.

findResource

protected ContentResource findResource(String id)
                                throws TypeException
Access the resource with this resource id. For non-collection resources only. Internal find that doesn't do security or event tracking The resource content and properties are accessible from the returned Resource object.

Parameters:
id - The resource id.
Returns:
the ContentResource object found, or null if there's a problem.
Throws:
TypeException - if the resource is a collection.

allowRemoveResource

public boolean allowRemoveResource(String id)
check permissions for removeResource().

Specified by:
allowRemoveResource in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to removeResource(id), false if not.

removeResource

public void removeResource(String id)
                    throws PermissionException,
                           IdUnusedException,
                           TypeException,
                           InUseException
Remove a resource. For non-collection resources only.

Specified by:
removeResource in interface ContentHostingService
Parameters:
id - The resource id.
Throws:
PermissionException - if the user does not have permissions to read a containing collection, or to remove this resource.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.

removeResource

public void removeResource(ContentResourceEdit edit)
                    throws PermissionException
Remove a resource that is locked for update.

Specified by:
removeResource in interface ContentHostingService
Parameters:
edit - The ContentResourceEdit object to remove.
Throws:
PermissionException - if the user does not have permissions to read a containing collection, or to remove this resource.

addResourceToDeleteTable

public void addResourceToDeleteTable(ContentResourceEdit edit,
                                     String uuid,
                                     String userId)
                              throws PermissionException
Store the resource in a separate delete table

Parameters:
edit -
uuid -
userId -
Throws:
PermissionException
ServerOverloadException - if server is configured to save resource body in filesystem and attempt to read from filesystem fails.

addDeleteResource

public ContentResource addDeleteResource(String id,
                                         String type,
                                         byte[] content,
                                         ResourceProperties properties,
                                         String uuid,
                                         String userId,
                                         int priority)
                                  throws PermissionException
Throws:
PermissionException

allowRename

public boolean allowRename(String id,
                           String new_id)
check permissions for rename(). Note: for just this collection, not the members on down.

Specified by:
allowRename in interface ContentHostingService
Parameters:
id - The id of the collection.
Returns:
true if the user is allowed to rename(id), false if not.

rename

public String rename(String id,
                     String new_id)
              throws IdUnusedException,
                     TypeException,
                     PermissionException,
                     InUseException,
                     OverQuotaException,
                     InconsistentException,
                     IdUsedException,
                     ServerOverloadException
Rename a collection or resource.

Specified by:
rename in interface ContentHostingService
Parameters:
id - The id of the collection.
new_id - The desired id of the collection.
Returns:
The full id of the resource after the rename is completed.
Throws:
IdUnusedException - if the id does not exist.
TypeException - if the resource exists but is not a collection or resource.
PermissionException - if the user does not have permissions to rename
InUseException - if the id or a contained member is locked by someone else. collections, or remove any members of the collection.
IdUsedException - if copied item is a collection and the new id is already in use or if the copied item is not a collection and a unique id cannot be found in some arbitrary number of attempts (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.
OverQuotaException
InconsistentException

allowCopy

public boolean allowCopy(String id,
                         String new_id)
check permissions for copy().

Specified by:
allowCopy in interface ContentHostingService
Parameters:
id - The id of the new resource.
new_id - The desired id of the new resource.
Returns:
true if the user is allowed to copy(id,new_id), false if not.

copyIntoFolder

public String copyIntoFolder(String id,
                             String folder_id)
                      throws PermissionException,
                             IdUnusedException,
                             TypeException,
                             InUseException,
                             IdLengthException,
                             IdUniquenessException,
                             OverQuotaException,
                             InconsistentException,
                             IdUsedException,
                             ServerOverloadException
Copy a collection or resource from one location to another. Creates a new collection with an id similar to new_folder_id and recursively copies all nested collections and resources within thisCollection to the new collection.

Specified by:
copyIntoFolder in interface ContentHostingService
Parameters:
id - The id of the resource.
folder_id - The id of the folder in which the copy should be created.
Returns:
The full id of the new copy of the resource.
Throws:
PermissionException - if the user does not have permissions to read a containing collection, or to remove this resource.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.
IdLengthException - if the new id of the copied item (or any nested item) is longer than the maximum length of an id.
InconsistentException - if the destination folder (folder_id) is contained within the source folder (id).
IdUsedException - if a unique resource id cannot be found after some arbitrary number of attempts (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.
IdUniquenessException - if a unique id cannot be found in the new folder.
OverQuotaException

newName

protected String newName(String id,
                         String folder_id)
                  throws PermissionException,
                         IdUnusedException
Calculate a candidate for a resource id for a resource being copied/moved into a new folder.

Parameters:
id -
folder_id -
Throws:
PermissionException - if the user does not have permissions to read the properties for the existing resource.
IdUnusedException - if the resource id is not found.

moveIntoFolder

public String moveIntoFolder(String id,
                             String folder_id)
                      throws PermissionException,
                             IdUnusedException,
                             TypeException,
                             InUseException,
                             OverQuotaException,
                             IdUsedException,
                             InconsistentException,
                             ServerOverloadException
Move a resource or collection to a (different) folder. This may be accomplished by renaming the resource or by recursively renaming the collection and all enclosed members (no matter how deep) to effectively change their locations. Alternatively, it may be accomplished by copying the resource and recursively copying collections from their existing collection to the new collection and ultimately deleting the original resource(s) and/or collections(s).

Specified by:
moveIntoFolder in interface ContentHostingService
Parameters:
id - The id of the resource or collection to be moved.
folder_id - The id of the folder to which the resource should be moved.
Returns:
The full id of the resource after the move is completed.
Throws:
PermissionException - if the user does not have permissions to read a containing collection, or to remove this resource.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.
InconsistentException - if the containing collection does not exist.
InconsistentException - if the destination folder (folder_id) is contained within the source folder (id).
IdUsedException - if a unique resource id cannot be found after some arbitrary number of attempts (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.
OverQuotaException

moveCollection

protected String moveCollection(ContentCollectionEdit thisCollection,
                                String new_folder_id)
                         throws PermissionException,
                                IdUnusedException,
                                TypeException,
                                InUseException,
                                OverQuotaException,
                                IdUsedException,
                                ServerOverloadException
Move a collection to a new folder. Moves the existing collection or creates a new collection with an id similar to the new_folder_id (in which case the original collection is removed) and recursively moves all nested collections and resources within thisCollection to the new collection. When finished, thisCollection no longer exists, but the collection identified by the return value has the same structure and all of the members the original had (or copies of them).

Parameters:
thisCollection - The collection to be copied
new_folder_id - The desired id of the collection after it is moved.
Returns:
The full id of the moved collection.
Throws:
PermissionException - if the user does not have permissions to perform the operations
IdUnusedException - if the collection id is not found.
TypeException - if the resource is not a collection.
InUseException - if the collection is locked by someone else.
IdUsedException - if a unique resource id cannot be found after some arbitrary number of attempts to find a unique variation of the new_id (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to save content bodies in the server's filesystem and an error occurs trying to access the filesystem.
OverQuotaException

moveResource

protected String moveResource(ContentResourceEdit thisResource,
                              String new_id)
                       throws PermissionException,
                              IdUnusedException,
                              TypeException,
                              InUseException,
                              OverQuotaException,
                              IdUsedException,
                              ServerOverloadException
Move a resource to a new folder. Either creates a new resource with an id similar to the new_folder_id and and removes the original resource, or renames the resource with an id similar to the new id, which effectively moves the resource to a new location.

Parameters:
thisResource - The resource to be copied
new_id - The desired id of the resource after it is moved.
Returns:
The full id of the moved resource (which may be a variation on the new_id to ensure uniqueness within the new folder.
Throws:
PermissionException - if the user does not have permissions to perform the operations
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.
IdUsedException - if a unique resource id cannot be found after some arbitrary number of attempts to find a unique variation of the new_id (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to save content bodies in the server's filesystem and an error occurs trying to access the filesystem.
OverQuotaException

copy

public String copy(String id,
                   String new_id)
            throws PermissionException,
                   IdUnusedException,
                   TypeException,
                   InUseException,
                   OverQuotaException,
                   IdUsedException,
                   ServerOverloadException
Copy a resource or collection.

Specified by:
copy in interface ContentHostingService
Parameters:
id - The id of the resource.
new_id - The desired id of the new resource.
Returns:
The full id of the new copy of the resource.
Throws:
PermissionException - if the user does not have permissions to read a containing collection, or to remove this resource.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.
IdUsedException - if copied item is a collection and the new id is already in use or if the copied item is not a collection and a unique id cannot be found in some arbitrary number of attempts (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.
OverQuotaException
See Also:
method (preferred method for invocation from a tool).

copyResource

public String copyResource(ContentResource resource,
                           String new_id)
                    throws PermissionException,
                           IdUnusedException,
                           TypeException,
                           InUseException,
                           OverQuotaException,
                           IdUsedException,
                           ServerOverloadException
Copy a resource.

Parameters:
new_id - The desired id of the new resource.
Returns:
The full id of the new copy of the resource.
Throws:
PermissionException - if the user does not have permissions to read a containing collection, or to remove this resource.
IdUnusedException - if the resource id is not found.
TypeException - if the resource is a collection.
InUseException - if the resource is locked by someone else.
OverQuotaException - if copying the resource would exceed the quota.
IdUsedException - if a unique id cannot be found in some arbitrary number of attempts (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

copyCollection

public String copyCollection(ContentCollection thisCollection,
                             String new_id)
                      throws PermissionException,
                             IdUnusedException,
                             TypeException,
                             InUseException,
                             OverQuotaException,
                             IdUsedException
Copy a collection.

Parameters:
thisCollection - The collection to be copied
new_id - The desired id of the new collection.
Returns:
The full id of the new copy of the resource.
Throws:
PermissionException - if the user does not have permissions to perform the operations
IdUnusedException - if the collection id is not found.
TypeException - if the resource is not a collection.
InUseException - if the resource is locked by someone else.
IdUsedException - if the new collection id is already in use.
OverQuotaException

deepcopyCollection

protected String deepcopyCollection(ContentCollection thisCollection,
                                    String new_folder_id)
                             throws PermissionException,
                                    IdUnusedException,
                                    TypeException,
                                    InUseException,
                                    IdLengthException,
                                    IdUniquenessException,
                                    OverQuotaException,
                                    IdUsedException,
                                    ServerOverloadException
Make a deep copy of a collection. Creates a new collection with an id similar to new_folder_id and recursively copies all nested collections and resources within thisCollection to the new collection.

Parameters:
thisCollection - The collection to be copied
new_folder_id - The desired id of the new collection.
Returns:
The full id of the copied collection (which may be a slight variation on the desired id to ensure uniqueness).
Throws:
PermissionException - if the user does not have permissions to perform the operations
IdUnusedException - if the collection id is not found. ???
TypeException - if the resource is not a collection.
InUseException - if the collection is locked by someone else.
IdUsedException - if a unique id cannot be found for the new collection after some arbitrary number of attempts to find a unique variation of the new_folder_id (@see MAXIMUM_ATTEMPTS_FOR_UNIQUENESS).
ServerOverloadException - if the server is configured to save content bodies in the server's filesystem and an error occurs trying to access the filesystem.
IdLengthException
IdUniquenessException
OverQuotaException

commitResource

public void commitResource(ContentResourceEdit edit)
                    throws OverQuotaException,
                           ServerOverloadException
Commit the changes made, and release the lock. The Object is disabled, and not to be used after this call.

Specified by:
commitResource in interface ContentHostingService
Parameters:
edit - The ContentResourceEdit object to commit.
Throws:
OverQuotaException - if this would result in being over quota (the edit is then cancled).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

commitResource

public void commitResource(ContentResourceEdit edit,
                           int priority)
                    throws OverQuotaException,
                           ServerOverloadException
Commit the changes made, and release the lock. The Object is disabled, and not to be used after this call.

Specified by:
commitResource in interface ContentHostingService
Parameters:
edit - The ContentResourceEdit object to commit.
priority - The notification priority of this commit.
Throws:
OverQuotaException - if this would result in being over quota (the edit is then cancled).
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

commitResourceEdit

protected void commitResourceEdit(ContentResourceEdit edit,
                                  int priority)
                           throws ServerOverloadException
Commit the changes made, and release the lock - no quota check. The Object is disabled, and not to be used after this call.

Parameters:
edit - The ContentResourceEdit object to commit.
priority - The notification priority of this commit.
Throws:
ServerOverloadException

cancelResource

public void cancelResource(ContentResourceEdit edit)
Cancel the changes made object, and release the lock. The Object is disabled, and not to be used after this call.

Specified by:
cancelResource in interface ContentHostingService
Parameters:
edit - The ContentResourceEdit object to commit.

allowGetProperties

public boolean allowGetProperties(String id)
check permissions for getProperties().

Specified by:
allowGetProperties in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to getProperties(id), false if not.

getProperties

public ResourceProperties getProperties(String id)
                                 throws PermissionException,
                                        IdUnusedException
Access the properties of a resource with this resource id, either collection or resource.

Specified by:
getProperties in interface ContentHostingService
Parameters:
id - The resource id.
Returns:
the ResourceProperties object for this resource.
Throws:
PermissionException - if the user does not have permissions to read properties on this object or read through containing collections.
IdUnusedException - if the resource id is not found.

allowAddProperty

public boolean allowAddProperty(String id)
check permissions for addProperty().

Specified by:
allowAddProperty in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to addProperty(id), false if not.

addProperty

public ResourceProperties addProperty(String id,
                                      String name,
                                      String value)
                               throws PermissionException,
                                      IdUnusedException,
                                      TypeException,
                                      InUseException,
                                      ServerOverloadException
Add / update a property for a resource, either collection or resource.

Specified by:
addProperty in interface ContentHostingService
Parameters:
id - The resource id.
name - The properties name to add or update
value - The new value for the property.
Returns:
the ResourceProperties object for this resource.
Throws:
PermissionException - if the user does not have premissions to write properties on this object or read through containing collections.
IdUnusedException - if the resource id is not found.
TypeException - if any property requested cannot be set (it may be live).
InUseException - if the resource is locked by someone else.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

allowRemoveProperty

public boolean allowRemoveProperty(String id)
check permissions for removeProperty().

Specified by:
allowRemoveProperty in interface ContentHostingService
Parameters:
id - The id of the new resource.
Returns:
true if the user is allowed to removeProperty(id), false if not.

removeProperty

public ResourceProperties removeProperty(String id,
                                         String name)
                                  throws PermissionException,
                                         IdUnusedException,
                                         TypeException,
                                         InUseException,
                                         ServerOverloadException
Remove a property from a resource, either collection or resource.

Specified by:
removeProperty in interface ContentHostingService
Parameters:
id - The resource id.
name - The property name to be removed from the resource.
Returns:
the ResourceProperties object for this resource.
Throws:
PermissionException - if the user does not have premissions to write properties on this object or read through containing collections.
IdUnusedException - if the resource id is not found.
TypeException - if the property named cannot be removed.
InUseException - if the resource is locked by someone else.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

getUrl

public String getUrl(String id)
Access the resource URL from a resource id.

Specified by:
getUrl in interface ContentHostingService
Parameters:
id - The resource id.
Returns:
The resource URL.

getUrl

public String getUrl(String id,
                     String rootProperty)
Access the alternate URL which can be used to access the entity.

Specified by:
getUrl in interface ContentHostingService
Parameters:
id - The resource id.
rootProperty - The name of the entity property whose value controls which alternate reference URL is requested. If null, the native 'raw' URL is requested.
Returns:
The resource URL.

getAlternateReferenceRoot

protected String getAlternateReferenceRoot(String id,
                                           String rootProperty)
Compute an alternate root for a reference, based on the value of the specified property.

Parameters:
rootProperty - The property name.
Returns:
The alternate root, or "" if there is none.

getReference

public String getReference(String id)
Access the internal reference from a resource id.

Specified by:
getReference in interface ContentHostingService
Parameters:
id - The resource id.
Returns:
The internal reference from a resource id.

getContainingCollectionId

public String getContainingCollectionId(String id)
Access the resource id of the collection which contains this collection or resource.

Specified by:
getContainingCollectionId in interface ContentHostingService
Parameters:
id - The resource id (reference, or URL) of the ContentCollection or ContentResource
Returns:
the resource id (reference, or URL, depending on the id parameter) of the collection which contains this resource.

getDepth

public int getDepth(String resourceId,
                    String baseCollectionId)
Get the depth of the resource/collection object in the hireachy based on the given collection id

Specified by:
getDepth in interface ContentHostingService
Parameters:
resourceId - The Id of the resource/collection object to be tested
baseCollectionId - The Id of the collection as the relative root level
Returns:
the integer value reflecting the relative hierarchy depth of the test resource/collection object based on the given base collection level

isRootCollection

public boolean isRootCollection(String id)
Test if this id (reference, or URL) refers to the root collection.

Specified by:
isRootCollection in interface ContentHostingService
Parameters:
id - The resource id (reference, or URL) of a ContentCollection
Returns:
true if this is the root collection

newResourceProperties

public ResourcePropertiesEdit newResourceProperties()
Construct a stand-alone, not associated with any particular resource, ResourceProperties object.

Specified by:
newResourceProperties in interface ContentHostingService
Returns:
The new ResourceProperties object.

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.

handleAccessResource

protected void handleAccessResource(HttpServletRequest req,
                                    HttpServletResponse res,
                                    Reference ref,
                                    Collection copyrightAcceptedRefs)
                             throws PermissionException,
                                    IdUnusedException,
                                    ServerOverloadException,
                                    CopyrightException
Process the access request for a resource.

Parameters:
req -
res -
ref -
copyrightAcceptedRefs -
Throws:
PermissionException
IdUnusedException
ServerOverloadException
CopyrightException

handleAccessCollection

protected void handleAccessCollection(HttpServletRequest req,
                                      HttpServletResponse res,
                                      Reference ref,
                                      Collection copyrightAcceptedRefs)
                               throws PermissionException,
                                      IdUnusedException,
                                      ServerOverloadException
Process the access request for a collection, producing the "apache" style HTML file directory listing (complete with index.html redirect if found).

Parameters:
req -
res -
ref -
copyrightAcceptedRefs -
Throws:
PermissionException
IdUnusedException
ServerOverloadException

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.

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.

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.

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.

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.

archiveResources

public String archiveResources(List attachments,
                               Document doc,
                               Stack stack,
                               String archivePath)
Archive the specified list of resources.

Specified by:
archiveResources in interface ContentHostingService
Parameters:
attachments - A list of the resources to archive.
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.
Returns:
A log of status messages from the archive.

WTUserIdTrans

protected void WTUserIdTrans(Element el,
                             Map userIdTrans)
Replace the WT user id with the new qualified id

Parameters:
el - The XML element holding the perproties

merge

public String merge(String siteId,
                    Element root,
                    String archivePath,
                    String mergeId,
                    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 archive.

importEntities

public void importEntities(String fromContext,
                           String toContext,
                           List resourceIds)
import tool(s) contents from the source context into the destination context

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

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.

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

syncWithSiteChangeResources

public void syncWithSiteChangeResources(Site site,
                                        EntityProducer.ChangeType change)
{@inheritDoc}


syncWithSiteChangeDropbox

public void syncWithSiteChangeDropbox(Site site,
                                      EntityProducer.ChangeType change)
{@inheritDoc}


enableResources

protected void enableResources(Site site)
Make sure a home in resources exists for the site.

Parameters:
site - The site.

disableResources

protected void disableResources(Site site)
Remove resources area for a site.

Parameters:
site - The site.

enableDropbox

protected void enableDropbox(Site site)
Make sure a home in resources for dropbox exists for the site.

Parameters:
site - The site.

disableDropbox

protected void disableDropbox(Site site)
Remove resources area for a site.

Parameters:
site - The site.

archiveCollection

protected void archiveCollection(ContentCollection collection,
                                 Document doc,
                                 Stack stack,
                                 String storagePath,
                                 String siteCollectionId,
                                 StringBuffer results)
Archive the collection, then the members of the collection - recursively for collection members.

Parameters:
collection - The collection whose members are to be archived.
doc - The document to contain the xml.
stack - The stack of elements, the top of which will be the containing element of the "collection" or "resource" element.
storagePath - The path to the folder where we are writing files.
siteCollectionId - The resource id of the site collection.
results - A log of messages from the archive.

archiveResource

protected String archiveResource(ContentResource resource,
                                 Document doc,
                                 Stack stack,
                                 String storagePath,
                                 String siteCollectionId)
Archive a singe resource

Parameters:
resource - The content resource to archive
doc - The XML document.
stack - The stack of elements.
storagePath - The path to the folder where we are writing files.
siteCollectionId - The resource id of the site collection (optional).
Returns:
A log of messages from the archive.

mergeCollection

protected ContentCollection mergeCollection(Element element)
                                     throws PermissionException,
                                            InconsistentException,
                                            IdInvalidException
Merge in a collection from an XML DOM definition. Take whole if not defined already. Ignore if already here.

Parameters:
element - The XML DOM element containing the collection definition.
Returns:
a new ContentCollection object, or null if it was not created.
Throws:
PermissionException - if the user does not have permission to add a collection.
InconsistentException - if the containing collection does not exist.
IdInvalidException - if the id is not valid.

mergeResource

protected ContentResource mergeResource(Element element)
                                 throws PermissionException,
                                        InconsistentException,
                                        IdInvalidException,
                                        OverQuotaException,
                                        ServerOverloadException
Merge in a resource from an XML DOM definition. Ignore if already defined. Take whole if not.

Parameters:
element - The XML DOM element containing the collection definition.
Returns:
a new ContentResource object, or null if it was not created.
Throws:
PermissionException - if the user does not have permission to add a resource.
InconsistentException - if the containing collection does not exist.
IdInvalidException - if the id is not valid.
OverQuotaException - if this would result in being over quota.
ServerOverloadException - if the server is configured to write the resource body to the filesystem and the save fails.

mergeResource

protected ContentResource mergeResource(Element element,
                                        byte[] body)
                                 throws PermissionException,
                                        InconsistentException,
                                        IdInvalidException,
                                        OverQuotaException,
                                        ServerOverloadException
Merge in a resource from an XML DOM definition and a body bytes array. Ignore if already defined. Take whole if not.

Parameters:
element - The XML DOM element containing the collection definition.
body - The body bytes.
Returns:
a new ContentResource object, or null if it was not created.
Throws:
PermissionException - if the user does not have permission to add a resource.
InconsistentException - if the containing collection does not exist.
IdInvalidException - if the id is not valid.
OverQuotaException - if this would result in being over quota.
ServerOverloadException

isolateContainingId

protected String isolateContainingId(String id)
Find the containing collection id of a given resource id.

Parameters:
id - The resource id.
Returns:
the containing collection id.

isolateName

protected String isolateName(String id)
Find the resource name of a given resource id.

Parameters:
id - The resource id.
Returns:
the resource name.

fixTypeAndId

protected Hashtable fixTypeAndId(String id,
                                 String type)
Check the fixed type and id infomation: The same or better content type based on the known type for this id's extension, if any. The same or added extension id based on the know MIME type, if any Only if the type is the unknown type already.

Parameters:
id - The resource id with possible file extension to check.
type - The content type.
Returns:
the best guess content type based on this resource's id and resource id with extension based on this resource's MIME type.

overQuota

protected boolean overQuota(ContentResourceEdit edit)
Test if this resource edit would place the account" over quota.

Parameters:
edit - The proposed resource edit.
Returns:
true if this change would palce the "account" over quota, false if not.

bytes2k

protected long bytes2k(long bytes)
Convert bytes to Kbytes, rounding up, and counting even 0 bytes as 1 k.

Parameters:
bytes - The size in bytes.
Returns:
The size in Kbytes, rounded up.

generateCollections

protected void generateCollections(String target)
Attempt to create any collections needed so that the parameter collection exists.

Parameters:
target - The collection that we want to exist.

getSiteCollection

public String getSiteCollection(String siteId)
Return the collection id of the root collection for this site id.

Specified by:
getSiteCollection in interface ContentHostingService
Parameters:
siteId - The site id.
Returns:
The collection id which is the root collection for this site.

isPubView

public boolean isPubView(String id)
Does this resource support public view?

Specified by:
isPubView in interface ContentHostingService
Parameters:
id - The resource id to check.
Returns:
true if this resource supports public view, false if not.

isInheritingPubView

public boolean isInheritingPubView(String id)
Does this resource inherit public view by having it set in a containing folder (not counting it's own setting)?

Specified by:
isInheritingPubView in interface ContentHostingService
Parameters:
id - The resource id to check.
Returns:
true if this resource inherits public view, false if not.

setPubView

public void setPubView(String id,
                       boolean pubview)
Set this resource or collection to the pubview setting.

Specified by:
setPubView in interface ContentHostingService
Parameters:
id - The resource or collection id.
pubview - The desired public view setting.

findResources

public List findResources(String type,
                          String primaryMimeType,
                          String subMimeType)
Find the resources this user has read access to from all worksites of the appropriate type.

Specified by:
findResources in interface ContentHostingService
Parameters:
type - this is the ResourceProperties.PROP_STRUCTOBJ_TYPE for stuctured objects or ResourceProperties.FILE_TYPE for file resources or null for all resources.
primaryMimeType - The primary mime type (ie. the "text" of "text/xml") This may be null to include all resources
subMimeType - The sub type (ie, the "xml" of "text/xml") This may be null to include all resources of the primary mime type if specified.
Returns:
List of ContentResource objects that match the search criteria

getCollectionMap

public Map getCollectionMap()
Return a map of Worksite collections roots that the user has access to.

Specified by:
getCollectionMap in interface ContentHostingService
Returns:
Map of worksite title (String) to worksite resource root id (String)

getFlatResources

protected List getFlatResources(String parentId)
get all the resources under a given directory.

Parameters:
parentId -
Returns:
List of all the ContentResource objects under this directory.

eliminateDuplicates

public void eliminateDuplicates(Collection resourceIds)
Eliminate from the collection any duplicates as well as any items that are contained within another item whose resource-id is in the collection.

Specified by:
eliminateDuplicates in interface ContentHostingService
Parameters:
resourceIds - A collection of strings (possibly empty) identifying items and/or collections.

filterArtifacts

protected List filterArtifacts(List artifacts,
                               String type,
                               String primaryMimeType,
                               String subMimeType)

getDropboxCollection

public String getDropboxCollection()
Description copied from interface: ContentHostingService
Access the default dropbox collection id for the current request.
If the current user is a dropbox maintainer for the current site, return the site's dropbox area.
Otherwis return the current user's collection within the site's dropbox.

Specified by:
getDropboxCollection in interface ContentHostingService
Returns:
The default dropbox collection id for the current request.

getDropboxCollection

public String getDropboxCollection(String siteId)
Description copied from interface: ContentHostingService
Access the default dropbox collection id for the current request.
If the current user is a dropbox maintainer for the current site, return the site's dropbox area.
Otherwis return the current user's collection within the site's dropbox.

Specified by:
getDropboxCollection in interface ContentHostingService
Parameters:
siteId - The site id.
Returns:
The default dropbox collection id for the site.

getDropboxDisplayName

public String getDropboxDisplayName()
Access the default dropbox collection display name for the current request. If the current user has permission to modify the site's dropbox collection, this is returned. Otherwise, the current user's collection within the site's dropbox is returned.

Specified by:
getDropboxDisplayName in interface ContentHostingService
Returns:
The default dropbox collection display name for the current request.

getDropboxDisplayName

public String getDropboxDisplayName(String siteId)
Access the default dropbox collection display name for the site. If the current user has permission to modify the site's dropbox collection, this is returned. Otherwise, the current user's collection within the site's dropbox is returned.

Specified by:
getDropboxDisplayName in interface ContentHostingService
Parameters:
siteId - the Site id.
Returns:
The default dropbox collection display name for the site.

createDropboxCollection

public void createDropboxCollection()
Create the site's dropbox collection and one for each qualified user that the current user can make.

Specified by:
createDropboxCollection in interface ContentHostingService

createDropboxCollection

public void createDropboxCollection(String siteId)
Create the site's dropbox collection and one for each qualified user that the current user can make.

Specified by:
createDropboxCollection in interface ContentHostingService
Parameters:
siteId - the Site id.

isDropboxMaintainer

public boolean isDropboxMaintainer()
Determine whether the default dropbox collection id for this user in this site is the site's entire dropbox collection or just the current user's collection within the site's dropbox.

Specified by:
isDropboxMaintainer in interface ContentHostingService
Returns:
True if user sees all dropboxes in the site, false otherwise.

isDropboxMaintainer

public boolean isDropboxMaintainer(String siteId)
Determine whether the default dropbox collection id for this user in some site is the site's entire dropbox collection or just the current user's collection within the site's dropbox.

Specified by:
isDropboxMaintainer in interface ContentHostingService
Returns:
True if user sees all dropboxes in the site, false otherwise.

refresh

public Object refresh(Object key,
                      Object oldValue,
                      Event event)
Get a new value for this key whose value has already expired in the cache.

Specified by:
refresh in interface CacheRefresher
Parameters:
key - The key whose value has expired and needs to be refreshed.
oldValue - The old exipred value of the key.
event - The event which triggered this refresh.
Returns:
a new value for use in the cache for this key; if null, the entry will be removed.