/** * Connect to a SPARQL end point (GET or POST query only). * * @param opts * The connection options. * * @return The connection. */ private JettyResponseListener doConnect(final ConnectOptions opts) throws Exception { return mgr.doConnect(opts); }
@Override public JettyResponseListener doConnect(ConnectOptions opts) throws Exception { // Store connection options data.opts = opts; return super.doConnect(opts); } };
private static JettyResponseListener getStatus(final RemoteRepositoryManager repo) throws Exception { final ConnectOptions opts = new ConnectOptions(serviceURL + "/status"); opts.method = "GET"; return repo.doConnect(opts); }
private static JettyResponseListener getNamespaceProperties( final RemoteRepositoryManager repo, final String namespace) throws Exception { final ConnectOptions opts = new ConnectOptions(serviceURL + "/namespace/" + namespace + "/properties"); opts.method = "GET"; return repo.doConnect(opts); }
/** * <code>LIST-TX</code>: Return the set of active transactions. */ public Iterator<IRemoteTxState0> listTx() { final ConnectOptions opts = new ConnectOptions(mgr.getBaseServiceURL() + "/tx"); opts.method = "GET"; JettyResponseListener response = null; try { RemoteRepository.checkResponseCode(response = mgr.doConnect(opts)); // Note: iterator return supports streaming results (not implemented). return multiTxResponse(response).iterator(); } catch (Exception e) { throw new RuntimeException(e); } finally { if (response != null) response.abort(); } }
private String doGET(final String url) throws Exception { JettyResponseListener response = null; try { final ConnectOptions opts = new ConnectOptions(url); opts.method = "GET"; response = m_repo.doConnect(opts); RemoteRepository.checkResponseCode(response); return response.getResponseBody(); } finally { if (response != null) response.abort(); } }
response = doConnect(opts); return response.getResponseBody();
checkResponseCode(response = doConnect(opts));
checkResponseCode(response = doConnect(opts)); } finally { if (response != null)
/** * Destroy a KB instance. * * @param namespace * The namespace of the KB instance. * @param uuid * The {@link UUID} to be assigned to the request.a * * @throws Exception */ public void deleteRepository(final String namespace, final UUID uuid) throws Exception { final ConnectOptions opts = newConnectOptions(getRepositoryBaseURLForNamespace(namespace), uuid, null/* txId */); opts.method = "DELETE"; JettyResponseListener response = null; try { checkResponseCode(response = doConnect(opts)); } finally { if (response != null) response.abort(); } }
/** * Checks whether the mapgraph runtime is available. * @return */ public boolean mapgraphRuntimeAvailable() throws Exception { final String repositoryUrl = getSparqlEndpointUrlForNamespaceOrDefault(null /* default namespace */); /** * First reset the runtime */ final ConnectOptions opts = newConnectOptions(repositoryUrl, UUID.randomUUID(), null/* tx */); JettyResponseListener response = null; // Setup the request entity. { opts.addRequestParam(MAPGRAPH, MAPGRAPH_CHECK_RUNTIME_AVAILABLE); opts.method = "POST"; } try { response = doConnect(opts); return response.getStatus()==200 /* HTTP OK */; } finally { if (response != null) response.abort(); } }
try { checkResponseCode(response = doConnect(opts)); } finally {
/** * List the currently running queries on the server * */ public Collection<RunningQuery> showQueries() throws Exception { final ConnectOptions opts = newUpdateConnectOptions(baseServiceURL, null, null/* txId */); opts.addRequestParam(SHOW_QUERIES); opts.setAcceptHeader(IMimeTypes.MIME_APPLICATION_JSON); JettyResponseListener response = null; try { // Issue request, check response status code. checkResponseCode(response = doConnect(opts)); final String contentType = response.getContentType(); if (!IMimeTypes.MIME_APPLICATION_JSON.equals(contentType)) throw new RuntimeException("Expected MIME_TYPE " + IMimeTypes.MIME_APPLICATION_JSON + " but received : " + contentType + "."); final InputStream is = response.getInputStream(); final List<RunningQuery> runningQueries = JsonHelper.readRunningQueryList(is); return runningQueries; } finally { /* * Ensure that the http response entity is consumed so that the http * connection will be released in a timely fashion. */ if (response != null) response.abort(); } }
/** * Resets the mapgraph runtime for the compute mode. * * @param computeMode the desired compute mode */ public void resetMapgraphRuntime(final ComputeMode computeMode) throws Exception { assertMapgraphRuntimeAvailable(); if (computeMode==null) { throw new IllegalArgumentException("Compute mode must not be null"); } final String repositoryUrl = getSparqlEndpointUrlForNamespaceOrDefault(null /* default namespace */); final ConnectOptions opts = newConnectOptions(repositoryUrl, UUID.randomUUID(), null/* tx */); JettyResponseListener response = null; // Setup the request entity. { opts.addRequestParam(MAPGRAPH, MAPGRAPH_RESET); opts.addRequestParam(COMPUTE_MODE, computeMode.toString()); opts.method = "POST"; } try { checkResponseCode(response = doConnect(opts)); } finally { if (response != null) response.abort(); } }
checkResponseCode(response = doConnect(opts));
checkResponseCode(response = doConnect(opts));
checkResponseCode(response = doConnect(opts));
private String doGET(final String url) throws Exception { JettyResponseListener response = null; try { final ConnectOptions opts = new ConnectOptions(url); opts.method = "GET"; response = m_repo.doConnect(opts); RemoteRepository.checkResponseCode(response); return response.getResponseBody(); } finally { if (response != null) response.abort(); } }
.checkResponseCode(response = mgr.doConnect(opts));
try { checkResponseCode(response = doConnect(opts));