View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   *
20   */
21  package org.apache.chemistry.opencmis.client.bindings.spi.local;
22  
23  import java.util.List;
24  
25  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
26  import org.apache.chemistry.opencmis.commons.data.Acl;
27  import org.apache.chemistry.opencmis.commons.data.ContentStream;
28  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
29  import org.apache.chemistry.opencmis.commons.data.ObjectData;
30  import org.apache.chemistry.opencmis.commons.data.Properties;
31  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
32  import org.apache.chemistry.opencmis.commons.server.CmisService;
33  import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
34  import org.apache.chemistry.opencmis.commons.spi.Holder;
35  import org.apache.chemistry.opencmis.commons.spi.VersioningService;
36  
37  public class VersioningServiceImpl extends AbstractLocalService implements VersioningService {
38  
39      /**
40       * Constructor.
41       */
42      public VersioningServiceImpl(BindingSession session, CmisServiceFactory factory) {
43          setSession(session);
44          setServiceFactory(factory);
45      }
46  
47      @Override
48      public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension) {
49          CmisService service = getService(repositoryId);
50  
51          try {
52              if (stopBeforeService(service)) {
53                  return;
54              }
55  
56              service.cancelCheckOut(repositoryId, objectId, extension);
57  
58              if (stopAfterService(service)) {
59                  return;
60              }
61  
62          } finally {
63              service.close();
64          }
65      }
66  
67      @Override
68      public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
69              ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
70              ExtensionsData extension) {
71          CmisService service = getService(repositoryId);
72  
73          try {
74              if (stopBeforeService(service)) {
75                  return;
76              }
77  
78              service.checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment, policies,
79                      addAces, removeAces, extension);
80  
81              if (stopAfterService(service)) {
82                  return;
83              }
84          } finally {
85              service.close();
86          }
87      }
88  
89      @Override
90      public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
91              Holder<Boolean> contentCopied) {
92          CmisService service = getService(repositoryId);
93  
94          try {
95              if (stopBeforeService(service)) {
96                  return;
97              }
98  
99              service.checkOut(repositoryId, objectId, extension, contentCopied);
100 
101             if (stopAfterService(service)) {
102                 return;
103             }
104         } finally {
105             service.close();
106         }
107     }
108 
109     @Override
110     public List<ObjectData> getAllVersions(String repositoryId, String objectId, String versionSeriesId, String filter,
111             Boolean includeAllowableActions, ExtensionsData extension) {
112         CmisService service = getService(repositoryId);
113 
114         try {
115             if (stopBeforeService(service)) {
116                 return null;
117             }
118 
119             List<ObjectData> serviceResult = service.getAllVersions(repositoryId, objectId, versionSeriesId, filter,
120                     includeAllowableActions, extension);
121 
122             if (stopAfterService(service)) {
123                 return null;
124             }
125 
126             return serviceResult;
127         } finally {
128             service.close();
129         }
130     }
131 
132     @Override
133     public ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
134             Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
135             String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension) {
136         CmisService service = getService(repositoryId);
137 
138         try {
139             if (stopBeforeService(service)) {
140                 return null;
141             }
142 
143             ObjectData serviceResult = service.getObjectOfLatestVersion(repositoryId, objectId, versionSeriesId, major,
144                     filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds,
145                     includeAcl, extension);
146 
147             if (stopAfterService(service)) {
148                 return null;
149             }
150 
151             return serviceResult;
152         } finally {
153             service.close();
154         }
155     }
156 
157     @Override
158     public Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
159             Boolean major, String filter, ExtensionsData extension) {
160         CmisService service = getService(repositoryId);
161 
162         try {
163             if (stopBeforeService(service)) {
164                 return null;
165             }
166 
167             Properties serviceResult = service.getPropertiesOfLatestVersion(repositoryId, objectId, versionSeriesId,
168                     major, filter, extension);
169 
170             if (stopAfterService(service)) {
171                 return null;
172             }
173 
174             return serviceResult;
175         } finally {
176             service.close();
177         }
178     }
179 }