Interface ContentService
- All Known Implementing Classes:
ContentServiceImpl,RoutingContentService
Implementations of this service are primarily responsible for ensuring that the correct store is used to access content, and that reads and writes for the same node reference are routed to the same store instance.
The mechanism for selecting an appropriate store is not prescribed by the interface, but typically the decision will be made on the grounds of content type.
Whereas the content stores have no knowledge of nodes other than their references, the ContentService is responsible for ensuring that all the relevant node-content relationships are maintained.
- Author:
- Derek Hulley
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetRawReader(String contentUrl) Fetch content from the low-level stores using a content URL.Gets a reader for the content associated with the given node property.getStorageProperties(NodeRef nodeRef, QName propertyQName) Gets a key-value (String-String) collection of storage headers/properties with their respective values for a specific node reference.longGets the remaing available space in the underlying content store.longGets the total space of the underlying content store (not exclusively Alfresco-controlled binaries).Gets a writer to a temporary location.Get a content writer for the given node property, choosing to optionally have the node property updated automatically when the content stream closes.booleanChecks if the system and at least one store supports the retrieving of direct access URLs.default booleanisContentDirectUrlEnabled(NodeRef nodeRef) Deprecated.booleanisContentDirectUrlEnabled(NodeRef nodeRef, QName propertyQName) Checks if the system and store supports the retrieving of a direct accessURLfor the given node.default DirectAccessUrlrequestContentDirectUrl(NodeRef nodeRef, boolean attachment) Deprecated.default DirectAccessUrlrequestContentDirectUrl(NodeRef nodeRef, boolean attachment, Long validFor) Deprecated.default DirectAccessUrlrequestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment) Gets a presigned URL to directly access the content.default DirectAccessUrlrequestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment, Long validFor) Gets a presigned URL to directly access the content.requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment, Long validFor, String fileName) Gets a presigned URL to directly access the content.default booleanrequestRestoreContentFromArchive(NodeRef nodeRef, QName propertyQName, Map<String, Serializable> restoreParams) Submit a request to restore content from archive (offline) state.default booleanrequestSendContentToArchive(NodeRef nodeRef, QName propertyQName, Map<String, Serializable> archiveParams) Submit a request to send content to archive (offline) state.
-
Method Details
-
getStoreTotalSpace
long getStoreTotalSpace()Gets the total space of the underlying content store (not exclusively Alfresco-controlled binaries).- Returns:
- Returns the total, possibly approximate, size (in bytes) of of the store or -1 if no size data is available.
- Since:
- 3.3.3
-
getStoreFreeSpace
long getStoreFreeSpace()Gets the remaing available space in the underlying content store.- Returns:
- Returns the total, possibly approximate, remaining space (in bytes) available to store content or -1 if no size data is available.
- Since:
- 3.3.3
-
getRawReader
Fetch content from the low-level stores using a content URL. None of the metadata associated with the content will be populated. This method should be used only to stream the binary data out when no other metadata is required.null is never returned, but the reader should always be checked for
existence.- Parameters:
contentUrl- a content store URL- Returns:
- Returns a reader for the URL that needs to be checked.
-
getReader
@Auditable(parameters={"nodeRef","propertyQName"}) ContentReader getReader(NodeRef nodeRef, QName propertyQName) throws InvalidNodeRefException, InvalidTypeException Gets a reader for the content associated with the given node property.If a content URL is present for the given node then a reader must be returned. The
existsmethod should then be used to detect 'missing' content.- Parameters:
nodeRef- a reference to a node having a content propertypropertyQName- the name of the property, which must be of type content- Returns:
- Returns a reader for the content associated with the node property, or null if no content has been written for the property
- Throws:
InvalidNodeRefException- if the node doesn't existInvalidTypeException- if the node is not of type content- See Also:
-
getWriter
@Auditable(parameters={"nodeRef","propertyQName","update"}) ContentWriter getWriter(NodeRef nodeRef, QName propertyQName, boolean update) throws InvalidNodeRefException, InvalidTypeException Get a content writer for the given node property, choosing to optionally have the node property updated automatically when the content stream closes.If the update flag is off, then the state of the node property will remain unchanged regardless of the state of the written binary data. If the flag is on, then the node property will be updated on the same thread as the code that closed the write channel.
If no node is supplied, then the writer will provide a stream into the backing content store, but will not be associated with any new or previous content.
NOTE: The content URL provided will be registered for automatic cleanup in the event that the transaction, in which this method was called, rolls back. If the transaction is successful, the writer may still be open and available for use but the underlying binary will not be cleaned up subsequently. The recommended pattern is to group calls to retrieve the writer in the same transaction as the calls to subsequently update and close the write stream - including setting of the related content properties.- Parameters:
nodeRef- a reference to a node having a content property, or null to just get a valid writer into a backing content store.propertyQName- the name of the property, which must be of type contentupdate- true if the property must be updated atomically when the content write stream is closed (attaches a listener to the stream); false if the client code will perform the updates itself.- Returns:
- Returns a writer for the content associated with the node property
- Throws:
InvalidNodeRefException- if the node doesn't existInvalidTypeException- if the node property is not of type content
-
getTempWriter
Gets a writer to a temporary location. The longevity of the stored temporary content is determined by the system.- Returns:
- Returns a writer onto a temporary location
-
isContentDirectUrlEnabled
boolean isContentDirectUrlEnabled()Checks if the system and at least one store supports the retrieving of direct access URLs.- Returns:
trueif direct access URLs retrieving is supported,falseotherwise
-
isContentDirectUrlEnabled
Deprecated.Checks if the system and store supports the retrieving of a direct accessURLfor the given node.- Returns:
trueif direct access URLs retrieving is supported for the node,falseotherwise
-
isContentDirectUrlEnabled
Checks if the system and store supports the retrieving of a direct accessURLfor the given node.- Parameters:
nodeRef- a reference to a node having a content propertypropertyQName- the name of the property, which must be of type content- Returns:
trueif direct access URLs retrieving is supported for the node,falseotherwise
-
requestContentDirectUrl
Deprecated.Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
nodeRef- Node ref for which to obtain the direct accessURL.attachment-trueif an attachment URL is requested,falsefor an embeddedURL.- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information.
-
requestContentDirectUrl
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment) Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
nodeRef- Node ref for which to obtain the direct accessURL.propertyQName- the name of the property, which must be of type contentattachment-trueif an attachment URL is requested,falsefor an embeddedURL.- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information.
-
requestContentDirectUrl
@Auditable(parameters={"nodeRef","validFor"}) @Deprecated default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, boolean attachment, Long validFor) Deprecated.Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
nodeRef- Node ref for which to obtain the direct accessURL.attachment-trueif an attachment URL is requested,falsefor an embeddedURL.validFor- The time at which the direct accessURLwill expire.- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information.
-
requestContentDirectUrl
@Auditable(parameters={"nodeRef","propertyQName","validFor"}) default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment, Long validFor) Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
nodeRef- Node ref for which to obtain the direct accessURL.propertyQName- the name of the property, which must be of type contentattachment-trueif an attachment URL is requested,falsefor an embeddedURL.validFor- The time at which the direct accessURLwill expire.- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information.
-
requestContentDirectUrl
@Auditable(parameters={"nodeRef","propertyQName","validFor"}) DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment, Long validFor, String fileName) Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
nodeRef- Node ref for which to obtain the direct accessURL.propertyQName- the name of the property, which must be of type contentattachment-trueif an attachment URL is requested,falsefor an embeddedURL.validFor- The time at which the direct accessURLwill expire.fileName- Optional name for the file when downloaded- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information.
-
getStorageProperties
@Auditable(parameters={"nodeRef","propertyQName"}) default Map<String,String> getStorageProperties(NodeRef nodeRef, QName propertyQName) Gets a key-value (String-String) collection of storage headers/properties with their respective values for a specific node reference. A particular Cloud Connector will fill in that data with Cloud Storage Provider generic data. Map may be also filled in with entries consisting of pre-defined Alfresco keys ofObjectStoragePropsand their values. If empty Map is returned - no connector is present or connector is not supporting retrieval of the properties or cannot determine the properties.- Parameters:
nodeRef- a reference to a node having a content propertypropertyQName- the name of the property, which must be of type content- Returns:
- Returns a key-value (String-String) collection of storage headers/properties with their respective values for a given
NodeRef.
-
requestSendContentToArchive
@Auditable(parameters={"nodeRef","propertyQName","archiveParams"}) default boolean requestSendContentToArchive(NodeRef nodeRef, QName propertyQName, Map<String, Serializable> archiveParams) Submit a request to send content to archive (offline) state. If no connector is present or connector is not supporting sending to archive, thenUnsupportedOperationExceptionwill be returned. Specific connector will decide which storage class/tier will be set for content.- Parameters:
nodeRef- a reference to a node having a content propertypropertyQName- the name of the property, which must be of type contentarchiveParams- a map of String-Serializable parameters defining Storage Provider specific request parameters (can be empty).- Returns:
- true when request successful, false when unsuccessful.
- Throws:
UnsupportedOperationException- when method not implemented
-
requestRestoreContentFromArchive
@Auditable(parameters={"nodeRef","propertyQName","restoreParams"}) default boolean requestRestoreContentFromArchive(NodeRef nodeRef, QName propertyQName, Map<String, Serializable> restoreParams) Submit a request to restore content from archive (offline) state. If no connector is present or connector is not supporting restoring fom archive, thenUnsupportedOperationExceptionwill be returned. One of input parameters of this method is a map (String-Serializable) of Storage Provider specific input needed to perform proper restore. Keys of this map should be restricted toContentRestoreParamsenumeration. For AWS S3 map can indicating expiry days, Glacier restore tier. For Azure Blob map can indicate rehydrate priority.- Parameters:
nodeRef- a reference to a node having a content propertypropertyQName- the name of the property, which must be of type contentrestoreParams- a map of String-Serializable parameters defining Storage Provider specific request parameters (can be empty).- Returns:
- true when request successful, false when unsuccessful.
- Throws:
UnsupportedOperationException- when method not implemented
-