This project has retired. For details please refer to its Attic page.
InMemoryAclService 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.inmemory.server;
20  
21  import org.apache.chemistry.opencmis.commons.data.Acl;
22  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
23  import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
24  import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
25  import org.apache.chemistry.opencmis.commons.server.CallContext;
26  import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
27  import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
28  import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
29  import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  
33  public class InMemoryAclService extends InMemoryAbstractServiceImpl {
34  
35      private static final Log LOG = LogFactory.getLog(InMemoryAclService.class.getName());
36      final AtomLinkInfoProvider fAtomLinkProvider;
37  
38      public InMemoryAclService(StoreManager storeManager) {
39          super(storeManager);
40          fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
41      }
42  
43      public Acl getAcl(CallContext context, String repositoryId, String objectId, Boolean onlyBasicPermissions,
44              ExtensionsData extension, ObjectInfoHandler objectInfos) {
45          LOG.debug("start getAcl()");
46          Acl acl = null;
47          StoredObject so = validator.getAcl(context, repositoryId, objectId, extension);
48          if (so instanceof DocumentVersion)
49              acl = ((DocumentVersion) so).getParentDocument().getAcl();
50          else
51              acl = so.getAcl();
52  
53          if (context.isObjectInfoRequired()) {
54              ObjectInfoImpl objectInfo = new ObjectInfoImpl();
55              fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
56              objectInfos.addObjectInfo(objectInfo);
57          }
58          
59          return acl;
60      }
61  
62      public Acl applyAcl(CallContext context, String repositoryId, String objectId, Acl addAces, Acl removeAces, AclPropagation aclPropagation,
63              ExtensionsData extension, ObjectInfoHandler objectInfos) {
64  
65          StoredObject so = validator.applyAcl(context, repositoryId, objectId, aclPropagation, extension);
66          Acl acl = fStoreManager.getObjectStore(repositoryId).applyAcl(so, addAces, removeAces, aclPropagation, context.getUsername());
67          
68          if (context.isObjectInfoRequired()) {
69              ObjectInfoImpl objectInfo = new ObjectInfoImpl();
70              fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
71              objectInfos.addObjectInfo(objectInfo);
72          }
73          return acl;       
74      }
75      
76      public Acl applyAcl(CallContext context, String repositoryId, String objectId, Acl aces, AclPropagation aclPropagation) {
77          
78          StoredObject so = validator.applyAcl(context, repositoryId, objectId);
79          return fStoreManager.getObjectStore(repositoryId).applyAcl(so, aces, aclPropagation, context.getUsername());        
80      }
81  
82  }