001/** 002 * Copyright 2015 DuraSpace, Inc. 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 */ 016package org.fcrepo.kernel.modeshape.rdf.impl; 017 018import com.hp.hpl.jena.rdf.model.Resource; 019import org.fcrepo.kernel.api.models.FedoraResource; 020import org.fcrepo.kernel.api.identifiers.IdentifierConverter; 021 022import javax.jcr.RepositoryException; 023import java.security.AccessControlException; 024 025import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDboolean; 026import static com.hp.hpl.jena.graph.NodeFactory.createLiteral; 027import static com.hp.hpl.jena.graph.Triple.create; 028import static org.fcrepo.kernel.api.RdfLexicon.WRITABLE; 029 030/** 031 * @author cabeer 032 * @since 10/1/14 033 */ 034public class AclRdfContext extends NodeRdfContext { 035 /** 036 * Default constructor. 037 * 038 * @param resource the resource 039 * @param idTranslator the property of idTranslator 040 * @throws javax.jcr.RepositoryException if repository exception occurred 041 */ 042 public AclRdfContext(final FedoraResource resource, 043 final IdentifierConverter<Resource, FedoraResource> idTranslator) throws RepositoryException { 044 super(resource, idTranslator); 045 046 boolean writable = false; 047 try { 048 resource().getNode().getSession().checkPermission( resource().getPath(), "add_node,set_property,remove" ); 049 writable = true; 050 } catch ( final AccessControlException ex ) { 051 writable = false; 052 } 053 concat(create(subject(), WRITABLE.asNode(), createLiteral(String.valueOf(writable), XSDboolean))); 054 } 055}