This project has retired. For details please refer to its
Attic page.
AclServiceImpl xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.client.bindings.spi.atompub;
2021importstatic org.apache.chemistry.opencmis.commons.impl.Converter.convert;
2223import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
24import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomAcl;
25import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
26import org.apache.chemistry.opencmis.commons.data.Acl;
27import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
28import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
29import org.apache.chemistry.opencmis.commons.impl.Constants;
30import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
31import org.apache.chemistry.opencmis.commons.spi.AclService;
3233/**34 * ACL Service AtomPub client.35 */36publicclassAclServiceImplextendsAbstractAtomPubService implements AclService {
3738/**39 * Constructor.40 */41publicAclServiceImpl(BindingSession session) {
42 setSession(session);
43 }
4445public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
46 AclPropagation aclPropagation, ExtensionsData extension) {
4748// fetch the current ACL49 Acl originalAces = getAcl(repositoryId, objectId, false, null);
5051// if no changes required, just return the ACL52if (!isAclMergeRequired(addAces, removeAces)) {
53return originalAces;
54 }
5556// merge ACLs57 Acl newACL = mergeAcls(originalAces, addAces, removeAces);
5859// update ACL60AtomAcl acl = updateAcl(repositoryId, objectId, newACL, aclPropagation);
61 Acl result = convert(acl.getACL(), null);
6263return result;
64 }
6566public Acl getAcl(String repositoryId, String objectId,
67 Boolean onlyBasicPermissions, ExtensionsData extension) {
6869// find the link70 String link = loadLink(repositoryId, objectId, Constants.REL_ACL, Constants.MEDIATYPE_ACL);
7172if (link == null) {
73 throwLinkException(repositoryId, objectId, Constants.REL_ACL, Constants.MEDIATYPE_ACL);
74 }
7576 UrlBuilder url = new UrlBuilder(link);
77 url.addParameter(Constants.PARAM_ONLY_BASIC_PERMISSIONS, onlyBasicPermissions);
7879// read and parse80 HttpUtils.Response resp = read(url);
81AtomAcl acl = parse(resp.getStream(), AtomAcl.class);
8283return convert(acl.getACL(), null);
84 }
8586 }