001/*
002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     arussel
018 */
019package org.nuxeo.ecm.platform.publisher.task;
020
021import org.nuxeo.ecm.core.api.CoreSession;
022import org.nuxeo.ecm.core.api.DocumentModel;
023import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner;
024import org.nuxeo.ecm.core.api.security.ACP;
025
026/**
027 * @author arussel
028 * @author ataillefer XXX ataillefer: get rid of oldAclName if refactor old JBPM ACL name
029 */
030public class RemoveACLUnrestricted extends UnrestrictedSessionRunner {
031    private final DocumentModel document;
032
033    private final String aclName;
034
035    private final String oldAclName;
036
037    public RemoveACLUnrestricted(CoreSession session, DocumentModel document, String aclName, String oldAclName) {
038        super(session);
039        this.document = document;
040        this.aclName = aclName;
041        this.oldAclName = oldAclName;
042    }
043
044    @Override
045    public void run() {
046        ACP acp = document.getACP();
047        acp.removeACL(aclName);
048        acp.removeACL(oldAclName);
049        session.setACP(document.getRef(), acp, true);
050        session.save();
051        acp = document.getACP();
052    }
053
054}