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: package org.apache.lenya.cms.publication;
019:
020: import org.apache.lenya.cms.publication.util.DocumentSet;
021:
022: /**
023: * Helper to manage documents. It takes care of attachments etc.
024: *
025: * @version $Id: DocumentManager.java 527520 2007-04-11 15:22:11Z andreas $
026: */
027: public interface DocumentManager {
028:
029: /**
030: * The Avalon component role.
031: */
032: String ROLE = DocumentManager.class.getName();
033:
034: /**
035: * Checks if a document exists.
036: * @param factory The document factory.
037: * @param pub The publication.
038: * @param area The area.
039: * @param uuid The UUID.
040: * @param language The language.
041: * @return A boolean value.
042: * @throws PublicationException if an error occurs.
043: */
044: boolean exists(DocumentFactory factory, Publication pub,
045: String area, String uuid, String language)
046: throws PublicationException;
047:
048: /**
049: * Copies a document from one location to another location.
050: * @param sourceDocument The document to copy.
051: * @param destination The destination document.
052: * @throws PublicationException if a document which destinationDocument depends on does not
053: * exist.
054: */
055: void copy(Document sourceDocument, DocumentLocator destination)
056: throws PublicationException;
057:
058: /**
059: * Copies a document to another area.
060: * @param sourceDocument The document to copy.
061: * @param destinationArea The destination area.
062: * @throws PublicationException if a document which the destination document depends on does not
063: * exist.
064: */
065: void copyToArea(Document sourceDocument, String destinationArea)
066: throws PublicationException;
067:
068: /**
069: * Copies a document set to another area.
070: * @param documentSet The document set to copy.
071: * @param destinationArea The destination area.
072: * @throws PublicationException if a document which one of the destination documents depends on
073: * does not exist.
074: */
075: void copyToArea(DocumentSet documentSet, String destinationArea)
076: throws PublicationException;
077:
078: /**
079: * Creates a new document in the same publication the <code>parentDocument</code> belongs to
080: * with the given parameters:
081: *
082: * @param sourceDocument The document to initialize the contents and meta data from.
083: * @param area The target area.
084: * @param path The target path.
085: * @param language The target language.
086: * @param extension The extension to use for the document source.
087: * @param navigationTitle navigation title
088: * @param visibleInNav determines the visibility of a node in the navigation
089: * @return The added document.
090: *
091: * @throws DocumentBuildException if the document can not be created
092: * @throws PublicationException if the document is already contained.
093: */
094: Document add(Document sourceDocument, String area, String path,
095: String language, String extension, String navigationTitle,
096: boolean visibleInNav) throws DocumentBuildException,
097: PublicationException;
098:
099: /**
100: * Creates a new document with the given parameters:
101: * @param factory The document factory.
102: * @param resourceType the document type (aka resource type) of the new document
103: * @param contentSourceUri The URI to read the content from.
104: * @param pub The publication.
105: * @param area The area.
106: * @param path The path.
107: * @param language The language.
108: * @param extension The extension to use for the document source, without the leading dot.
109: * @param navigationTitle The navigation title.
110: * @param visibleInNav The navigation visibility.
111: * @return The added document.
112: *
113: * @throws DocumentBuildException if the document can not be created
114: * @throws PublicationException if the document is already contained.
115: */
116: Document add(DocumentFactory factory, ResourceType resourceType,
117: String contentSourceUri, Publication pub, String area,
118: String path, String language, String extension,
119: String navigationTitle, boolean visibleInNav)
120: throws DocumentBuildException, PublicationException;
121:
122: /**
123: * Creates a new document without adding it to the site structure.
124: * @param factory The document factory.
125: * @param resourceType the document type (aka resource type) of the new document
126: * @param contentSourceUri The URI to read the content from.
127: * @param pub The publication.
128: * @param area The area.
129: * @param language The language.
130: * @param extension The extension to use for the document source, without the leading dot.
131: * @return The added document.
132: *
133: * @throws DocumentBuildException if the document can not be created
134: * @throws PublicationException if the document is already contained.
135: */
136: Document add(DocumentFactory factory, ResourceType resourceType,
137: String contentSourceUri, Publication pub, String area,
138: String language, String extension)
139: throws DocumentBuildException, PublicationException;
140:
141: /**
142: * Adds a new version of a document with a different language and / or in a different area.
143: *
144: * @param sourceDocument The document to initialize the contents and meta data from.
145: * @param area The area.
146: * @param language The language of the new document.
147: * @return The added document.
148: *
149: * @throws DocumentBuildException if the document can not be created
150: * @throws PublicationException if the document is already contained.
151: */
152: Document addVersion(Document sourceDocument, String area,
153: String language) throws DocumentBuildException,
154: PublicationException;
155:
156: /**
157: * Adds a new version of a document with a different language and / or in a different area.
158: *
159: * @param sourceDocument The document to initialize the contents and meta data from.
160: * @param area The area.
161: * @param language The language of the new document.
162: * @param addToSite If the new version should be added to the site structure.
163: * @return The added document.
164: *
165: * @throws DocumentBuildException if the document can not be created
166: * @throws PublicationException if the document is already contained.
167: */
168: Document addVersion(Document sourceDocument, String area,
169: String language, boolean addToSite)
170: throws DocumentBuildException, PublicationException;
171:
172: /**
173: * Deletes a document from the content repository and from the site structure.
174: * @param document The document to delete.
175: * @throws PublicationException when something went wrong.
176: */
177: void delete(Document document) throws PublicationException;
178:
179: /**
180: * Moves a document from one location to another.
181: * @param sourceDocument The source document.
182: * @param destination The destination document.
183: * @throws PublicationException if a document which the destination document depends on does not
184: * exist.
185: */
186: void move(Document sourceDocument, DocumentLocator destination)
187: throws PublicationException;
188:
189: /**
190: * Moves a document set from one location to another. A source is moved to the destination of
191: * the same position in the set.
192: * @param sources The source documents.
193: * @param destinations The destination documents.
194: * @throws PublicationException if a document which the destination document depends on does not
195: * exist.
196: */
197: void move(DocumentSet sources, DocumentSet destinations)
198: throws PublicationException;
199:
200: /**
201: * Copies a document set from one location to another. A source is copied to the destination of
202: * the same position in the set.
203: * @param sources The source documents.
204: * @param destinations The destination documents.
205: * @throws PublicationException if a document which the destination document depends on does not
206: * exist.
207: */
208: void copy(DocumentSet sources, DocumentSet destinations)
209: throws PublicationException;
210:
211: /**
212: * Moves a document to another location, incl. all requiring documents. If a sitetree is used,
213: * this means that the whole subtree is moved.
214: * @param sourceArea The source area.
215: * @param sourcePath The source path.
216: * @param targetArea The target area.
217: * @param targetPath The target path.
218: * @throws PublicationException if an error occurs.
219: */
220: void moveAll(Area sourceArea, String sourcePath, Area targetArea,
221: String targetPath) throws PublicationException;
222:
223: /**
224: * Moves all language versions of a document to another location.
225: * @param sourceArea The source area.
226: * @param sourcePath The source path.
227: * @param targetArea The target area.
228: * @param targetPath The target path.
229: * @throws PublicationException if the documents could not be moved.
230: */
231: void moveAllLanguageVersions(Area sourceArea, String sourcePath,
232: Area targetArea, String targetPath)
233: throws PublicationException;
234:
235: /**
236: * Copies a document to another location, incl. all requiring documents. If a sitetree is used,
237: * this means that the whole subtree is copied.
238: * @param sourceArea The source area.
239: * @param sourcePath The source path.
240: * @param targetArea The target area.
241: * @param targetPath The target path.
242: * @throws PublicationException if an error occurs.
243: */
244: void copyAll(Area sourceArea, String sourcePath, Area targetArea,
245: String targetPath) throws PublicationException;
246:
247: /**
248: * Copies all language versions of a document to another location.
249: * @param sourceArea The source area.
250: * @param sourcePath The source path.
251: * @param targetArea The target area.
252: * @param targetPath The target path.
253: * @throws PublicationException if the documents could not be copied.
254: */
255: void copyAllLanguageVersions(Area sourceArea, String sourcePath,
256: Area targetArea, String targetPath)
257: throws PublicationException;
258:
259: /**
260: * Deletes a document, incl. all requiring documents. If a sitetree is used, this means that the
261: * whole subtree is deleted.
262: * @param document The document.
263: * @throws PublicationException if an error occurs.
264: */
265: void deleteAll(Document document) throws PublicationException;
266:
267: /**
268: * Deletes all language versions of a document.
269: * @param document The document.
270: * @throws PublicationException if the documents could not be copied.
271: */
272: void deleteAllLanguageVersions(Document document)
273: throws PublicationException;
274:
275: /**
276: * Deletes a set of documents.
277: * @param documents The documents.
278: * @throws PublicationException if an error occurs.
279: */
280: void delete(DocumentSet documents) throws PublicationException;
281:
282: }
|