private static String getPropertyNameFromPredicate ( final NamespaceRegistry namespaceRegistry , final Resource predicate , final Map < String , String > namespaceMapping ) throws RepositoryException { // reject if update request contains any fcr namespaces if ( namespaceMapping != null && namespaceMapping . containsKey ( "fcr" ) ) { throw new FedoraInvalidNamespaceException ( "Invalid fcr namespace properties " + predicate + "." ) ; } final String rdfNamespace = predicate . getNameSpace ( ) ; // log warning if the user-supplied namespace doesn't match value from predicate.getNameSpace(), // e.g., if the Jena method returns "http://" for "http://myurl.org" (no terminating character). if ( namespaceMapping != null && namespaceMapping . size ( ) > 0 && ! namespaceMapping . containsValue ( rdfNamespace ) ) { LOGGER . warn ( "The namespace of predicate: {} was possibly misinterpreted as: {}." , predicate , rdfNamespace ) ; } final String rdfLocalname = predicate . getLocalName ( ) ; final String prefix ; assert ( namespaceRegistry != null ) ; final String namespace = getJcrNamespaceForRDFNamespace ( rdfNamespace ) ; if ( namespaceRegistry . isRegisteredUri ( namespace ) ) { LOGGER . debug ( "Discovered namespace: {} in namespace registry." , namespace ) ; prefix = namespaceRegistry . getPrefix ( namespace ) ; } else { LOGGER . debug ( "Didn't discover namespace: {} in namespace registry." , namespace ) ; if ( namespaceMapping != null && namespaceMapping . containsValue ( namespace ) ) { LOGGER . debug ( "Discovered namespace: {} in namespace map: {}." , namespace , namespaceMapping ) ; prefix = namespaceMapping . entrySet ( ) . stream ( ) . filter ( t -> t . getValue ( ) . equals ( namespace ) ) . map ( Map . Entry :: getKey ) . findFirst ( ) . orElse ( null ) ; namespaceRegistry . registerNamespace ( prefix , namespace ) ; } else { prefix = namespaceRegistry . registerNamespace ( namespace ) ; LOGGER . debug ( "Registered prefix: {} for namespace: {}." , prefix , namespace ) ; } } final String propertyName = prefix + ":" + rdfLocalname ; LOGGER . debug ( "Took RDF predicate {} and translated it to JCR property {}" , namespace , propertyName ) ; return propertyName ; }
Get the JCR property name for an RDF predicate