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.api; 019 020import static com.google.common.collect.ImmutableSet.of; 021import static org.apache.jena.rdf.model.ResourceFactory.createProperty; 022import static org.apache.jena.rdf.model.ResourceFactory.createResource; 023 024import java.util.Set; 025import java.util.function.Predicate; 026 027import com.google.common.collect.ImmutableSet; 028import org.apache.jena.rdf.model.Property; 029import org.apache.jena.rdf.model.Resource; 030 031/** 032 * A lexicon of the RDF properties that the fcrepo kernel (or close-to-core modules) use 033 * 034 * @author ajs6f 035 */ 036public final class RdfLexicon { 037 038 /** 039 * Repository namespace "fedora" 040 **/ 041 public static final String REPOSITORY_NAMESPACE = "http://fedora.info/definitions/v4/repository#"; 042 043 public static final String EVENT_NAMESPACE = "http://fedora.info/definitions/v4/event#"; 044 045 public static final String EBUCORE_NAMESPACE = "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#"; 046 047 public static final String PROV_NAMESPACE = "http://www.w3.org/ns/prov#"; 048 049 public static final String PREMIS_NAMESPACE = "http://www.loc.gov/premis/rdf/v1#"; 050 051 /** 052 * Fedora configuration namespace "fedora-config", used for user-settable 053 * configuration properties. 054 **/ 055 // TODO from UCDetector: Constant "RdfLexicon.FEDORA_CONFIG_NAMESPACE" has 0 references 056 // should be referenced again when versioning is back in REST api 057 public static final String FEDORA_CONFIG_NAMESPACE = // NO_UCD (unused code) 058 "info:fedoraconfig/"; 059 060 /** 061 * Linked Data Platform namespace. 062 */ 063 public static final String LDP_NAMESPACE = "http://www.w3.org/ns/ldp#"; 064 065 /** 066 * SPARQL service description namespace. 067 */ 068 public static final String SPARQL_SD_NAMESPACE = 069 "http://www.w3.org/ns/sparql-service-description#"; 070 071 /** 072 * Is this namespace one that the repository manages? 073 */ 074 public static final Predicate<String> isManagedNamespace = p -> p.equals(REPOSITORY_NAMESPACE); 075 076 // MEMBERSHIP 077 public static final Property HAS_PARENT = 078 createProperty(REPOSITORY_NAMESPACE + "hasParent"); 079 public static final Property HAS_CHILD = 080 createProperty(REPOSITORY_NAMESPACE + "hasChild"); 081 082 public static final Set<Property> membershipProperties = of(HAS_PARENT, HAS_CHILD); 083 084 // FIXITY 085 086 public static final Resource FIXITY_TYPE = createResource(PREMIS_NAMESPACE + "Fixity"); 087 public static final Property HAS_MESSAGE_DIGEST = 088 createProperty(PREMIS_NAMESPACE + "hasMessageDigest"); 089 public static final Property HAS_SIZE = 090 createProperty(PREMIS_NAMESPACE + "hasSize"); 091 public static final Property HAS_FIXITY_RESULT = 092 createProperty(PREMIS_NAMESPACE + "hasFixity"); 093 094 public static final Property HAS_FIXITY_CHECK_COUNT = 095 createProperty(REPOSITORY_NAMESPACE + "numFixityChecks"); 096 public static final Property HAS_FIXITY_ERROR_COUNT = 097 createProperty(REPOSITORY_NAMESPACE + "numFixityErrors"); 098 public static final Property HAS_FIXITY_REPAIRED_COUNT = 099 createProperty(REPOSITORY_NAMESPACE + "numFixityRepaired"); 100 101 public static final Set<Property> fixityProperties = of( 102 HAS_FIXITY_RESULT, HAS_MESSAGE_DIGEST, HAS_SIZE, 103 HAS_FIXITY_CHECK_COUNT, HAS_FIXITY_ERROR_COUNT, HAS_FIXITY_REPAIRED_COUNT); 104 105 public static final Resource EVENT_OUTCOME_INFORMATION = createResource(PREMIS_NAMESPACE + "EventOutcomeDetail"); 106 107 public static final Property HAS_FIXITY_STATE = 108 createProperty(PREMIS_NAMESPACE + "hasEventOutcome"); 109 110 public static final Property WRITABLE = 111 createProperty(REPOSITORY_NAMESPACE + "writable"); 112 113 // Server managed properties 114 public static final Property CREATED_DATE = 115 createProperty(REPOSITORY_NAMESPACE + "created"); 116 public static final Property CREATED_BY = 117 createProperty(REPOSITORY_NAMESPACE + "createdBy"); 118 public static final Property LAST_MODIFIED_DATE = 119 createProperty(REPOSITORY_NAMESPACE + "lastModified"); 120 public static final Property LAST_MODIFIED_BY = 121 createProperty(REPOSITORY_NAMESPACE + "lastModifiedBy"); 122 public static final Set<Property> serverManagedProperties = of( 123 CREATED_DATE, CREATED_BY, LAST_MODIFIED_DATE, LAST_MODIFIED_BY); 124 125 // Linked Data Platform 126 public static final Property PAGE = 127 createProperty(LDP_NAMESPACE + "Page"); 128 public static final Resource CONTAINER = 129 createResource(LDP_NAMESPACE + "Container"); 130 public static final Resource BASIC_CONTAINER = 131 createResource(LDP_NAMESPACE + "BasicContainer"); 132 public static final Resource DIRECT_CONTAINER = 133 createResource(LDP_NAMESPACE + "DirectContainer"); 134 public static final Resource INDIRECT_CONTAINER = 135 createResource(LDP_NAMESPACE + "IndirectContainer"); 136 public static final Property MEMBERSHIP_RESOURCE = 137 createProperty(LDP_NAMESPACE + "membershipResource"); 138 public static final Property HAS_MEMBER_RELATION = 139 createProperty(LDP_NAMESPACE + "hasMemberRelation"); 140 public static final Property CONTAINS = 141 createProperty(LDP_NAMESPACE + "contains"); 142 public static final Property LDP_MEMBER = 143 createProperty(LDP_NAMESPACE + "member"); 144 public static final Property RDF_SOURCE = 145 createProperty(LDP_NAMESPACE + "RDFSource"); 146 public static final Property NON_RDF_SOURCE = 147 createProperty(LDP_NAMESPACE + "NonRDFSource"); 148 public static final Property CONSTRAINED_BY = 149 createProperty(LDP_NAMESPACE + "constrainedBy"); 150 public static final Property MEMBER_SUBJECT = 151 createProperty(LDP_NAMESPACE + "MemberSubject"); 152 153 private static final Set<Property> ldpProperties = of(CONTAINS, LDP_MEMBER); 154 155 // REPOSITORY INFORMATION 156 public static final Property HAS_OBJECT_COUNT = 157 createProperty(REPOSITORY_NAMESPACE + "objectCount"); 158 public static final Property HAS_OBJECT_SIZE = 159 createProperty(REPOSITORY_NAMESPACE + "objectSize"); 160 public static final Property HAS_TRANSACTION_SERVICE = 161 createProperty(REPOSITORY_NAMESPACE + "hasTransactionProvider"); 162 public static final Property HAS_ACCESS_ROLES_SERVICE = 163 createProperty(REPOSITORY_NAMESPACE + "hasAccessRoles"); 164 165 public static final Set<Property> repositoryProperties = of( 166 HAS_OBJECT_COUNT, HAS_OBJECT_SIZE, HAS_TRANSACTION_SERVICE); 167 168 // NAMESPACES 169 public static final Property HAS_NAMESPACE_PREFIX = 170 createProperty("http://purl.org/vocab/vann/preferredNamespacePrefix"); 171 public static final Property HAS_NAMESPACE_URI = 172 createProperty("http://purl.org/vocab/vann/preferredNamespaceUri"); 173 174 public static final Set<Property> namespaceProperties = of( 175 HAS_NAMESPACE_PREFIX, HAS_NAMESPACE_URI); 176 177 // OTHER SERVICES 178 public static final Property HAS_VERSION_HISTORY = 179 createProperty(REPOSITORY_NAMESPACE + "hasVersions"); 180 public static final Property HAS_FIXITY_SERVICE = 181 createProperty(REPOSITORY_NAMESPACE + "hasFixityService"); 182 public static final Property HAS_SPARQL_ENDPOINT = 183 createProperty(SPARQL_SD_NAMESPACE + "endpoint"); 184 185 public static final Set<Property> otherServiceProperties = of( 186 HAS_VERSION_HISTORY, HAS_FIXITY_SERVICE); 187 188 189 // BINARY DESCRIPTIONS 190 public static final Property DESCRIBES = 191 createProperty("http://www.iana.org/assignments/relation/describes"); 192 public static final Property DESCRIBED_BY = 193 createProperty("http://www.iana.org/assignments/relation/describedby"); 194 195 public static final Set<Property> structProperties = of(DESCRIBES, DESCRIBED_BY); 196 197 // CONTENT 198 public static final Resource CONTENT_LOCATION_TYPE = 199 createResource(PREMIS_NAMESPACE + "ContentLocation"); 200 public static final Resource INACCESSIBLE_RESOURCE = 201 createResource(REPOSITORY_NAMESPACE + "inaccessibleResource"); 202 public static final Property HAS_CONTENT_LOCATION = 203 createProperty(PREMIS_NAMESPACE + "hasContentLocation"); 204 public static final Property HAS_CONTENT_LOCATION_VALUE = 205 createProperty(PREMIS_NAMESPACE + "hasContentLocationValue"); 206 public static final Property HAS_MIME_TYPE = 207 createProperty(EBUCORE_NAMESPACE + "hasMimeType"); 208 public static final Property HAS_ORIGINAL_NAME = 209 createProperty(EBUCORE_NAMESPACE + "filename"); 210 211 public static final Set<Property> contentProperties = of(HAS_CONTENT_LOCATION, HAS_CONTENT_LOCATION_VALUE, 212 HAS_SIZE); 213 214 215 // VERSIONING 216 public static final Property HAS_VERSION = 217 createProperty(REPOSITORY_NAMESPACE + "hasVersion"); 218 public static final Property HAS_VERSION_LABEL = 219 createProperty(REPOSITORY_NAMESPACE + "hasVersionLabel"); 220 221 public static final Set<Property> versioningProperties = of(HAS_VERSION, 222 HAS_VERSION_LABEL); 223 224 // RDF EXTRACTION 225 public static final Property COULD_NOT_STORE_PROPERTY = 226 createProperty(REPOSITORY_NAMESPACE + "couldNotStoreProperty"); 227 public static final Property INBOUND_REFERENCES = createProperty(REPOSITORY_NAMESPACE + "InboundReferences"); 228 public static final Property EMBED_CONTAINS = createProperty(REPOSITORY_NAMESPACE + "EmbedResources"); 229 public static final Property SERVER_MANAGED = createProperty(REPOSITORY_NAMESPACE + "ServerManaged"); 230 231 public static final Set<Property> managedProperties; 232 233 static { 234 final ImmutableSet.Builder<Property> b = ImmutableSet.builder(); 235 b.addAll(membershipProperties).addAll(fixityProperties).addAll(ldpProperties).addAll( 236 repositoryProperties).addAll(namespaceProperties).addAll( 237 otherServiceProperties).addAll(structProperties).addAll(contentProperties).addAll( 238 versioningProperties).addAll(serverManagedProperties); 239 managedProperties = b.build(); 240 } 241 242 private static Predicate<Property> hasFedoraNamespace = 243 p -> !p.isAnon() && p.getNameSpace().startsWith(REPOSITORY_NAMESPACE); 244 245 /** 246 * Detects whether an RDF property is managed by the repository. 247 */ 248 public static final Predicate<Property> isManagedPredicate = 249 hasFedoraNamespace.or(p -> managedProperties.contains(p)); 250 251 private RdfLexicon() { 252 253 } 254}