protected String getNamespaceInternal(String prefix) throws SailException { try { return repoConnection.getNamespace(prefix); } catch (RepositoryException e) { throw new SailException(e); } }
public String getNamespace(String prefix) { try { return con.getNamespace(prefix); } catch (RepositoryException e) { throw new ModelException(e); } }
@Test public void testGetNamespace() throws Exception { setupNamespaces(); assertThat(testCon.getNamespace(EXAMPLE), is(equalTo(EXAMPLE_NS))); assertThat(testCon.getNamespace(RDFS_PREFIX), is(equalTo(RDFS_NS))); assertThat(testCon.getNamespace(RDF_PREFIX), is(equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); assertThat(testCon.getNamespace("undefined"), is(nullValue())); }
private static String resolvePropLabel(RepositoryConnection con, String propLabel) throws RepositoryException { String uri = propLabel; // find out which kind of propLabel we got passed if(uri.startsWith("<") && uri.endsWith(">")) { // uri is a real uri enclosed in < > uri = uri.substring(1,uri.length()-1); } else if(!uri.contains("://") && uri.contains(":")) { // uri is a SeQRQL/SPARQL identifier with abbreviated namespace, we need to lookup the namespace... String[] components = uri.split(":"); if(components.length == 2) { String ns_prefix = components[0]; String ns_local = components[1]; String ns = con.getNamespace(ns_prefix); if(ns == null) { log.error("could not find namespace with the given prefix"); } else { uri = ns + ns_local; } } else { log.error("could not properly split property identifier #0, as it contained more than one ':'",uri); } } return uri; }
@Override public String getNamespaceInternal(String prefix) throws SailException { try { String namespace = null; for (RepositoryConnection member : members) { String ns = member.getNamespace(prefix); if (namespace == null) { namespace = ns; } else if (ns != null && !ns.equals(namespace)) { return null; } } return namespace; } catch (RepositoryException e) { throw new SailException(e); } }
@Override @Nullable protected Namespace doGetNamespace(final String prefix) { try { final String name = this.connection.getNamespace(prefix); return name == null ? null : new NamespaceImpl(prefix, name); } catch (final RepositoryException ex) { throw new ModelException(ex); } }
@Override public void endRDF() throws RDFHandlerException { for (Map.Entry<String, String> entry : namespaceMap.entrySet()) { String prefix = entry.getKey(); String name = entry.getValue(); try { if (con.getNamespace(prefix) == null) { con.setNamespace(prefix, name); } } catch (RepositoryException e) { throw new RDFHandlerException(e); } } namespaceMap.clear(); bNodesMap.clear(); }
/** * Check the connection's namespace, using the base context when needed * * @param conn * @throws RepositoryException */ private void checkConnectionNamespace(RepositoryConnection conn) throws RepositoryException { if(conn.getNamespace(DEFAULT_PREFIX) == null) { conn.setNamespace(DEFAULT_PREFIX, getBaseContext()); } }
@Override public String getNamespace(String prefix) { this.assertModel(); try { return this.connection.getNamespace(prefix); } catch(RepositoryException e) { throw new ModelRuntimeException(e); } }
@Override public String getNamespace(String prefix) { assertModel(); try { return this.connection.getNamespace(prefix); } catch(RepositoryException e) { throw new ModelRuntimeException(e); } }
public String removeNamespace(String prefix) { try { String ret = con.getNamespace(prefix); con.removeNamespace(prefix); return ret; } catch (RepositoryException e) { throw new ModelException(e); } }
public String getNamespace(String prefix) { this.assertModel(); try { return this.connection.getNamespace(prefix); } catch (RepositoryException e) { throw new ModelRuntimeException(e); } }
/** * Check the connection's namespace, using the base context when needed * * @param conn * @throws RepositoryException */ private void checkConnectionNamespace(RepositoryConnection conn) throws RepositoryException { if(conn.getNamespace(DEFAULT_PREFIX) == null) { conn.setNamespace(DEFAULT_PREFIX, getBaseContext()); } }
public String setNamespace(String prefix, String name) { try { String ret = con.getNamespace(prefix); con.setNamespace(prefix, name); return ret; } catch (RepositoryException e) { throw new ModelException(e); } }
public String getNamespace(String prefix) { assertModel(); try { return this.connection.getNamespace(prefix); } catch (RepositoryException e) { throw new ModelRuntimeException(e); } }
public void setNamespace(RepositoryConnection conn, String prefix, String name) { try { String namespace = conn.getNamespace(prefix); Command command = new OverrideNamespaceCommand(prefix, namespace, name); addCommand(command); } catch (RepositoryException e) { handleException(e); } }
public void removeNamespace(RepositoryConnection conn, String prefix) { try { String namespace = conn.getNamespace(prefix); Command command = new OverrideNamespaceCommand(prefix, namespace, null); addCommand(command); } catch (RepositoryException e) { handleException(e); } }
private ModelAndView getExportNamespaceResult(HttpServletRequest request, String prefix) throws ServerHTTPException, ClientHTTPException { try { String namespace = null; RepositoryConnection repositoryCon = RepositoryInterceptor.getRepositoryConnection(request); synchronized (repositoryCon) { namespace = repositoryCon.getNamespace(prefix); } if (namespace == null) { throw new ClientHTTPException(SC_NOT_FOUND, "Undefined prefix: " + prefix); } Map<String, Object> model = new HashMap<String, Object>(); model.put(SimpleResponseView.CONTENT_KEY, namespace); return new ModelAndView(SimpleResponseView.getInstance(), model); } catch (RepositoryException e) { throw new ServerHTTPException("Repository error: " + e.getMessage(), e); } }
@Override protected Namespace doSetNamespace(final String prefix, @Nullable final String name) { try { final String oldName = this.connection.getNamespace(prefix); final Namespace oldNamespace = oldName == null ? null : new NamespaceImpl(prefix, oldName); if (name == null) { this.connection.removeNamespace(prefix); } else { this.connection.setNamespace(prefix, name); } return oldNamespace; } catch (final RepositoryException ex) { throw new ModelException(ex); } }
@Test public void testGetNamespace() throws Exception { setupNamespaces(); assertThat(testCon.getNamespace(EXAMPLE), is(equalTo(EXAMPLE_NS))); assertThat(testCon.getNamespace(RDFS_PREFIX), is(equalTo(RDFS_NS))); assertThat(testCon.getNamespace(RDF_PREFIX), is(equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); assertThat(testCon.getNamespace("undefined"), is(nullValue())); }