This project has retired. For details please refer to its Attic page.
DiscoveryServiceImpl xref

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.Converter.convert;
22  import static org.apache.chemistry.opencmis.commons.impl.Converter.convertHolder;
23  import static org.apache.chemistry.opencmis.commons.impl.Converter.setHolderValue;
24  
25  import java.math.BigInteger;
26  
27  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
28  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
29  import org.apache.chemistry.opencmis.commons.data.ObjectList;
30  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
31  import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
32  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
33  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectListType;
34  import org.apache.chemistry.opencmis.commons.impl.jaxb.DiscoveryServicePort;
35  import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumIncludeRelationships;
36  import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
37  import org.apache.chemistry.opencmis.commons.spi.Holder;
38  
39  /**
40   * Discovery Service Web Services client.
41   */
42  public class DiscoveryServiceImpl extends AbstractWebServicesService implements DiscoveryService {
43  
44      private final AbstractPortProvider portProvider;
45  
46      /**
47       * Constructor.
48       */
49      public DiscoveryServiceImpl(BindingSession session, AbstractPortProvider portProvider) {
50          setSession(session);
51          this.portProvider = portProvider;
52      }
53  
54      public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
55              String filter, Boolean includePolicyIds, Boolean includeACL, BigInteger maxItems, ExtensionsData extension) {
56          DiscoveryServicePort port = portProvider.getDiscoveryServicePort();
57  
58          try {
59              javax.xml.ws.Holder<String> portChangeLokToken = convertHolder(changeLogToken);
60              javax.xml.ws.Holder<CmisObjectListType> portObjects = new javax.xml.ws.Holder<CmisObjectListType>();
61  
62              port.getContentChanges(repositoryId, portChangeLokToken, includeProperties, filter, includePolicyIds,
63                      includeACL, maxItems, convert(extension), portObjects);
64  
65              setHolderValue(portChangeLokToken, changeLogToken);
66  
67              return convert(portObjects.value);
68          } catch (CmisException e) {
69              throw convertException(e);
70          } catch (Exception e) {
71              throw new CmisRuntimeException("Error: " + e.getMessage(), e);
72          } finally {
73              portProvider.endCall(port);
74          }
75      }
76  
77      public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
78              Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
79              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
80          DiscoveryServicePort port = portProvider.getDiscoveryServicePort();
81  
82          try {
83              return convert(port.query(repositoryId, statement, searchAllVersions, includeAllowableActions,
84                      convert(EnumIncludeRelationships.class, includeRelationships), renditionFilter, maxItems,
85                      skipCount, convert(extension)));
86          } catch (CmisException e) {
87              throw convertException(e);
88          } catch (Exception e) {
89              throw new CmisRuntimeException("Error: " + e.getMessage(), e);
90          } finally {
91              portProvider.endCall(port);
92          }
93      }
94  }