KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > cmr > repository > ContentService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.service.cmr.repository;
18
19 import org.alfresco.service.cmr.dictionary.InvalidTypeException;
20 import org.alfresco.service.namespace.QName;
21
22 /**
23  * Provides methods for accessing and transforming content.
24  * <p>
25  * Implementations of this service are primarily responsible for ensuring
26  * that the correct store is used to access content, and that reads and
27  * writes for the same node reference are routed to the same store instance.
28  * <p>
29  * The mechanism for selecting an appropriate store is not prescribed by
30  * the interface, but typically the decision will be made on the grounds
31  * of content type.
32  * <p>
33  * Whereas the content stores have no knowledge of nodes other than their
34  * references, the <code>ContentService</code> <b>is</b> responsible for
35  * ensuring that all the relevant node-content relationships are maintained.
36  *
37  * @see org.alfresco.repo.content.ContentStore
38  * @see org.alfresco.service.cmr.repository.ContentReader
39  * @see org.alfresco.service.cmr.repository.ContentWriter
40  *
41  * @author Derek Hulley
42  */

43 public interface ContentService
44 {
45     /**
46      * Gets a reader for the content associated with the given node property.
47      * <p>
48      * If a content URL is present for the given node then a reader <b>must</b>
49      * be returned. The {@link ContentReader#exists() exists} method should then
50      * be used to detect 'missing' content.
51      *
52      * @param nodeRef a reference to a node having a content property
53      * @param propertyQName the name of the property, which must be of type <b>content</b>
54      * @return Returns a reader for the content associated with the node property,
55      * or null if no content has been written for the property
56      * @throws InvalidNodeRefException if the node doesn't exist
57      * @throws InvalidTypeException if the node is not of type <b>content</b>
58      *
59      * @see org.alfresco.repo.content.filestore.FileContentReader#getSafeContentReader(ContentReader, String, Object[])
60      */

61     public ContentReader getReader(NodeRef nodeRef, QName propertyQName)
62             throws InvalidNodeRefException, InvalidTypeException;
63
64     /**
65      * Get a content writer for the given node property, choosing to optionally have
66      * the node property updated automatically when the content stream closes.
67      * <p>
68      * If the update flag is off, then the state of the node property will remain unchanged
69      * regardless of the state of the written binary data. If the flag is on, then the node
70      * property will be updated on the same thread as the code that closed the write
71      * channel.
72      *
73      * @param nodeRef a reference to a node having a content property
74      * @param propertyQName the name of the property, which must be of type <b>content</b>
75      * @param update true if the property must be updated atomically when the content write
76      * stream is closed (attaches a listener to the stream); false if the client code
77      * will perform the updates itself.
78      * @return Returns a writer for the content associated with the node property
79      * @throws InvalidNodeRefException if the node doesn't exist
80      * @throws InvalidTypeException if the node property is not of type <b>content</b>
81      */

82     public ContentWriter getWriter(NodeRef nodeRef, QName propertyQName, boolean update)
83                 throws InvalidNodeRefException, InvalidTypeException;
84
85     /**
86      * Gets a writer to a temporary location. The longevity of the stored
87      * temporary content is determined by the system.
88      *
89      * @return Returns a writer onto a temporary location
90      */

91     public ContentWriter getTempWriter();
92     
93     /**
94      * Transforms the content from the reader and writes the content
95      * back out to the writer.
96      * <p>
97      * The mimetypes used for the transformation must be set both on
98      * the {@link ContentAccessor#getMimetype() reader} and on the
99      * {@link ContentAccessor#getMimetype() writer}.
100      *
101      * @param reader the source content location and mimetype
102      * @param writer the target content location and mimetype
103      * @throws NoTransformerException if no transformer exists for the
104      * given source and target mimetypes of the reader and writer
105      * @throws ContentIOException if the transformation fails
106      */

107     public void transform(ContentReader reader, ContentWriter writer)
108             throws NoTransformerException, ContentIOException;
109     
110     /**
111      * Returns whether a transformer exists that can read the content from
112      * the reader and write the content back out to the writer.
113      * <p>
114      * The mimetypes used for the transformation must be set both on
115      * the {@link ContentAccessor#getMimetype() reader} and on the
116      * {@link ContentAccessor#getMimetype() writer}.
117      *
118      * @param reader the source content location and mimetype
119      * @param writer the target content location and mimetype
120      *
121      * @return true if a transformer exists, false otherwise
122      */

123     public boolean isTransformable(ContentReader reader, ContentWriter writer);
124 }
125
Popular Tags