View Javadoc

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.runtime.async;
20  
21  import java.io.OutputStream;
22  import java.util.Map;
23  import java.util.concurrent.Future;
24  
25  import org.apache.chemistry.opencmis.client.api.AsyncSession;
26  import org.apache.chemistry.opencmis.client.api.CmisObject;
27  import org.apache.chemistry.opencmis.client.api.Document;
28  import org.apache.chemistry.opencmis.client.api.ObjectId;
29  import org.apache.chemistry.opencmis.client.api.OperationContext;
30  import org.apache.chemistry.opencmis.client.api.Session;
31  import org.apache.chemistry.opencmis.commons.data.ContentStream;
32  import org.apache.chemistry.opencmis.commons.enums.VersioningState;
33  
34  /**
35   * An abstract implementation of the {@link AsyncSession} interface providing
36   * convenience implementations.
37   */
38  public abstract class AbstractAsyncSession implements AsyncSession {
39  
40      protected Session session;
41  
42      public AbstractAsyncSession(Session session) {
43          if (session == null) {
44              throw new IllegalArgumentException("Session must be set!");
45          }
46  
47          this.session = session;
48      }
49  
50      @Override
51      public Session getSession() {
52          return session;
53      }
54  
55      @Override
56      public Future<CmisObject> getObject(ObjectId objectId) {
57          return getObject(objectId, session.getDefaultContext());
58      }
59  
60      @Override
61      public Future<CmisObject> getObject(String objectId) {
62          return getObject(objectId, session.getDefaultContext());
63      }
64  
65      @Override
66      public Future<CmisObject> getObjectByPath(String path) {
67          return getObjectByPath(path, session.getDefaultContext());
68      }
69  
70      @Override
71      public Future<CmisObject> getObjectByPath(String parentPath, String name) {
72          return getObjectByPath(parentPath, name, session.getDefaultContext());
73      }
74  
75      @Override
76      public Future<Document> getLatestDocumentVersion(ObjectId objectId) {
77          return getLatestDocumentVersion(objectId, session.getDefaultContext());
78      }
79  
80      @Override
81      public Future<Document> getLatestDocumentVersion(ObjectId objectId, OperationContext context) {
82          return getLatestDocumentVersion(objectId, false, context);
83      }
84  
85      @Override
86      public Future<Document> getLatestDocumentVersion(String objectId) {
87          return getLatestDocumentVersion(objectId, session.getDefaultContext());
88      }
89  
90      @Override
91      public Future<Document> getLatestDocumentVersion(String objectId, OperationContext context) {
92          return getLatestDocumentVersion(objectId, false, context);
93      }
94  
95      @Override
96      public Future<ObjectId> createDocument(Map<String, ?> properties, ObjectId folderId, ContentStream contentStream,
97              VersioningState versioningState) {
98          return createDocument(properties, folderId, contentStream, versioningState, null, null, null);
99      }
100 
101     @Override
102     public Future<ObjectId> createDocumentFromSource(ObjectId source, Map<String, ?> properties, ObjectId folderId,
103             VersioningState versioningState) {
104         return createDocumentFromSource(source, properties, folderId, versioningState, null, null, null);
105     }
106 
107     @Override
108     public Future<ObjectId> createFolder(Map<String, ?> properties, ObjectId folderId) {
109         return createFolder(properties, folderId, null, null, null);
110     }
111 
112     @Override
113     public Future<ObjectId> createPolicy(Map<String, ?> properties, ObjectId folderId) {
114         return createPolicy(properties, folderId, null, null, null);
115     }
116 
117     @Override
118     public Future<ObjectId> createItem(Map<String, ?> properties, ObjectId folderId) {
119         return createItem(properties, folderId, null, null, null);
120     }
121 
122     @Override
123     public Future<ObjectId> createRelationship(Map<String, ?> properties) {
124         return createRelationship(properties, null, null, null);
125     }
126 
127     @Override
128     public Future<ContentStream> getContentStream(ObjectId docId) {
129         return getContentStream(docId, null, null, null);
130     }
131 
132     @Override
133     public Future<ContentStream> storeContentStream(ObjectId docId, OutputStream target) {
134         return storeContentStream(docId, null, null, null, target);
135     }
136 
137     @Override
138     public Future<?> delete(ObjectId objectId) {
139         return delete(objectId, true);
140     }
141 }