List of usage examples for com.google.common.collect ImmutableBiMap containsValue
boolean containsValue(Object value);
From source file:org.fcrepo.kernel.impl.rdf.converters.PropertyConverter.java
/** * Get the JCR property name for an RDF predicate * * @param namespaceRegistry the namespace registry * @param predicate the predicate to map to a property name * @param namespaceMapping the namespace mapping * @return JCR property name for an RDF predicate * @throws RepositoryException if repository exception occurred *//*from w ww. ja v a 2s . c o m*/ public 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.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); final ImmutableBiMap<String, String> nsMap = ImmutableBiMap.copyOf(namespaceMapping); if (nsMap.containsValue(namespace)) { LOGGER.debug("Discovered namespace: {} in namespace map: {}.", namespace, nsMap); prefix = nsMap.inverse().get(namespace); namespaceRegistry.registerNamespace(prefix, namespace); } else { prefix = namespaceRegistry.registerNamespace(namespace); } } final String propertyName = prefix + ":" + rdfLocalname; LOGGER.debug("Took RDF predicate {} and translated it to JCR property {}", namespace, propertyName); return propertyName; }
From source file:org.fcrepo.kernel.modeshape.rdf.converters.PropertyConverter.java
/** * Get the JCR property name for an RDF predicate * * @param namespaceRegistry the namespace registry * @param predicate the predicate to map to a property name * @param namespaceMapping the namespace mapping * @return JCR property name for an RDF predicate * @throws RepositoryException if repository exception occurred *//*from ww w .j av a 2s.c o m*/ public 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); final ImmutableBiMap<String, String> nsMap = ImmutableBiMap.copyOf(namespaceMapping); if (nsMap.containsValue(namespace)) { LOGGER.debug("Discovered namespace: {} in namespace map: {}.", namespace, nsMap); prefix = nsMap.inverse().get(namespace); namespaceRegistry.registerNamespace(prefix, namespace); } else { prefix = namespaceRegistry.registerNamespace(namespace); } } final String propertyName = prefix + ":" + rdfLocalname; LOGGER.debug("Took RDF predicate {} and translated it to JCR property {}", namespace, propertyName); return propertyName; }
From source file:org.fcrepo.kernel.rdf.JcrRdfTools.java
/** * Get the JCR property name for an RDF predicate * * @param namespaceRegistry/*from w ww . j a v a 2 s . c o m*/ * @param rdfNamespace * @param rdfLocalname * @param namespaceMapping * @return * @throws RepositoryException */ private String getJcrNameForRdfNode(final NamespaceRegistry namespaceRegistry, final String rdfNamespace, final String rdfLocalname, final Map<String, String> namespaceMapping) throws RepositoryException { final String prefix; final String namespace = getJcrNamespaceForRDFNamespace(rdfNamespace); assert (namespaceRegistry != null); 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); final ImmutableBiMap<String, String> nsMap = ImmutableBiMap.copyOf(namespaceMapping); if (nsMap.containsValue(namespace)) { LOGGER.debug("Discovered namespace: {} in namespace map: {}.", namespace, nsMap); prefix = nsMap.inverse().get(namespace); namespaceRegistry.registerNamespace(prefix, namespace); } else { prefix = namespaceRegistry.registerNamespace(namespace); } } final String propertyName = prefix + ":" + rdfLocalname; LOGGER.debug("Took RDF predicate {} and translated it to JCR property {}", namespace, propertyName); return propertyName; }