mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Allow other types of content URLs other than store://...
Enforce restriction that all content URLs must be of form protocol://identifier Allow for read-only stores. Improved tests so that it is easier, when writing a new store, to determine if the store is compliant or not. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5899 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,7 +42,9 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
* providing persistence and retrieval of the content against a
|
||||
* <code>content URL</code>.
|
||||
* <p>
|
||||
* The URL format is <b>store://year/month/day/GUID.bin</b> <br>
|
||||
* Content URLs must consist of a prefix or protocol followed by an
|
||||
* implementation-specific identifier. For example, the content URL format
|
||||
* for file stores is <b>store://year/month/day/GUID.bin</b> <br>
|
||||
* <ul>
|
||||
* <li> <b>store://</b>: prefix identifying an Alfresco content stores
|
||||
* regardless of the persistence mechanism. </li>
|
||||
@@ -53,16 +55,53 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
* <li> <b>minute</b>: 0-based minute of the hour </li>
|
||||
* <li> <b>GUID</b>: A unique identifier </li>
|
||||
* </ul>
|
||||
* The old <b>file://</b> prefix must still be supported - and functionality
|
||||
* around this can be found in the {@link org.alfresco.repo.content.AbstractContentStore}
|
||||
* implementation.
|
||||
* <p>
|
||||
* Where the store cannot handle a particular content URL request, the
|
||||
* {@link UnsupportedContentUrlException} must be generated. This will allow
|
||||
* various implementations to provide fallback code to other stores where
|
||||
* possible.
|
||||
* <p>
|
||||
* Where a store cannot serve a particular request because the functionality
|
||||
* is just not available, the <code>UnsupportedOperationException</code> should
|
||||
* be thrown. Once again, there may be fallback handling provided for these
|
||||
* situations.
|
||||
*
|
||||
* @since 1.0
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public interface ContentStore
|
||||
{
|
||||
/** <b>store://</b> is the new prefix for all content URLs */
|
||||
public static final String STORE_PROTOCOL = "store://";
|
||||
/**
|
||||
* An empty content context used to retrieve completely new content.
|
||||
*
|
||||
* @see ContentStore#getWriter(ContentContext)
|
||||
*/
|
||||
public static final ContentContext NEW_CONTENT_CONTEXT = new ContentContext(null, null);
|
||||
/**
|
||||
* The delimiter that must be found in all URLS, i.e <b>://</b>
|
||||
*/
|
||||
public static final String PROTOCOL_DELIMITER = "://";
|
||||
|
||||
/**
|
||||
* Check if the content URL format is supported by the store.
|
||||
*
|
||||
* @param contentUrl the content URL to check
|
||||
* @return Returns <tt>true</tt> if none of the other methods on the store
|
||||
* will throw an {@link UnsupportedContentUrlException} when given
|
||||
* this URL.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public boolean isContentUrlSupported(String contentUrl);
|
||||
|
||||
/**
|
||||
* Check if the store supports write requests.
|
||||
*
|
||||
* @return Return true is the store supports write operations
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public boolean isWriteSupported();
|
||||
|
||||
/**
|
||||
* Check for the existence of content in the store.
|
||||
@@ -71,30 +110,37 @@ public interface ContentStore
|
||||
* reader to {@link ContentReader#exists() check for existence}, although
|
||||
* that check should also be performed.
|
||||
*
|
||||
* @param contentUrl the path to the content
|
||||
* @return Returns true if the content exists, otherwise
|
||||
* false if the content doesn't exist or if the URL
|
||||
* is not applicable to this store.
|
||||
* @param contentUrl
|
||||
* the path to the content
|
||||
* @return
|
||||
* Returns true if the content exists, otherwise false if the content doesn't
|
||||
* exist or <b>if the URL is not applicable to this store</b>.
|
||||
* @throws UnsupportedContentUrlException
|
||||
* if the content URL supplied is not supported by the store
|
||||
* @throws ContentIOException
|
||||
* if an IO error occurs
|
||||
*
|
||||
* @see ContentReader#exists()
|
||||
*/
|
||||
public boolean exists(String contentUrl) throws ContentIOException;
|
||||
public boolean exists(String contentUrl);
|
||||
|
||||
/**
|
||||
* Get the accessor with which to read from the content at the given URL.
|
||||
* The reader is <b>stateful</b> and can <b>only be used once</b>.
|
||||
*
|
||||
* @param contentUrl the path to where the content is located
|
||||
* @return Returns a read-only content accessor for the given URL. There may
|
||||
* be no content at the given URL, but the reader must still be returned.
|
||||
* @param contentUrl the path to where the content is located
|
||||
* @return Returns a read-only content accessor for the given URL. There may
|
||||
* be no content at the given URL, but the reader must still be returned.
|
||||
* @throws UnsupportedContentUrlException
|
||||
* if the content URL supplied is not supported by the store
|
||||
* @throws ContentIOException
|
||||
* if an IO error occurs
|
||||
*
|
||||
* @see #exists(String)
|
||||
* @see ContentReader#exists()
|
||||
* @see EmptyContentReader
|
||||
*/
|
||||
public ContentReader getReader(String contentUrl) throws ContentIOException;
|
||||
public ContentReader getReader(String contentUrl);
|
||||
|
||||
/**
|
||||
* Get an accessor with which to write content to a location
|
||||
@@ -110,15 +156,24 @@ public interface ContentStore
|
||||
* can enable this by copying the existing content into the new location
|
||||
* before supplying a writer onto the new content.
|
||||
*
|
||||
* @param context the context of content.
|
||||
* @return Returns a write-only content accessor
|
||||
* @throws ContentIOException if completely new content storage could not be created
|
||||
* @param context
|
||||
* the context of content.
|
||||
* @return
|
||||
* Returns a write-only content accessor
|
||||
* @throws UnsupportedOperationException
|
||||
* if the store is unable to provide the information
|
||||
* @throws UnsupportedContentUrlException
|
||||
* if the content URL supplied is not supported by the store
|
||||
* @throws ContentExistsException
|
||||
* if the content URL is already in use
|
||||
* @throws ContentIOException
|
||||
* if an IO error occurs
|
||||
*
|
||||
* @see #getWriter(ContentReader, String)
|
||||
* @see #getWriteSupport()
|
||||
* @see ContentWriter#addListener(ContentStreamListener)
|
||||
* @see ContentWriter#getContentUrl()
|
||||
*/
|
||||
public ContentWriter getWriter(ContentContext context) throws ContentIOException;
|
||||
public ContentWriter getWriter(ContentContext context);
|
||||
|
||||
/**
|
||||
* Shortcut method to {@link #getWriter(ContentContext)}.
|
||||
@@ -127,26 +182,37 @@ public interface ContentStore
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl) throws ContentIOException;
|
||||
public ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl);
|
||||
|
||||
/**
|
||||
* Get all URLs for the store, regardless of creation time.
|
||||
* @return
|
||||
* Returns a set of all unique content URLs in the store
|
||||
* @throws ContentIOException
|
||||
* if an IO error occurs
|
||||
* @throws UnsupportedOperationException
|
||||
* if the store is unable to provide the information
|
||||
*
|
||||
* @see #getUrls(Date, Date)
|
||||
*/
|
||||
public Set<String> getUrls() throws ContentIOException;
|
||||
public Set<String> getUrls();
|
||||
|
||||
/**
|
||||
* Get a set of all content URLs in the store. This indicates all content
|
||||
* available for reads.
|
||||
*
|
||||
* @param createdAfter all URLs returned must have been created after this date. May be null.
|
||||
* @param createdBefore all URLs returned must have been created before this date. May be null.
|
||||
* @return Returns a complete set of the unique URLs of all available content
|
||||
* in the store
|
||||
* @param createdAfter
|
||||
* all URLs returned must have been created after this date. May be null.
|
||||
* @param createdBefore
|
||||
* all URLs returned must have been created before this date. May be null.
|
||||
* @return
|
||||
* Returns a complete set of the unique URLs of all available content in the store
|
||||
* @throws UnsupportedOperationException
|
||||
* if the store is unable to provide the information
|
||||
* @throws ContentIOException
|
||||
* if an IO error occurs
|
||||
*/
|
||||
public Set<String> getUrls(Date createdAfter, Date createdBefore) throws ContentIOException;
|
||||
public Set<String> getUrls(Date createdAfter, Date createdBefore);
|
||||
|
||||
/**
|
||||
* Deletes the content at the given URL.
|
||||
@@ -154,11 +220,17 @@ public interface ContentStore
|
||||
* A delete cannot be forced since it is much better to have the
|
||||
* file remain longer than desired rather than deleted prematurely.
|
||||
*
|
||||
* @param contentUrl the URL of the content to delete
|
||||
* @return Return true if the content was deleted (either by this or
|
||||
* another operation), otherwise false. If the content no longer
|
||||
* exists, then <tt>true</tt> is returned.
|
||||
* @param contentUrl
|
||||
* the URL of the content to delete
|
||||
* @return
|
||||
* Returns <tt>true</tt> if the content was deleted (either by this or another operation),
|
||||
* otherwise false. If the content no longer exists, then <tt>true</tt> is returned.
|
||||
* @throws UnsupportedOperationException
|
||||
* if the store is unable to perform the action
|
||||
* @throws UnsupportedContentUrlException
|
||||
* if the content URL supplied is not supported by the store
|
||||
* @throws ContentIOException
|
||||
* if an IO error occurs
|
||||
*/
|
||||
public boolean delete(String contentUrl) throws ContentIOException;
|
||||
public boolean delete(String contentUrl);
|
||||
}
|
||||
|
Reference in New Issue
Block a user