Package com.franz.agraph.http
Class AGHTTPClient
java.lang.Object
com.franz.agraph.http.AGHTTPClient
- All Implemented Interfaces:
AutoCloseable
Class responsible for handling HTTP connections.
Uses an unlimited pool of connections to allow safe, concurrent access.
Also contains methods for accessing AG services that operate above the repository level - such as managing repositories.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Number of times an HTTP GET request is automatically retried, not counting the initial (failed) attempt, in case of errors caused by a connection timeout. -
Constructor Summary
ConstructorDescriptionAGHTTPClient
(String serverURL) AGHTTPClient
(String serverURL, org.apache.http.conn.HttpClientConnectionManager manager) AGHTTPClient
(String serverURL, org.apache.http.conn.HttpClientConnectionManager manager, org.apache.http.config.SocketConfig socketConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
delete
(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, AGResponseHandler handler) void
deleteCatalog
(String catalogURL) void
deleteRepository
(String repositoryURL) String[]
generateURIs
(String repositoryURL, String namespace, int amount) void
get
(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, AGResponseHandler handler) String[]
getBlankNodes
(String repositoryURL, int amount) org.apache.http.client.HttpClient
getListOfStrings
(String url) String[]
getStringArray
(String url) String[]
Retrieve the username and password previously set by setUsernameAndPassword.openSession
(String spec, boolean autocommit) void
post
(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, org.apache.http.HttpEntity requestEntity, AGResponseHandler handler) void
put
(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, org.apache.http.HttpEntity requestEntity, AGResponseHandler handler) void
putCatalog
(String catalogURL) void
putRepository
(String repositoryURL) void
setMasqueradeAsUser
(String user) Sets the AG user for X-Masquerade-As-User requests.void
setUsernameAndPassword
(String username, String password) Set the username and password for authentication with the remote server.toString()
-
Field Details
-
PROP_HTTP_NUM_RETRIES
Number of times an HTTP GET request is automatically retried, not counting the initial (failed) attempt, in case of errors caused by a connection timeout. Disabling this by setting it to 0 will expose "Connection reset" and "HTTP 408 Client timeout" errors. A value of 1 should enough to hide these supposedly harmless errors if the network is otherwise stable.- See Also:
-
-
Constructor Details
-
AGHTTPClient
public AGHTTPClient(String serverURL, org.apache.http.conn.HttpClientConnectionManager manager, org.apache.http.config.SocketConfig socketConfig) -
AGHTTPClient
-
AGHTTPClient
-
-
Method Details
-
toString
-
getServerURL
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient() -
post
public void post(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, org.apache.http.HttpEntity requestEntity, AGResponseHandler handler) throws AGHttpException - Throws:
AGHttpException
-
get
public void get(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, AGResponseHandler handler) throws AGHttpException - Throws:
AGHttpException
-
delete
public void delete(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, AGResponseHandler handler) throws AGHttpException - Throws:
AGHttpException
-
put
public void put(String url, org.apache.http.Header[] headers, org.apache.http.NameValuePair[] params, org.apache.http.HttpEntity requestEntity, AGResponseHandler handler) throws AGHttpException - Throws:
AGHttpException
-
setUsernameAndPassword
Set the username and password for authentication with the remote server.- Parameters:
username
- the usernamepassword
- the password
-
getUsernameAndPassword
Retrieve the username and password previously set by setUsernameAndPassword.- Returns:
- An array of two Strings. The first element is the username (or null) and the second element is the password (or null).
-
setMasqueradeAsUser
Sets the AG user for X-Masquerade-As-User requests.For AG superusers only. This allows AG superusers to run requests as another user in a dedicated session.
- Parameters:
user
- the user for X-Masquerade-As-User requests
-
putCatalog
- Throws:
AGHttpException
-
deleteCatalog
- Throws:
AGHttpException
-
putRepository
- Throws:
AGHttpException
-
deleteRepository
- Throws:
AGHttpException
-
getTupleQueryResult
- Throws:
AGHttpException
-
getBlankNodes
- Throws:
AGHttpException
-
getString
- Throws:
AGHttpException
-
getStringArray
- Throws:
AGHttpException
-
getListOfStrings
- Throws:
AGHttpException
-
openSession
- Throws:
AGHttpException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
generateURIs
public String[] generateURIs(String repositoryURL, String namespace, int amount) throws AGHttpException - Throws:
AGHttpException
-