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.bindings.spi.webservices;
20  
21  import static org.apache.chemistry.opencmis.commons.impl.WSConverter.convertExtensionHolder;
22  import static org.apache.chemistry.opencmis.commons.impl.WSConverter.setExtensionValues;
23  
24  import javax.xml.ws.Holder;
25  
26  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
27  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
28  import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
29  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
30  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
31  import org.apache.chemistry.opencmis.commons.impl.jaxb.MultiFilingServicePort;
32  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
33  
34  /**
35   * MultiFiling Service Web Services client.
36   */
37  public class MultiFilingServiceImpl extends AbstractWebServicesService implements MultiFilingService {
38  
39      private final AbstractPortProvider portProvider;
40  
41      /**
42       * Constructor.
43       */
44      public MultiFilingServiceImpl(BindingSession session, AbstractPortProvider portProvider) {
45          setSession(session);
46          this.portProvider = portProvider;
47      }
48  
49      @Override
50      public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
51              ExtensionsData extension) {
52          MultiFilingServicePort port = portProvider.getMultiFilingServicePort(getCmisVersion(repositoryId),
53                  "addObjectToFolder");
54  
55          try {
56              Holder<CmisExtensionType> portExtension = convertExtensionHolder(extension);
57  
58              port.addObjectToFolder(repositoryId, objectId, folderId, allVersions, portExtension);
59  
60              setExtensionValues(portExtension, extension);
61          } catch (CmisException e) {
62              throw convertException(e);
63          } catch (Exception e) {
64              throw new CmisRuntimeException("Error: " + e.getMessage(), e);
65          } finally {
66              portProvider.endCall(port);
67          }
68      }
69  
70      @Override
71      public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
72          MultiFilingServicePort port = portProvider.getMultiFilingServicePort(getCmisVersion(repositoryId),
73                  "removeObjectFromFolder");
74  
75          try {
76              Holder<CmisExtensionType> portExtension = convertExtensionHolder(extension);
77  
78              port.removeObjectFromFolder(repositoryId, objectId, folderId, portExtension);
79  
80              setExtensionValues(portExtension, extension);
81          } catch (CmisException e) {
82              throw convertException(e);
83          } catch (Exception e) {
84              throw new CmisRuntimeException("Error: " + e.getMessage(), e);
85          } finally {
86              portProvider.endCall(port);
87          }
88      }
89  }