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; 017 018import static com.google.common.base.Predicates.in; 019import static com.google.common.base.Predicates.or; 020import static com.google.common.collect.ImmutableSet.of; 021import static com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty; 022import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource; 023 024import java.util.Set; 025 026import com.google.common.base.Predicate; 027import com.google.common.collect.ImmutableSet; 028import com.hp.hpl.jena.rdf.model.Property; 029import com.hp.hpl.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 "fcrepo", used for JCR properties exposed 040 * publicly. 041 * Was "info:fedora/fedora-system:def/internal#". 042 **/ 043 public static final String REPOSITORY_NAMESPACE = 044 "http://fedora.info/definitions/v4/repository#"; 045 046 /** 047 * The core JCR namespace. 048 */ 049 public static final String JCR_NAMESPACE = "http://www.jcp.org/jcr/1.0"; 050 051 public static final String MODE_NAMESPACE = "http://www.modeshape.org/1.0"; 052 053 public static final String MIX_NAMESPACE = "http://www.jcp.org/jcr/mix/1.0"; 054 055 public static final String JCR_NT_NAMESPACE = "http://www.jcp.org/jcr/nt/1.0"; 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 in(managedNamespaces); 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_STATE = 128 createProperty(REPOSITORY_NAMESPACE + "status"); 129 130 public static final Property HAS_FIXITY_CHECK_COUNT = 131 createProperty(REPOSITORY_NAMESPACE + "numFixityChecks"); 132 public static final Property HAS_FIXITY_ERROR_COUNT = 133 createProperty(REPOSITORY_NAMESPACE + "numFixityErrors"); 134 public static final Property HAS_FIXITY_REPAIRED_COUNT = 135 createProperty(REPOSITORY_NAMESPACE + "numFixityRepaired"); 136 137 public static final Set<Property> fixityProperties = of( 138 HAS_FIXITY_RESULT, HAS_MESSAGE_DIGEST, HAS_SIZE, HAS_FIXITY_STATE, 139 HAS_FIXITY_CHECK_COUNT, HAS_FIXITY_ERROR_COUNT, HAS_FIXITY_REPAIRED_COUNT); 140 141 public static final Property WRITABLE = 142 createProperty(REPOSITORY_NAMESPACE + "writable"); 143 144 // Linked Data Platform 145 public static final Property PAGE = 146 createProperty(LDP_NAMESPACE + "Page"); 147 public static final Property PAGE_OF = 148 createProperty(LDP_NAMESPACE + "pageOf"); 149 public static final Property FIRST_PAGE = 150 createProperty(LDP_NAMESPACE + "firstPage"); 151 public static final Property NEXT_PAGE = 152 createProperty(LDP_NAMESPACE + "nextPage"); 153 public static final Resource CONTAINER = 154 createResource(LDP_NAMESPACE + "Container"); 155 public static final Resource BASIC_CONTAINER = 156 createResource(LDP_NAMESPACE + "BasicContainer"); 157 public static final Resource DIRECT_CONTAINER = 158 createResource(LDP_NAMESPACE + "DirectContainer"); 159 public static final Resource INDIRECT_CONTAINER = 160 createResource(LDP_NAMESPACE + "IndirectContainer"); 161 public static final Property MEMBERSHIP_RESOURCE = 162 createProperty(LDP_NAMESPACE + "membershipResource"); 163 public static final Property HAS_MEMBER_RELATION = 164 createProperty(LDP_NAMESPACE + "hasMemberRelation"); 165 public static final Property CONTAINS = 166 createProperty(LDP_NAMESPACE + "contains"); 167 public static final Property LDP_MEMBER = 168 createProperty(LDP_NAMESPACE + "member"); 169 public static final Property RDF_SOURCE = 170 createProperty(LDP_NAMESPACE + "RDFSource"); 171 public static final Property NON_RDF_SOURCE = 172 createProperty(LDP_NAMESPACE + "NonRDFSource"); 173 public static final Property CONSTRAINED_BY = 174 createProperty(LDP_NAMESPACE + "constrainedBy"); 175 public static final Property MEMBER_SUBJECT = 176 createProperty(LDP_NAMESPACE + "MemberSubject"); 177 178 public static final Set<Property> ldpProperties = of(PAGE, PAGE_OF, 179 FIRST_PAGE, NEXT_PAGE, CONTAINS, LDP_MEMBER); 180 public static final Set<Resource> ldpResources = of(CONTAINER, 181 DIRECT_CONTAINER); 182 183 // REPOSITORY INFORMATION 184 public static final Property HAS_OBJECT_COUNT = 185 createProperty(REPOSITORY_NAMESPACE + "objectCount"); 186 public static final Property HAS_OBJECT_SIZE = 187 createProperty(REPOSITORY_NAMESPACE + "objectSize"); 188 public static final Property HAS_TRANSACTION_SERVICE = 189 createProperty(REPOSITORY_NAMESPACE + "hasTransactionProvider"); 190 public static final Property HAS_ACCESS_ROLES_SERVICE = 191 createProperty(REPOSITORY_NAMESPACE + "hasAccessRoles"); 192 193 public static final Set<Property> repositoryProperties = of( 194 HAS_OBJECT_COUNT, HAS_OBJECT_SIZE, HAS_TRANSACTION_SERVICE); 195 196 // NAMESPACES 197 public static final Property HAS_NAMESPACE_PREFIX = 198 createProperty("http://purl.org/vocab/vann/preferredNamespacePrefix"); 199 public static final Property HAS_NAMESPACE_URI = 200 createProperty("http://purl.org/vocab/vann/preferredNamespaceUri"); 201 public static final Property VOAF_VOCABULARY = createProperty("http://purl.org/vocommons/voaf#Vocabulary"); 202 203 public static final Set<Property> namespaceProperties = of( 204 HAS_NAMESPACE_PREFIX, HAS_NAMESPACE_URI, VOAF_VOCABULARY); 205 206 // OTHER SERVICES 207 public static final Property HAS_SERIALIZATION = 208 createProperty(REPOSITORY_NAMESPACE + "exportsAs"); 209 public static final Property HAS_VERSION_HISTORY = 210 createProperty(REPOSITORY_NAMESPACE + "hasVersions"); 211 public static final Property HAS_FIXITY_SERVICE = 212 createProperty(REPOSITORY_NAMESPACE + "hasFixityService"); 213 public static final Property HAS_FEED = 214 createProperty( 215 "http://www.whatwg.org/specs/web-apps/current-work/#", 216 "feed0"); 217 public static final Property HAS_SUBSCRIPTION_SERVICE = 218 createProperty("http://microformats.org/wiki/rel-subscription"); 219 public static final Property HAS_SPARQL_ENDPOINT = 220 createProperty(SPARQL_SD_NAMESPACE + "endpoint"); 221 222 public static final Set<Property> otherServiceProperties = of( 223 HAS_SERIALIZATION, HAS_VERSION_HISTORY, HAS_FIXITY_SERVICE, 224 HAS_FEED, HAS_SUBSCRIPTION_SERVICE); 225 226 227 // BINARY DESCRIPTIONS 228 public static final Property DESCRIBES = 229 createProperty("http://www.iana.org/assignments/relation/describes"); 230 public static final Property DESCRIBED_BY = 231 createProperty("http://www.iana.org/assignments/relation/describedby"); 232 233 public static final Set<Property> structProperties = of(DESCRIBES, DESCRIBED_BY); 234 235 // CONTENT 236 public static final Resource CONTENT_LOCATION_TYPE = 237 createResource(PREMIS_NAMESPACE + "ContentLocation"); 238 public static final Property HAS_CONTENT_LOCATION = 239 createProperty(PREMIS_NAMESPACE + "hasContentLocation"); 240 public static final Property HAS_CONTENT_LOCATION_VALUE = 241 createProperty(PREMIS_NAMESPACE + "hasContentLocationValue"); 242 public static final Property HAS_MIME_TYPE = 243 createProperty(REPOSITORY_NAMESPACE + "mimeType"); 244 public static final Property HAS_ORIGINAL_NAME = 245 createProperty(PREMIS_NAMESPACE + "hasOriginalName"); 246 247 public static final Set<Property> contentProperties = of(HAS_CONTENT_LOCATION, HAS_CONTENT_LOCATION_VALUE, 248 HAS_MIME_TYPE, HAS_ORIGINAL_NAME, HAS_SIZE); 249 250 251 // VERSIONING 252 public static final Property HAS_VERSION = 253 createProperty(REPOSITORY_NAMESPACE + "hasVersion"); 254 public static final Property HAS_VERSION_LABEL = 255 createProperty(REPOSITORY_NAMESPACE + "hasVersionLabel"); 256 257 public static final Set<Property> versioningProperties = of(HAS_VERSION, 258 HAS_VERSION_LABEL); 259 260 // RDF EXTRACTION 261 public static final Property COULD_NOT_STORE_PROPERTY = 262 createProperty(REPOSITORY_NAMESPACE + "couldNotStoreProperty"); 263 public static final Property INBOUND_REFERENCES = createProperty(REPOSITORY_NAMESPACE + "InboundReferences"); 264 public static final Property EMBED_CONTAINS = createProperty(REPOSITORY_NAMESPACE + "EmbedResources"); 265 public static final Property SERVER_MANAGED = createProperty(REPOSITORY_NAMESPACE + "ServerManaged"); 266 267 // IMPORTANT JCR PROPERTIES 268 public static final Property HAS_PRIMARY_IDENTIFIER = 269 createProperty(REPOSITORY_NAMESPACE + "uuid"); 270 public static final Property HAS_PRIMARY_TYPE = 271 createProperty(REPOSITORY_NAMESPACE + "primaryType"); 272 public static final Property HAS_NODE_TYPE = 273 createProperty(REPOSITORY_NAMESPACE + "hasNodeType"); 274 public static final Property HAS_MIXIN_TYPE = 275 createProperty(REPOSITORY_NAMESPACE + "mixinTypes"); 276 public static final Property CREATED_DATE = 277 createProperty(REPOSITORY_NAMESPACE + "created"); 278 public static final Property CREATED_BY = 279 createProperty(REPOSITORY_NAMESPACE + "createdBy"); 280 public static final Property LAST_MODIFIED_DATE = 281 createProperty(REPOSITORY_NAMESPACE + "lastModified"); 282 public static final Property LAST_MODIFIED_BY = 283 createProperty(REPOSITORY_NAMESPACE + "lastModifiedBy"); 284 285 public static final Set<Property> jcrProperties = of( 286 HAS_PRIMARY_IDENTIFIER, HAS_PRIMARY_TYPE, HAS_NODE_TYPE, 287 HAS_MIXIN_TYPE, CREATED_DATE, CREATED_BY, LAST_MODIFIED_DATE, 288 LAST_MODIFIED_BY); 289 290 public static final Property RDFS_LABEL = 291 createProperty("http://www.w3.org/2000/01/rdf-schema#label"); 292 public static final Property DC_TITLE = 293 createProperty("http://purl.org/dc/elements/1.1/title"); 294 public static final Property DCTERMS_TITLE = 295 createProperty("http://purl.org/dc/terms/title"); 296 public static final Property SKOS_PREFLABEL = 297 createProperty("http://www.w3.org/2004/02/skos/core#prefLabel"); 298 299 public static final Set<Property> managedProperties; 300 301 static { 302 final ImmutableSet.Builder<Property> b = ImmutableSet.builder(); 303 b.addAll(membershipProperties).addAll(fixityProperties).addAll(ldpProperties).addAll( 304 repositoryProperties).addAll(namespaceProperties).addAll( 305 otherServiceProperties).addAll(structProperties).addAll(contentProperties).addAll( 306 versioningProperties).addAll(jcrProperties); 307 managedProperties = b.build(); 308 } 309 310 private static Predicate<Property> hasJcrNamespace = 311 new Predicate<Property>() { 312 313 @Override 314 public boolean apply(final Property p) { 315 return !p.isAnon() && p.getNameSpace().equals(JCR_NAMESPACE); 316 317 } 318 }; 319 320 private static Predicate<Property> hasFedoraNamespace = 321 new Predicate<Property>() { 322 323 @Override 324 public boolean apply(final Property p) { 325 return !p.isAnon() 326 && p.getNameSpace().startsWith(REPOSITORY_NAMESPACE); 327 328 } 329 }; 330 331 /** 332 * Detects whether an RDF property is managed by the repository. 333 */ 334 @SuppressWarnings("unchecked") 335 public static final Predicate<Property> isManagedPredicate = or( 336 in(managedProperties), hasJcrNamespace, hasFedoraNamespace); 337 338 /** 339 * Detects whether an RDF predicate URI is managed by the repository. 340 **/ 341 public static Predicate<String> isManagedPredicateURI = 342 new Predicate<String>() { 343 @Override 344 public boolean apply(final String uri) { 345 return isManagedPredicate.apply( createProperty(uri) ); 346 } 347 }; 348 349 private RdfLexicon() { 350 351 } 352}