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.atompub;
20  
21  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
22  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomAcl;
23  import org.apache.chemistry.opencmis.commons.data.Acl;
24  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
25  import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
26  import org.apache.chemistry.opencmis.commons.spi.AclService;
27  import org.apache.chemistry.opencmis.commons.spi.ExtendedAclService;
28  
29  /**
30   * ACL Service AtomPub client.
31   */
32  public class AclServiceImpl extends AbstractAtomPubService implements AclService, ExtendedAclService {
33  
34      /**
35       * Constructor.
36       */
37      public AclServiceImpl(BindingSession session) {
38          setSession(session);
39      }
40  
41      @Override
42      public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
43              AclPropagation aclPropagation, ExtensionsData extension) {
44  
45          // fetch the current ACL
46          Acl originalAces = getAcl(repositoryId, objectId, false, null);
47  
48          // if no changes required, just return the ACL
49          if (!isAclMergeRequired(addAces, removeAces)) {
50              return originalAces;
51          }
52  
53          // merge ACLs
54          Acl newACL = mergeAcls(originalAces, addAces, removeAces);
55  
56          // update ACL
57          AtomAcl acl = updateAcl(repositoryId, objectId, newACL, aclPropagation);
58          Acl result = acl.getACL();
59  
60          return result;
61      }
62  
63      @Override
64      public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
65          return getAclInternal(repositoryId, objectId, onlyBasicPermissions, extension);
66      }
67  
68      @Override
69      public Acl setAcl(String repositoryId, String objectId, Acl aces) {
70          AtomAcl acl = updateAcl(repositoryId, objectId, aces, AclPropagation.OBJECTONLY);
71          Acl result = acl.getACL();
72  
73          return result;
74      }
75  }