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.browser;
20  
21  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
22  import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
23  import org.apache.chemistry.opencmis.commons.spi.AclService;
24  import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
25  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
26  import org.apache.chemistry.opencmis.commons.spi.NavigationService;
27  import org.apache.chemistry.opencmis.commons.spi.ObjectService;
28  import org.apache.chemistry.opencmis.commons.spi.PolicyService;
29  import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
30  import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
31  import org.apache.chemistry.opencmis.commons.spi.VersioningService;
32  import org.slf4j.Logger;
33  import org.slf4j.LoggerFactory;
34  
35  public class CmisBrowserBindingSpi implements CmisSpi {
36  
37      private static final Logger LOG = LoggerFactory.getLogger(CmisBrowserBindingSpi.class);
38  
39      private final BindingSession session;
40  
41      private final RepositoryService repositoryService;
42      private final NavigationService navigationService;
43      private final ObjectService objectService;
44      private final VersioningService versioningService;
45      private final DiscoveryService discoveryService;
46      private final MultiFilingService multiFilingService;
47      private final RelationshipService relationshipService;
48      private final PolicyService policyService;
49      private final AclService aclService;
50  
51      /**
52       * Constructor.
53       */
54      public CmisBrowserBindingSpi(BindingSession session) {
55          if (LOG.isDebugEnabled()) {
56              LOG.debug("Session {}: Initializing Browser Binding SPI...", session.getSessionId());
57          }
58  
59          this.session = session;
60  
61          repositoryService = new RepositoryServiceImpl(session);
62          navigationService = new NavigationServiceImpl(session);
63          objectService = new ObjectServiceImpl(session);
64          versioningService = new VersioningServiceImpl(session);
65          discoveryService = new DiscoveryServiceImpl(session);
66          multiFilingService = new MultiFilingServiceImpl(session);
67          relationshipService = new RelationshipServiceImpl(session);
68          policyService = new PolicyServiceImpl(session);
69          aclService = new AclServiceImpl(session);
70      }
71  
72      @Override
73      public RepositoryService getRepositoryService() {
74          return repositoryService;
75      }
76  
77      @Override
78      public NavigationService getNavigationService() {
79          return navigationService;
80      }
81  
82      @Override
83      public ObjectService getObjectService() {
84          return objectService;
85      }
86  
87      @Override
88      public VersioningService getVersioningService() {
89          return versioningService;
90      }
91  
92      @Override
93      public RelationshipService getRelationshipService() {
94          return relationshipService;
95      }
96  
97      @Override
98      public DiscoveryService getDiscoveryService() {
99          return discoveryService;
100     }
101 
102     @Override
103     public MultiFilingService getMultiFilingService() {
104         return multiFilingService;
105     }
106 
107     @Override
108     public AclService getAclService() {
109         return aclService;
110     }
111 
112     @Override
113     public PolicyService getPolicyService() {
114         return policyService;
115     }
116 
117     @Override
118     public void clearAllCaches() {
119         session.remove(SpiSessionParameter.REPOSITORY_URL_CACHE);
120     }
121 
122     @Override
123     public void clearRepositoryCache(String repositoryId) {
124         RepositoryUrlCache repUrlCache = (RepositoryUrlCache) session.get(SpiSessionParameter.REPOSITORY_URL_CACHE);
125         if (repUrlCache != null) {
126             repUrlCache.removeRepository(repositoryId);
127         }
128     }
129 
130     @Override
131     public void close() {
132         // no-op for Browser Binding
133     }
134 }