public class DefaultConfigurableContentManager extends Object implements ConfigurableContentManager
Default ConfigurableContentManager
implementation. This implementation uses the CurrentTenantService
to set the scope of the operations of the content provider.
Modifier and Type | Field and Description |
---|---|
static String |
PRE_PROCESS_ORIGINAL_FILE_NAME |
static String |
PRE_PROCESS_PROCESSED_FILE_NAME |
Constructor and Description |
---|
DefaultConfigurableContentManager(List<ContentProvider> contentProviders,
CurrentTenantService currentTenantService,
CurrentUserService currentUserService,
org.springframework.transaction.PlatformTransactionManager transactionManager)
Constructor for the
ConfigurableContentManager . |
Modifier and Type | Method and Description |
---|---|
ContentReference |
addContent(ContentInfo contentInfo,
org.springframework.core.io.Resource resource,
long inputStreamLength)
Add content with the specified
ContentInfo and the content itself as InputStream . |
void |
addContentProvider(ContentProvider contentProvider)
Add a
ContentProvider to the content manager. |
void |
deleteContent()
Deletes all the content of the content manager.
|
int |
deleteContent(ContentReference contentReference)
Deletes all versions of the specified
ContentReference such that the passed in ContentReference cannot be used anymore to retrieve content. |
void |
deleteContent(ContentReference contentReference,
String version)
Deletes a specific version of the specified
ContentReference such that the passed in ContentReference cannot be used anymore to retrieve content with that
version. |
void |
deleteContent(String contentSourceId)
Deletes the content that is associated to the supplied ContentSourceId.
|
org.springframework.core.io.Resource |
getContent(ContentReference contentReference)
Returns the latest version of the content.
|
org.springframework.core.io.Resource |
getContent(ContentReference contentReference,
String version)
Returns the specified version of the content.
|
byte[] |
getContentAsBytes(ContentReference contentReference)
Returns the latest version of the content as a byte array.
|
byte[] |
getContentAsBytes(ContentReference contentReference,
String version)
Returns the specified version of the content as a byte array.
|
Optional<ContentMetadata> |
getContentMetadata(ContentReference contentReference)
Returns the metadata of the latest version of the content.
|
Optional<ContentMetadata> |
getContentMetadata(ContentReference contentReference,
String version)
Returns the metadata of the supplied version of the content.
|
List<ContentProvider> |
getContentProviders()
Returns the
ContentProvider s. |
Optional<ContentReference> |
getContentReference(String contentReferenceId)
Gets the content reference associated to the supplied ContentReferenceId.
|
List<ContentReference> |
getContentReferences(String contentSourceId)
Gets a list of all the content references associated to the supplied ContentSourceId.
|
List<String> |
getContentVersions(ContentReference contentReference)
Returns a list with all the versions of the content of the specified
ContentReference . |
ContentProvider |
getDefaultContentProvider()
Returns the default
ContentProvider configured for the content manager instance. |
void |
processContent(ContentScope contentScope,
ContentProcessor contentProcessor)
Process all content with the given content processor
|
void |
setContentListeners(List<ContentListener> contentListeners)
Set the
ContentListener s for the content manager. |
void |
setContentPreProcessingConfiguration(ContentPreProcessingConfiguration contentPreProcessingConfiguration)
Set the
ContentPreProcessingConfiguration which is required if you want to pre process the content added or updated in a separate job. |
void |
setContentSourceId(ContentReference contentReference,
String contentSourceId)
Sets the ContentSourceId for a selected
ContentReference . |
ContentReference |
updateContent(ContentReference contentReference,
org.springframework.core.io.Resource resource,
long inputStreamLength,
ContentMetadata contentMetadata)
This method behaves exactly like calling
ContentManager.updateContent(ContentReference, Resource, long, ContentMetadata, boolean) with the last parameter set to false. |
ContentReference |
updateContent(ContentReference contentReference,
org.springframework.core.io.Resource resource,
long inputStreamLength,
ContentMetadata contentMetadata,
boolean overwriteVersion)
Updates the the content and the metadata of the specified
ContentReference with the specified InputStream and ContentMetadata , with the option to
overwrite te existing version. |
void |
updateContentMetadata(ContentReference contentReference,
ContentMetadata contentMetadata)
Updates the content metadata.
|
public static final String PRE_PROCESS_ORIGINAL_FILE_NAME
public static final String PRE_PROCESS_PROCESSED_FILE_NAME
public DefaultConfigurableContentManager(List<ContentProvider> contentProviders, CurrentTenantService currentTenantService, CurrentUserService currentUserService, org.springframework.transaction.PlatformTransactionManager transactionManager)
Constructor for the ConfigurableContentManager
. It requires a list of content providers and the current tenant service. The first element of the list of content
providers is considered to be the default one.
contentProviders
- A list of content providers that can be used with this content manager.currentTenantService
- the current tenant service that will be used to establish the content scope of the content manager instancecurrentUserService
- the current user service used to get the current user for the content pre processing jobstransactionManager
- the transaction managerIllegalArgumentException
- if the current tenant service is null or if the supplied list of content providers is null, if it contains null values or if it not contains
at least a valid content provider@Transactional public ContentReference addContent(ContentInfo contentInfo, org.springframework.core.io.Resource resource, long inputStreamLength)
ContentManager
Add content with the specified ContentInfo
and the content itself as InputStream
. The provided InputStream
will always be closed. This method
triggers the ContentListener.contentAdded(ContentEvent)
method of the registered content listeners.
addContent
in interface ContentManager
contentInfo
- the content inforesource
- the content as input streaminputStreamLength
- the length of the input stream@Transactional(readOnly=true) public org.springframework.core.io.Resource getContent(ContentReference contentReference)
ContentManager
Returns the latest version of the content. The version of the specified ContentReference
is not taken into account.
getContent
in interface ContentManager
contentReference
- the content reference of the content to be returned@Transactional(readOnly=true) public byte[] getContentAsBytes(ContentReference contentReference)
ContentManager
Returns the latest version of the content as a byte array.
Note
|
Whenever possible you should use the stream-based content access methods as they will allow large content to be processed without requiring that the whole content be loaded into memory at the same time. |
getContentAsBytes
in interface ContentManager
contentReference
- the content reference of the content to be returned@Transactional(readOnly=true) public org.springframework.core.io.Resource getContent(ContentReference contentReference, String version)
ContentManager
Returns the specified version of the content. The version of the specified ContentReference
is not taken into account.
getContent
in interface ContentManager
contentReference
- the content reference of the content to be returnedversion
- the version of the content to be returned@Transactional(readOnly=true) public byte[] getContentAsBytes(ContentReference contentReference, String version)
ContentManager
Returns the specified version of the content as a byte array.
Note
|
Whenever possible you should use the stream-based content access methods as they will allow large content to be processed without requiring that the whole content be loaded into memory at the same time. |
getContentAsBytes
in interface ContentManager
contentReference
- the content reference of the content to be returned@Cacheable(value="edorasGear-contentMetadataByContentReferenceId", condition="#contentReference != null", key="#contentReference.getId()") public Optional<ContentMetadata> getContentMetadata(ContentReference contentReference)
ContentManager
Returns the metadata of the latest version of the content. The version of the specified ContentReference
is not taken into account.
getContentMetadata
in interface ContentManager
contentReference
- the content reference of the content to be returnedOptional
content metadata object of the specified content reference.public Optional<ContentMetadata> getContentMetadata(ContentReference contentReference, String version)
ContentManager
Returns the metadata of the supplied version of the content. The version of the specified ContentReference
is not taken into account.
getContentMetadata
in interface ContentManager
contentReference
- the content reference of the content to be returnedversion
- the version@Transactional(readOnly=true) @Cacheable(value="edorasGear-contentVersionsByContentReferenceId", condition="#contentReference != null", key="#contentReference.getId()") public List<String> getContentVersions(ContentReference contentReference)
ContentManager
Returns a list with all the versions of the content of the specified ContentReference
. The first entry of the list holds the first version and the last entry the
last one.
getContentVersions
in interface ContentManager
contentReference
- the content reference of the content versions to be returned@Transactional(readOnly=true) @Cacheable(value="edorasGear-contentReferencesByContentSourceId", condition="#contentSourceId != null", key="#contentSourceId") public List<ContentReference> getContentReferences(String contentSourceId)
ContentManager
Gets a list of all the content references associated to the supplied ContentSourceId. In case of a multi-versioned content reference, the last version is retrieved.
getContentReferences
in interface ContentManager
contentSourceId
- the content source id@Transactional(readOnly=true) public Optional<ContentReference> getContentReference(String contentReferenceId)
ContentManager
Gets the content reference associated to the supplied ContentReferenceId. In case of a multi-versioned content reference, the last version is retrieved.
getContentReference
in interface ContentManager
contentReferenceId
- the content reference id@Transactional @CacheEvict(cacheNames={"edorasGear-contentMetadataByContentReferenceId","edorasGear-contentVersionsByContentReferenceId"},key="#contentReference.getId()") @CacheEvict(value="edorasOne-previewedDocuments",key="#contentReference") public ContentReference updateContent(ContentReference contentReference, org.springframework.core.io.Resource resource, long inputStreamLength, ContentMetadata contentMetadata)
ContentManager
This method behaves exactly like calling ContentManager.updateContent(ContentReference, Resource, long, ContentMetadata, boolean)
with the last parameter set to false.
updateContent
in interface ContentManager
contentReference
- the content reference to be updatedresource
- the updated content as input streaminputStreamLength
- the length of the input streamcontentMetadata
- the optional content metadata@Transactional @CacheEvict(cacheNames={"edorasGear-contentMetadataByContentReferenceId","edorasGear-contentVersionsByContentReferenceId"},key="#contentReference.getId()") @CacheEvict(value="edorasOne-previewedDocuments",key="#contentReference") public ContentReference updateContent(ContentReference contentReference, org.springframework.core.io.Resource resource, long inputStreamLength, ContentMetadata contentMetadata, boolean overwriteVersion)
ContentManager
Updates the the content and the metadata of the specified ContentReference
with the specified InputStream
and ContentMetadata
, with the option to
overwrite te existing version. A new ContentReference
will be returned with the new version set if the overwrite flag is set to false. The same ContentReference will
be returned if the overwrite flag is set to true. The source id of the specified content reference must not be changed. The provided InputStream
will always be
closed. This method triggers the ContentListener.contentUpdated(ContentEvent)
method of the registered content listeners.
updateContent
in interface ContentManager
contentReference
- the content reference to be updatedresource
- the updated content as input streaminputStreamLength
- the length of the input streamcontentMetadata
- the optional content metadataoverwriteVersion
- true if the content that is about to be updated shall be overwritten, otherwise false@CacheEvict(value="edorasGear-contentMetadataByContentReferenceId",key="#contentReference.getId()") @CacheEvict(value="edorasOne-previewedDocuments",key="#contentReference") public void updateContentMetadata(ContentReference contentReference, ContentMetadata contentMetadata)
ContentManager
Updates the content metadata. This method triggers the ContentListener.contentUpdated(ContentEvent)
method of the registered content listeners.
updateContentMetadata
in interface ContentManager
contentReference
- the content referencecontentMetadata
- the content metadata@CacheEvict(value="edorasGear-contentReferencesByContentSourceId", key="#contentSourceId") public void setContentSourceId(ContentReference contentReference, String contentSourceId)
ContentManager
Sets the ContentSourceId for a selected ContentReference
. All the versions of the content reference are updated. This method triggers the ContentListener.contentUpdated(ContentEvent)
method of the registered content listeners.
setContentSourceId
in interface ContentManager
contentReference
- the content referencecontentSourceId
- the content source id@CacheEvict(cacheNames={"edorasGear-contentMetadataByContentReferenceId","edorasGear-contentVersionsByContentReferenceId","edorasGear-contentReferencesByContentSourceId","edorasOne-previewedDocuments"}, allEntries=true) public void deleteContent()
ConfigurableContentManager
Deletes all the content of the content manager. CAUTION: Double check what you are doing before calling this method. All the configured content providers are called to
delete the content. This method is intended only for maintenance purposes. No ContentListener
will be called upon a full content deletion.
deleteContent
in interface ConfigurableContentManager
@Transactional @CacheEvict(cacheNames={"edorasGear-contentMetadataByContentReferenceId","edorasGear-contentVersionsByContentReferenceId"},key="#contentReference.getId()") @CacheEvict(value="edorasOne-previewedDocuments",key="#contentReference") @CacheEvict(value="edorasGear-contentReferencesByContentSourceId",allEntries=true) public int deleteContent(ContentReference contentReference)
ContentManager
Deletes all versions of the specified ContentReference
such that the passed in ContentReference
cannot be used anymore to retrieve content. This method
triggers the ContentListener.contentDeleted(ContentEvent, Optional)
method of the registered content listeners.
deleteContent
in interface ContentManager
contentReference
- the content reference to be deleted@Transactional @CacheEvict(cacheNames={"edorasGear-contentMetadataByContentReferenceId","edorasGear-contentVersionsByContentReferenceId"},key="#contentReference.getId()") @CacheEvict(value="edorasOne-previewedDocuments",key="#contentReference") @CacheEvict(value="edorasGear-contentReferencesByContentSourceId",allEntries=true) public void deleteContent(ContentReference contentReference, String version)
ContentManager
Deletes a specific version of the specified ContentReference
such that the passed in ContentReference
cannot be used anymore to retrieve content with that
version. This method triggers the ContentListener.contentDeleted(ContentEvent, Optional)
method of the registered content listeners.
deleteContent
in interface ContentManager
contentReference
- the content reference to be deletedversion
- the version of the content to be deleted@CacheEvict(cacheNames={"edorasGear-contentMetadataByContentReferenceId","edorasGear-contentVersionsByContentReferenceId","edorasOne-previewedDocuments"},allEntries=true) @CacheEvict(value="edorasGear-contentReferencesByContentSourceId",key="#contentSourceId") public void deleteContent(String contentSourceId)
ContentManager
Deletes the content that is associated to the supplied ContentSourceId. All the configured content providers are called to delete the content. This method triggers
the ContentListener.contentDeleted(ContentEvent, Optional)
method of the registered content listeners.
deleteContent
in interface ContentManager
contentSourceId
- the content source idpublic void addContentProvider(ContentProvider contentProvider)
ConfigurableContentManager
Add a ContentProvider
to the content manager.
addContentProvider
in interface ConfigurableContentManager
contentProvider
- the content provider to be added@Autowired(required=false) public void setContentListeners(List<ContentListener> contentListeners)
ConfigurableContentManager
Set the ContentListener
s for the content manager.
setContentListeners
in interface ConfigurableContentManager
contentListeners
- the list of content listeners to be addedpublic void setContentPreProcessingConfiguration(ContentPreProcessingConfiguration contentPreProcessingConfiguration)
ConfigurableContentManager
Set the ContentPreProcessingConfiguration
which is required if you want to pre process the content added or updated in a separate job.
setContentPreProcessingConfiguration
in interface ConfigurableContentManager
contentPreProcessingConfiguration
- the content pre processing configurationpublic List<ContentProvider> getContentProviders()
ConfigurableContentManager
Returns the ContentProvider
s.
getContentProviders
in interface ConfigurableContentManager
public ContentProvider getDefaultContentProvider()
ContentManager
Returns the default ContentProvider
configured for the content manager instance.
getDefaultContentProvider
in interface ContentManager
public void processContent(ContentScope contentScope, ContentProcessor contentProcessor)
ConfigurableContentManager
Process all content with the given content processor
processContent
in interface ConfigurableContentManager
contentScope
- contentScope for which content will be processedcontentProcessor
- content processor which will be applied on all contentCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.