1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.chemistry.opencmis.client.api;
20
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.chemistry.opencmis.commons.data.Ace;
25 import org.apache.chemistry.opencmis.commons.data.ContentStream;
26 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
27
28 /**
29 * CMIS Document.
30 * <p>
31 * Domain Model 2.4
32 */
33 public interface Document extends FileableCmisObject, DocumentProperties {
34
35 TransientDocument getTransientDocument();
36
37 // object service
38
39 /**
40 * Deletes this document and all its versions.
41 */
42 void deleteAllVersions();
43
44 /**
45 * Retrieves the content stream of this document.
46 *
47 * @return the content stream, or {@code null}
48 */
49 ContentStream getContentStream();
50
51 /**
52 * Retrieves the content stream that is associated with the given stream id.
53 * This is usually a rendition of the document.
54 *
55 * @return the content stream, or {@code null}
56 */
57 ContentStream getContentStream(String streamId);
58
59 /**
60 * Sets a new content stream for the document.
61 */
62 Document setContentStream(ContentStream contentStream, boolean overwrite);
63
64 /**
65 * Sets a new content stream for the document.
66 */
67 ObjectId setContentStream(ContentStream contentStream, boolean overwrite, boolean refresh);
68
69 /**
70 * Removes the current content stream from the document.
71 */
72 Document deleteContentStream();
73
74 /**
75 * Removes the current content stream from the document.
76 */
77 ObjectId deleteContentStream(boolean refresh);
78
79 // versioning service
80
81 /**
82 * Checks out the document and returns the object id of the PWC (private
83 * working copy).
84 *
85 * @return PWC id
86 */
87 ObjectId checkOut(); // returns the PWC id
88
89 /**
90 * If this is a PWC (private working copy) the check out will be reversed.
91 * If this is not a PWC it an exception will be thrown.
92 */
93 void cancelCheckOut();
94
95 /**
96 * If this is a PWC (private working copy) it performs a check in. If this
97 * is not a PWC it an exception will be thrown.
98 *
99 * @return new document id
100 */
101 ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream, String checkinComment,
102 List<Policy> policies, List<Ace> addAces, List<Ace> removeAces);
103
104 /**
105 * If this is a PWC (private working copy) it performs a check in. If this
106 * is not a PWC it an exception will be thrown.
107 *
108 * @return new document id
109 */
110 ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream, String checkinComment);
111
112 /**
113 * Fetches the latest major or minor version of this document.
114 *
115 * @param major
116 * if <code>true</code> the latest major version will be
117 * returned, otherwise the very last version will be returned
118 *
119 * @return the latest document object
120 */
121 Document getObjectOfLatestVersion(boolean major);
122
123 /**
124 * Fetches the latest major or minor version of this document using the
125 * given {@link OperationContext}.
126 *
127 * @param major
128 * if <code>true</code> the latest major version will be
129 * returned, otherwise the very last version will be returned
130 *
131 * @return the latest document object
132 */
133 Document getObjectOfLatestVersion(boolean major, OperationContext context);
134
135 /**
136 * Fetches all versions of this document.
137 */
138 List<Document> getAllVersions();
139
140 /**
141 * Fetches all versions of this document using the given
142 * {@link OperationContext}.
143 */
144 List<Document> getAllVersions(OperationContext context);
145
146 /**
147 * Creates a copy of this document, including content.
148 *
149 * @return the new document object
150 */
151 Document copy(ObjectId targetFolderId);
152
153 /**
154 * Creates a copy of this document, including content.
155 *
156 * @return the new document object or {@code null} if the parameter
157 * {@code context} was set to {@code null}
158 */
159 Document copy(ObjectId targetFolderId, Map<String, ?> properties, VersioningState versioningState,
160 List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs, OperationContext context);
161
162 }