001/*
002 * Licensed to DuraSpace under one or more contributor license agreements.
003 * See the NOTICE file distributed with this work for additional information
004 * regarding copyright ownership.
005 *
006 * DuraSpace licenses this file to you under the Apache License,
007 * Version 2.0 (the "License"); you may not use this file except in
008 * compliance with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.fcrepo.kernel.impl.models;
019
020import org.fcrepo.kernel.api.exception.PathNotFoundException;
021import org.fcrepo.kernel.api.exception.PathNotFoundRuntimeException;
022import org.fcrepo.kernel.api.identifiers.FedoraId;
023import org.fcrepo.kernel.api.models.FedoraResource;
024import org.fcrepo.kernel.api.models.ResourceFactory;
025import org.fcrepo.kernel.api.models.WebacAcl;
026import org.fcrepo.persistence.api.PersistentStorageSessionManager;
027
028/**
029 * Webac Acl class
030 *
031 * @author whikloj
032 */
033public class WebacAclImpl extends ContainerImpl implements WebacAcl {
034
035    /**
036     * Constructor
037     * @param fedoraID the internal identifier
038     * @param txId the current transactionId
039     * @param pSessionManager a session manager
040     * @param resourceFactory a resource factory instance.
041     */
042    public WebacAclImpl(final FedoraId fedoraID, final String txId,
043                        final PersistentStorageSessionManager pSessionManager, final ResourceFactory resourceFactory) {
044        super(fedoraID, txId, pSessionManager, resourceFactory);
045    }
046
047    @Override
048    public FedoraResource getContainer() {
049        final var originalId = FedoraId.create(getFedoraId().getBaseId());
050        try {
051
052            return resourceFactory.getResource(txId, originalId);
053        } catch (final PathNotFoundException exc) {
054            throw new PathNotFoundRuntimeException(exc.getMessage(), exc);
055        }
056    }
057
058    @Override
059    public boolean isOriginalResource() {
060        return false;
061    }
062
063    @Override
064    public boolean isAcl() {
065        return true;
066    }
067}