001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.lenya.cms.publication;
020:
021: import java.io.File;
022: import java.io.InputStream;
023: import java.io.OutputStream;
024: import java.util.Date;
025:
026: import org.apache.lenya.cms.metadata.MetaDataOwner;
027: import org.apache.lenya.cms.publication.util.DocumentVisitor;
028: import org.apache.lenya.cms.repository.Node;
029: import org.apache.lenya.cms.repository.RepositoryItem;
030: import org.apache.lenya.cms.site.Link;
031:
032: /**
033: * A CMS document.
034: * @version $Id: Document.java 586495 2007-10-19 15:13:36Z rfrovarp $
035: */
036: public interface Document extends MetaDataOwner, RepositoryItem {
037:
038: /**
039: * The document namespace URI.
040: */
041: String NAMESPACE = "http://apache.org/cocoon/lenya/document/1.0";
042:
043: /**
044: * The default namespace prefix.
045: */
046: String DEFAULT_PREFIX = "lenya";
047:
048: /**
049: * The transactionable type for document objects.
050: */
051: String TRANSACTIONABLE_TYPE = "document";
052:
053: /**
054: * <code>DOCUMENT_META_SUFFIX</code> The suffix for document meta Uris
055: */
056: final String DOCUMENT_META_SUFFIX = ".meta";
057:
058: /**
059: * Returns the date at which point the requested document is considered expired
060: * @return a string in RFC 1123 date format
061: * @throws DocumentException if an error occurs.
062: */
063: Date getExpires() throws DocumentException;
064:
065: /**
066: * Returns the document name of this document.
067: * @return the document-name of this document.
068: */
069: String getName();
070:
071: /**
072: * Returns the publication this document belongs to.
073: * @return A publication object.
074: */
075: Publication getPublication();
076:
077: /**
078: * Returns the canonical web application URL.
079: * @return A string.
080: */
081: String getCanonicalWebappURL();
082:
083: /**
084: * Returns the canonical document URL.
085: * @return A string.
086: */
087: String getCanonicalDocumentURL();
088:
089: /**
090: * Returns the language of this document.
091: * Each document has one language associated to it.
092: * @return A string denoting the language.
093: */
094: String getLanguage();
095:
096: /**
097: * Returns all the languages this document is available in.
098: * A document has one associated language (@see Document#getLanguage)
099: * but there are possibly a number of other languages for which a
100: * document with the same document-uuid is also available in.
101: *
102: * @return An array of strings denoting the languages.
103: *
104: * @throws DocumentException if an error occurs
105: */
106: String[] getLanguages() throws DocumentException;
107:
108: /**
109: * Returns the date of the last modification of this document.
110: * @return A date denoting the date of the last modification.
111: * @throws DocumentException if an error occurs.
112: */
113: long getLastModified() throws DocumentException;
114:
115: /**
116: * Returns the area this document belongs to.
117: * @return The area.
118: */
119: String getArea();
120:
121: /**
122: * Returns the file for this document.
123: * @return A file object.
124: * @deprecated This implies the usage of a filesystem based storage. Use {@link #getSourceURI()} instead.
125: */
126: File getFile();
127:
128: /**
129: * Returns the extension in the URL without the dot.
130: * @return A string.
131: */
132: String getExtension();
133:
134: /**
135: * Returns the UUID.
136: * @return A string.
137: */
138: String getUUID();
139:
140: /**
141: * Check if a document with the given document-uuid, language and in the given
142: * area actually exists.
143: *
144: * @return true if the document exists, false otherwise
145: *
146: * @throws DocumentException if an error occurs
147: */
148: boolean exists() throws DocumentException;
149:
150: /**
151: * Check if a document exists with the given document-uuid and the given area
152: * independently of the given language.
153: *
154: * @return true if a document with the given document-uuid and area exists, false otherwise
155: *
156: * @throws DocumentException if an error occurs
157: */
158: boolean existsInAnyLanguage() throws DocumentException;
159:
160: /**
161: * Returns the identity map this document belongs to.
162: * @return A document identity map.
163: */
164: DocumentFactory getFactory();
165:
166: /**
167: * Returns the URI to resolve the document's source.
168: * The source can only be used for read-only access.
169: * For write access, use {@link #getOutputStream()}.
170: * @return A string.
171: */
172: String getSourceURI();
173:
174: /**
175: * @return The output stream to write the document content to.
176: */
177: OutputStream getOutputStream();
178:
179: /**
180: * Accepts a document visitor.
181: * @param visitor The visitor.
182: * @throws PublicationException if an error occurs.
183: */
184: void accept(DocumentVisitor visitor) throws PublicationException;
185:
186: /**
187: * Deletes the document.
188: * @throws DocumentException if an error occurs.
189: */
190: void delete() throws DocumentException;
191:
192: /**
193: * @return The repository node that represents this document.
194: */
195: Node getRepositoryNode();
196:
197: /**
198: * @return The resource type of this document (formerly known as doctype)
199: * @throws DocumentException if an error occurs.
200: */
201: ResourceType getResourceType() throws DocumentException;
202:
203: /**
204: * @param resourceType The resource type of this document.
205: */
206: void setResourceType(ResourceType resourceType);
207:
208: /**
209: * @return The source extension used by this document, without the dot.
210: */
211: String getSourceExtension();
212:
213: /**
214: * @param extension The source extension used by this document, without the dot.
215: */
216: void setSourceExtension(String extension);
217:
218: /**
219: * Sets the mime type of this document.
220: * @param mimeType The mime type.
221: * @throws DocumentException if an error occurs.
222: */
223: void setMimeType(String mimeType) throws DocumentException;
224:
225: /**
226: * @return The mime type of this document.
227: * @throws DocumentException if an error occurs.
228: */
229: String getMimeType() throws DocumentException;
230:
231: /**
232: * @return The content length of the document.
233: * @throws DocumentException if an error occurs.
234: */
235: long getContentLength() throws DocumentException;
236:
237: /**
238: * @return The document identifier for this document.
239: */
240: DocumentIdentifier getIdentifier();
241:
242: /**
243: * This is a shortcut to getLink().getNode().getPath().
244: * @return The path of this document in the site structure.
245: * @throws DocumentException if the document is not linked in the site structure.
246: */
247: String getPath() throws DocumentException;
248:
249: /**
250: * Checks if a certain translation (language version) of this document exists.
251: * @param language The language.
252: * @return A boolean value.
253: */
254: boolean existsTranslation(String language);
255:
256: /**
257: * Returns a certain translation (language version) of this document.
258: * @param language The language.
259: * @return A document.
260: * @throws DocumentException if the language version doesn't exist.
261: */
262: Document getTranslation(String language) throws DocumentException;
263:
264: /**
265: * Checks if this document exists in a certain area.
266: * @param area The area.
267: * @return A boolean value.
268: */
269: boolean existsAreaVersion(String area);
270:
271: /**
272: * Returns the document in a certain area.
273: * @param area The area.
274: * @return A document.
275: * @throws DocumentException if the area version doesn't exist.
276: */
277: Document getAreaVersion(String area) throws DocumentException;
278:
279: /**
280: * Checks if a translation of this document exists in a certain area.
281: * @param area The area.
282: * @param language The language.
283: * @return A boolean value.
284: */
285: boolean existsVersion(String area, String language);
286:
287: /**
288: * Returns a translation of this document in a certain area.
289: * @param area The area.
290: * @param language The language.
291: * @return A document.
292: * @throws DocumentException if the area version doesn't exist.
293: */
294: Document getVersion(String area, String language)
295: throws DocumentException;
296:
297: /**
298: * @return A document locator.
299: */
300: DocumentLocator getLocator();
301:
302: /**
303: * @return The link to this document in the site structure.
304: * @throws DocumentException if the document is not referenced in the site structure.
305: */
306: Link getLink() throws DocumentException;
307:
308: /**
309: * @return The area the document belongs to.
310: */
311: Area area();
312:
313: /**
314: * @return if the document is linked in the site structure.
315: */
316: boolean hasLink();
317:
318: /**
319: * @return The input stream to obtain the document's content.
320: */
321: InputStream getInputStream();
322:
323: /**
324: * @return The revision number of this document.
325: */
326: int getRevisionNumber();
327: }
|