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.api; 017 018import static com.google.common.collect.ImmutableSet.of; 019import static com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty; 020import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource; 021 022import java.util.Set; 023import java.util.function.Predicate; 024 025import com.google.common.collect.ImmutableSet; 026import com.hp.hpl.jena.rdf.model.Property; 027import com.hp.hpl.jena.rdf.model.Resource; 028 029/** 030 * A lexicon of the RDF properties that the fcrepo kernel (or close-to-core modules) use 031 * 032 * @author ajs6f 033 */ 034public final class RdfLexicon { 035 036 /** 037 * Repository namespace "fcrepo", used for JCR properties exposed 038 * publicly. 039 * Was "info:fedora/fedora-system:def/internal#". 040 **/ 041 public static final String REPOSITORY_NAMESPACE = 042 "http://fedora.info/definitions/v4/repository#"; 043 044 /** 045 * The core JCR namespace. 046 */ 047 public static final String JCR_NAMESPACE = "http://www.jcp.org/jcr/1.0"; 048 049 public static final String MODE_NAMESPACE = "http://www.modeshape.org/1.0"; 050 051 public static final String MIX_NAMESPACE = "http://www.jcp.org/jcr/mix/1.0"; 052 053 public static final String JCR_NT_NAMESPACE = "http://www.jcp.org/jcr/nt/1.0"; 054 055 public static final String EBUCORE_NAMESPACE = "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#"; 056 057 /** 058 * Fedora configuration namespace "fedora-config", used for user-settable 059 * configuration properties. 060 **/ 061 // TODO from UCDetector: Constant "RdfLexicon.FEDORA_CONFIG_NAMESPACE" has 0 references 062 // should be referenced again when versioning is back in REST api 063 public static final String FEDORA_CONFIG_NAMESPACE = // NO_UCD (unused code) 064 "http://fedora.info/definitions/v4/config#"; 065 066 /** 067 * REST API namespace "fedora", used for internal API links and node 068 * paths. 069 * Was "info:fedora/". 070 **/ 071 public static final String PREMIS_NAMESPACE = 072 "http://www.loc.gov/premis/rdf/v1#"; 073 074 /** 075 * Linked Data Platform namespace. 076 */ 077 public static final String LDP_NAMESPACE = "http://www.w3.org/ns/ldp#"; 078 079 /** 080 * SPARQL service description namespace. 081 */ 082 public static final String SPARQL_SD_NAMESPACE = 083 "http://www.w3.org/ns/sparql-service-description#"; 084 085 /** 086 * The namespaces that the repository manages internally. 087 */ 088 public static final Set<String> managedNamespaces = of( 089 REPOSITORY_NAMESPACE, JCR_NAMESPACE, 090 MIX_NAMESPACE, JCR_NT_NAMESPACE, MODE_NAMESPACE); 091 092 /** 093 * Is this namespace one that the repository manages? 094 */ 095 public static final Predicate<String> isManagedNamespace = 096 p -> managedNamespaces.contains(p); 097 098 public static final String RDF_NAMESPACE = 099 "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 100 101 public static final String INDEXING_NAMESPACE = 102 "http://fedora.info/definitions/v4/indexing#"; 103 104 public static final String DC_NAMESPACE = 105 "http://purl.org/dc/elements/1.1/"; 106 107 // MEMBERSHIP 108 public static final Property HAS_PARENT = 109 createProperty(REPOSITORY_NAMESPACE + "hasParent"); 110 public static final Property HAS_CHILD = 111 createProperty(REPOSITORY_NAMESPACE + "hasChild"); 112 public static final Property HAS_CHILD_COUNT = 113 createProperty(REPOSITORY_NAMESPACE + "numberOfChildren"); 114 115 public static final Set<Property> membershipProperties = of(HAS_PARENT, HAS_CHILD, HAS_CHILD_COUNT); 116 117 // FIXITY 118 119 public static final Resource FIXITY_TYPE = createResource(PREMIS_NAMESPACE + "Fixity"); 120 public static final Property HAS_MESSAGE_DIGEST = 121 createProperty(PREMIS_NAMESPACE + "hasMessageDigest"); 122 public static final Property HAS_SIZE = 123 createProperty(PREMIS_NAMESPACE + "hasSize"); 124 public static final Property HAS_FIXITY_RESULT = 125 createProperty(PREMIS_NAMESPACE + "hasFixity"); 126 127 public static final Property HAS_FIXITY_CHECK_COUNT = 128 createProperty(REPOSITORY_NAMESPACE + "numFixityChecks"); 129 public static final Property HAS_FIXITY_ERROR_COUNT = 130 createProperty(REPOSITORY_NAMESPACE + "numFixityErrors"); 131 public static final Property HAS_FIXITY_REPAIRED_COUNT = 132 createProperty(REPOSITORY_NAMESPACE + "numFixityRepaired"); 133 134 public static final Set<Property> fixityProperties = of( 135 HAS_FIXITY_RESULT, HAS_MESSAGE_DIGEST, HAS_SIZE, 136 HAS_FIXITY_CHECK_COUNT, HAS_FIXITY_ERROR_COUNT, HAS_FIXITY_REPAIRED_COUNT); 137 138 public static final Resource EVENT_OUTCOME_INFORMATION = createResource(PREMIS_NAMESPACE + "EventOutcomeDetail"); 139 140 public static final Property HAS_FIXITY_STATE = 141 createProperty(PREMIS_NAMESPACE + "hasEventOutcome"); 142 143 public static final Property WRITABLE = 144 createProperty(REPOSITORY_NAMESPACE + "writable"); 145 146 // Linked Data Platform 147 public static final Property PAGE = 148 createProperty(LDP_NAMESPACE + "Page"); 149 public static final Property PAGE_OF = 150 createProperty(LDP_NAMESPACE + "pageOf"); 151 public static final Property FIRST_PAGE = 152 createProperty(LDP_NAMESPACE + "firstPage"); 153 public static final Property NEXT_PAGE = 154 createProperty(LDP_NAMESPACE + "nextPage"); 155 public static final Resource CONTAINER = 156 createResource(LDP_NAMESPACE + "Container"); 157 public static final Resource BASIC_CONTAINER = 158 createResource(LDP_NAMESPACE + "BasicContainer"); 159 public static final Resource DIRECT_CONTAINER = 160 createResource(LDP_NAMESPACE + "DirectContainer"); 161 public static final Resource INDIRECT_CONTAINER = 162 createResource(LDP_NAMESPACE + "IndirectContainer"); 163 public static final Property MEMBERSHIP_RESOURCE = 164 createProperty(LDP_NAMESPACE + "membershipResource"); 165 public static final Property HAS_MEMBER_RELATION = 166 createProperty(LDP_NAMESPACE + "hasMemberRelation"); 167 public static final Property CONTAINS = 168 createProperty(LDP_NAMESPACE + "contains"); 169 public static final Property LDP_MEMBER = 170 createProperty(LDP_NAMESPACE + "member"); 171 public static final Property RDF_SOURCE = 172 createProperty(LDP_NAMESPACE + "RDFSource"); 173 public static final Property NON_RDF_SOURCE = 174 createProperty(LDP_NAMESPACE + "NonRDFSource"); 175 public static final Property CONSTRAINED_BY = 176 createProperty(LDP_NAMESPACE + "constrainedBy"); 177 public static final Property MEMBER_SUBJECT = 178 createProperty(LDP_NAMESPACE + "MemberSubject"); 179 180 public static final Set<Property> ldpProperties = of(PAGE, PAGE_OF, 181 FIRST_PAGE, NEXT_PAGE, CONTAINS, LDP_MEMBER); 182 public static final Set<Resource> ldpResources = of(CONTAINER, 183 DIRECT_CONTAINER); 184 185 // REPOSITORY INFORMATION 186 public static final Property HAS_OBJECT_COUNT = 187 createProperty(REPOSITORY_NAMESPACE + "objectCount"); 188 public static final Property HAS_OBJECT_SIZE = 189 createProperty(REPOSITORY_NAMESPACE + "objectSize"); 190 public static final Property HAS_TRANSACTION_SERVICE = 191 createProperty(REPOSITORY_NAMESPACE + "hasTransactionProvider"); 192 public static final Property HAS_ACCESS_ROLES_SERVICE = 193 createProperty(REPOSITORY_NAMESPACE + "hasAccessRoles"); 194 195 public static final Set<Property> repositoryProperties = of( 196 HAS_OBJECT_COUNT, HAS_OBJECT_SIZE, HAS_TRANSACTION_SERVICE); 197 198 // NAMESPACES 199 public static final Property HAS_NAMESPACE_PREFIX = 200 createProperty("http://purl.org/vocab/vann/preferredNamespacePrefix"); 201 public static final Property HAS_NAMESPACE_URI = 202 createProperty("http://purl.org/vocab/vann/preferredNamespaceUri"); 203 public static final Property VOAF_VOCABULARY = createProperty("http://purl.org/vocommons/voaf#Vocabulary"); 204 205 public static final Set<Property> namespaceProperties = of( 206 HAS_NAMESPACE_PREFIX, HAS_NAMESPACE_URI, VOAF_VOCABULARY); 207 208 // OTHER SERVICES 209 public static final Property HAS_SERIALIZATION = 210 createProperty(REPOSITORY_NAMESPACE + "exportsAs"); 211 public static final Property HAS_VERSION_HISTORY = 212 createProperty(REPOSITORY_NAMESPACE + "hasVersions"); 213 public static final Property HAS_FIXITY_SERVICE = 214 createProperty(REPOSITORY_NAMESPACE + "hasFixityService"); 215 public static final Property HAS_FEED = 216 createProperty( 217 "http://www.whatwg.org/specs/web-apps/current-work/#", 218 "feed0"); 219 public static final Property HAS_SUBSCRIPTION_SERVICE = 220 createProperty("http://microformats.org/wiki/rel-subscription"); 221 public static final Property HAS_SPARQL_ENDPOINT = 222 createProperty(SPARQL_SD_NAMESPACE + "endpoint"); 223 224 public static final Set<Property> otherServiceProperties = of( 225 HAS_SERIALIZATION, HAS_VERSION_HISTORY, HAS_FIXITY_SERVICE, 226 HAS_FEED, HAS_SUBSCRIPTION_SERVICE); 227 228 229 // BINARY DESCRIPTIONS 230 public static final Property DESCRIBES = 231 createProperty("http://www.iana.org/assignments/relation/describes"); 232 public static final Property DESCRIBED_BY = 233 createProperty("http://www.iana.org/assignments/relation/describedby"); 234 235 public static final Set<Property> structProperties = of(DESCRIBES, DESCRIBED_BY); 236 237 // CONTENT 238 public static final Resource CONTENT_LOCATION_TYPE = 239 createResource(PREMIS_NAMESPACE + "ContentLocation"); 240 public static final Resource INACCESSIBLE_RESOURCE = 241 createResource(REPOSITORY_NAMESPACE + "inaccessibleResource"); 242 public static final Property HAS_CONTENT_LOCATION = 243 createProperty(PREMIS_NAMESPACE + "hasContentLocation"); 244 public static final Property HAS_CONTENT_LOCATION_VALUE = 245 createProperty(PREMIS_NAMESPACE + "hasContentLocationValue"); 246 public static final Property HAS_MIME_TYPE = 247 createProperty(EBUCORE_NAMESPACE + "hasMimeType"); 248 public static final Property HAS_ORIGINAL_NAME = 249 createProperty(EBUCORE_NAMESPACE + "filename"); 250 251 public static final Set<Property> contentProperties = of(HAS_CONTENT_LOCATION, HAS_CONTENT_LOCATION_VALUE, 252 HAS_SIZE); 253 254 255 // VERSIONING 256 public static final Property HAS_VERSION = 257 createProperty(REPOSITORY_NAMESPACE + "hasVersion"); 258 public static final Property HAS_VERSION_LABEL = 259 createProperty(REPOSITORY_NAMESPACE + "hasVersionLabel"); 260 261 public static final Set<Property> versioningProperties = of(HAS_VERSION, 262 HAS_VERSION_LABEL); 263 264 // RDF EXTRACTION 265 public static final Property COULD_NOT_STORE_PROPERTY = 266 createProperty(REPOSITORY_NAMESPACE + "couldNotStoreProperty"); 267 public static final Property INBOUND_REFERENCES = createProperty(REPOSITORY_NAMESPACE + "InboundReferences"); 268 public static final Property EMBED_CONTAINS = createProperty(REPOSITORY_NAMESPACE + "EmbedResources"); 269 public static final Property SERVER_MANAGED = createProperty(REPOSITORY_NAMESPACE + "ServerManaged"); 270 271 // IMPORTANT JCR PROPERTIES 272 public static final Property HAS_PRIMARY_IDENTIFIER = 273 createProperty(REPOSITORY_NAMESPACE + "uuid"); 274 public static final Property HAS_PRIMARY_TYPE = 275 createProperty(REPOSITORY_NAMESPACE + "primaryType"); 276 public static final Property HAS_NODE_TYPE = 277 createProperty(REPOSITORY_NAMESPACE + "hasNodeType"); 278 public static final Property HAS_MIXIN_TYPE = 279 createProperty(REPOSITORY_NAMESPACE + "mixinTypes"); 280 public static final Property CREATED_DATE = 281 createProperty(REPOSITORY_NAMESPACE + "created"); 282 public static final Property CREATED_BY = 283 createProperty(REPOSITORY_NAMESPACE + "createdBy"); 284 public static final Property LAST_MODIFIED_DATE = 285 createProperty(REPOSITORY_NAMESPACE + "lastModified"); 286 public static final Property LAST_MODIFIED_BY = 287 createProperty(REPOSITORY_NAMESPACE + "lastModifiedBy"); 288 289 public static final Set<Property> jcrProperties = of( 290 HAS_PRIMARY_IDENTIFIER, HAS_PRIMARY_TYPE, HAS_NODE_TYPE, 291 HAS_MIXIN_TYPE, CREATED_DATE, CREATED_BY, LAST_MODIFIED_DATE, 292 LAST_MODIFIED_BY); 293 294 public static final Property RDFS_LABEL = 295 createProperty("http://www.w3.org/2000/01/rdf-schema#label"); 296 public static final Property DC_TITLE = 297 createProperty("http://purl.org/dc/elements/1.1/title"); 298 public static final Property DCTERMS_TITLE = 299 createProperty("http://purl.org/dc/terms/title"); 300 public static final Property SKOS_PREFLABEL = 301 createProperty("http://www.w3.org/2004/02/skos/core#prefLabel"); 302 303 public static final Set<Property> managedProperties; 304 305 static { 306 final ImmutableSet.Builder<Property> b = ImmutableSet.builder(); 307 b.addAll(membershipProperties).addAll(fixityProperties).addAll(ldpProperties).addAll( 308 repositoryProperties).addAll(namespaceProperties).addAll( 309 otherServiceProperties).addAll(structProperties).addAll(contentProperties).addAll( 310 versioningProperties).addAll(jcrProperties); 311 managedProperties = b.build(); 312 } 313 314 private static Predicate<Property> hasJcrNamespace = 315 p -> !p.isAnon() && p.getNameSpace().equals(JCR_NAMESPACE); 316 317 private static Predicate<Property> hasFedoraNamespace = 318 p -> !p.isAnon() && p.getNameSpace().startsWith(REPOSITORY_NAMESPACE); 319 320 /** 321 * Detects whether an RDF property is managed by the repository. 322 */ 323 @SuppressWarnings("unchecked") 324 public static final Predicate<Property> isManagedPredicate = 325 hasJcrNamespace.or(hasFedoraNamespace).or(p -> managedProperties.contains(p)); 326 327 /** 328 * Detects whether an RDF predicate URI is managed by the repository. 329 **/ 330 public static Predicate<String> isManagedPredicateURI = 331 p -> isManagedPredicate.test(createProperty(p)); 332 333 private RdfLexicon() { 334 335 } 336}