Package io.vantiq.client
Class Vantiq
java.lang.Object
io.vantiq.client.Vantiq
Vantiq SDK for Java/Android API
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a Vantiq SDK instance against a specific Vantiq server using the latest version of the API.Constructs a Vantiq SDK instance against a specific Vantiq server URL using a specific REST API version.Constructs a Vantiq SDK instance against a specific Vantiq server URL using a specific REST API version.Constructs a Vantiq SDK instance against a specific Vantiq server using the latest version of the API. -
Method Summary
Modifier and TypeMethodDescriptionvoidAcknowledge the receipt of a reliable messageauthenticate(String username, String password) Authenticates this Vantiq instance using the given credentials synchronously.voidauthenticate(String username, String password, ResponseHandler responseHandler) Authenticates this Vantiq instance using the given credentials asynchronously.batch(com.google.gson.JsonArray requests) Performs a synchronous batch query, specified by a JSON array.voidbatch(com.google.gson.JsonArray requests, ResponseHandler responseHandler) Performs a batch query, specified by a JSON array.voidCloses the websocket to VantiqThis method is similar toselect(java.lang.String, java.util.List<java.lang.String>, java.lang.Object, io.vantiq.client.SortSpec, io.vantiq.client.ResponseHandler)except returns only the count of matching records.voidcount(String resource, Object where, ResponseHandler responseHandler) This method is similar toselect(java.lang.String, java.util.List<java.lang.String>, java.lang.Object, io.vantiq.client.SortSpec, io.vantiq.client.ResponseHandler)except returns only the count of matching records.Do a DELETE using the specified path synchronously.voiddel(String path, ResponseHandler responseHandler) Do a DELETE using the specified path asynchronously.Deletes the matching records specified by a where constraint synchronously.voiddelete(String resource, Object where, ResponseHandler responseHandler) Deletes the matching records specified by a where constraint asynchronously.Deletes the record for the given resource and specified id synchronously.voiddeleteOne(String resource, String id, ResponseHandler responseHandler) Deletes the record for the given resource and specified id asynchronously.Perform the download of a document synchronously from the specified path.voiddownload(String path, ResponseHandler responseHandler) Perform the download of a document asynchronously from the specified path.Executes a specific procedure synchronously.voidexecute(String procedure, Object params, ResponseHandler responseHandler) Executes a specific procedure asynchronously.Returns the current access token.longGets the connect timeout for the connectionReturns the current idToken.getNamespaceUsers(String namespace) Returns a JsonArray containing objects which map between "username" and "preferredUsername"voidgetNamespaceUsers(String namespace, ResponseHandler responseHandler) Returns a JsonArray containing objects which map between "username" and "preferredUsername"longReturns the read timeout for the connectionReturns the server that was assigned when this user was successfully logged in with the Vantiq server instance (or null if not currently logged in).Returns the current access token.Returns the username that was assigned when this user was successfully logged in with the Vantiq username instance (or null if not currently logged in).longReturns the write timeout for the connectionInserts a new record of the specified resource type synchronously.voidinsert(String resource, Object object, ResponseHandler responseHandler) Inserts a new record of the specified resource type asynchronously.booleanReturns if this Vantiq instance has been successfully authenticated with the Vantiq server instance.booleanReturns if pinging should be enabled on the websockets for subscriptions to ensure the connection is kept open.Do a POST (insert) of the supplied data using the specified path synchronously.voidpost(String path, Object object, ResponseHandler responseHandler) Do a POST (insert) of the supplied data using the specified path type asynchronously.Publishes to a specific topic or source synchronously.voidpublish(String resource, String id, Object payload, ResponseHandler responseHandler) Publishes to a specific topic or source asynchronously.Do a PUT (update) of the supplied data using the specified path synchronously.voidput(String path, Object object, ResponseHandler responseHandler) Do a PUT (update) of the supplied data using the specified path type asynchronously.Performs a query operation on the specified source synchronously.voidquery(String source, Object params, ResponseHandler responseHandler) Performs a query operation on the specified source asynchronously.Do a GET against the specified raw path type synchronously.voidrawGet(String fullPath, Map<String, String> queryParams, Map<String, String> extraHeaders, ResponseHandler responseHandler) Do a GET against the specified raw path type asynchronously.Refreshes the given accessToken synchronously.voidrefresh(String accessToken, ResponseHandler responseHandler) Refreshes the given accessToken asynchronously.Revokes the given accessToken synchronously.voidrevoke(String accessToken, ResponseHandler responseHandler) Revokes the given accessToken asynchronously.Returns the record for the given resource and specified id.Returns the record for the given resource and specified id.select(String resource, List<String> propSpecs, Object where, SortSpec sortSpec, long limit, Map<String, String> options) Returns the record for the given resource and specified id.voidselect(String resource, List<String> propSpecs, Object where, SortSpec sortSpec, ResponseHandler responseHandler) Performs a query to search for records that match the given constraints asynchronously.Returns the record for the given resource and specified id synchronously.voidselectOne(String resource, String id, ResponseHandler responseHandler) Returns the record for the given resource and specified id asynchronously.voidsetAccessToken(String accessToken) Sets the access token for use in future requests to the Vantiq server.voidsetConnectTimeout(long timeout) Sets the connect timeout for the connectionvoidsetEnablePings(boolean enablePings) Sets if pinging should be enabled on the websockets for subscriptions to ensure the connection is kept open.voidsetReadTimeout(long timeout) Sets the read timeout for the connectionvoidSets the server; this is used if the app has remembered an old server and wants to re-use it.voidsetTargetNamespace(String targetNamespace) Sets the target namespace for use in future requests to the Vantiq server.voidsetUsername(String username) Sets the username; this is used if the app has remembered an old username and wants to re-use it.voidsetWriteTimeout(long timeout) Sets the write timeout for the connectionvoidsubscribe(String resource, String id, Vantiq.TypeOperation operation, SubscriptionCallback callback) voidsubscribe(String resource, String id, Vantiq.TypeOperation operation, SubscriptionCallback callback, Map<String, Object> parameters) Subscribes to a specific topic, source, or type event.voidUnsubscribes to all current subscriptions by closing the WebSocket to the Vantiq server.Updates an existing record of the specified resource type synchronously.voidupdate(String resource, String id, Object object, ResponseHandler responseHandler) Updates an existing record of the specified resource type asynchronously.Performs an upload of the given file synchronously.voidupload(File file, String contentType, String documentPath, ResponseHandler responseHandler) Performs an upload of the given file asynchronously.Performs an upload of the given file synchronously.voidupload(File file, String contentType, String filePath, String resourcePath, ResponseHandler responseHandler) Performs an upload of the given file asynchronously.Upserts a record of the specified resource type synchronously.voidupsert(String resource, Object object, ResponseHandler responseHandler) Upserts a record of the specified resource type asynchronously.
-
Constructor Details
-
Vantiq
Constructs a Vantiq SDK instance against a specific Vantiq server URL using a specific REST API version.- Parameters:
server- The URL of the Vantiq serverapiVersion- The REST API version to use
-
Vantiq
Constructs a Vantiq SDK instance against a specific Vantiq server URL using a specific REST API version.The proxyAuthenticator is only required when the proxy requires authentication other than Basic user and password. The internal authenticator will provide those as required, based on the Java standard properties.
- Parameters:
server- The URL of the Vantiq serverapiVersion- The REST API version to useproxyAuthenticator- okhttp3.Authenticator Used to authenticate with a network proxy.
-
Vantiq
Constructs a Vantiq SDK instance against a specific Vantiq server using the latest version of the API.- Parameters:
server- The URL of the Vantiq server
-
Vantiq
Constructs a Vantiq SDK instance against a specific Vantiq server using the latest version of the API.The proxyAuthenticator is only required when the proxy requires authentication other than Basic user and password. The internal authenticator will provide those as required, based on the Java standard properties.
- Parameters:
server- The URL of the Vantiq serverproxyAuthenticator- okhttp3.Authenticator Used to authenticate with a network proxy.
-
-
Method Details
-
isAuthenticated
public boolean isAuthenticated()Returns if this Vantiq instance has been successfully authenticated with the Vantiq server instance.- Returns:
- true if authenticated successfully
-
getServer
Returns the server that was assigned when this user was successfully logged in with the Vantiq server instance (or null if not currently logged in).- Returns:
- server string or null
-
setServer
Sets the server; this is used if the app has remembered an old server and wants to re-use it. (It could also be used to "un-authenticate", setting the server to null.- Parameters:
server- The server to be used to avoid calling "authenticate"
-
getUsername
Returns the username that was assigned when this user was successfully logged in with the Vantiq username instance (or null if not currently logged in).- Returns:
- username string or null
-
setUsername
Sets the username; this is used if the app has remembered an old username and wants to re-use it. (It could also be used to "un-authenticate", setting the username to null.- Parameters:
username- The username to be used to avoid calling "authenticate"
-
isEnablePings
public boolean isEnablePings()Returns if pinging should be enabled on the websockets for subscriptions to ensure the connection is kept open. By default, pinging is enabled.- Returns:
- Indicates this client should send periodic pings to the server
-
setEnablePings
public void setEnablePings(boolean enablePings) Sets if pinging should be enabled on the websockets for subscriptions to ensure the connection is kept open. By default, pinging is enabled.- Parameters:
enablePings- True indicates this client should send periodic pings to the server
-
authenticate
Authenticates this Vantiq instance using the given credentials asynchronously. The response handler "onSuccess" will return true if the authentication was successful.- Parameters:
username- The username for the Vantiq serverpassword- The password for the Vantiq serverresponseHandler- The response handler that is called upon completion.
-
authenticate
Authenticates this Vantiq instance using the given credentials synchronously.- Parameters:
username- The username for the Vantiq serverpassword- The password for the Vantiq server- Returns:
- The response from the Vantiq server
-
revoke
Revokes the given accessToken asynchronously. The response handler "onSuccess" will return true if the authentication was successful.- Parameters:
accessToken- The accessToken to be revokedresponseHandler- The response handler that is called upon completion.
-
revoke
Revokes the given accessToken synchronously.- Parameters:
accessToken- The accessToken to be revoked- Returns:
- The response from the Vantiq server
-
refresh
Refreshes the given accessToken asynchronously. The response handler "onSuccess" will return true if the refresh was successful.- Parameters:
accessToken- The accessToken to be refreshedresponseHandler- The response handler that is called upon completion.
-
refresh
Refreshes the given accessToken synchronously.- Parameters:
accessToken- The accessToken to be refreshed- Returns:
- The response from the Vantiq server
-
buildPath
-
select
public void select(String resource, List<String> propSpecs, Object where, SortSpec sortSpec, ResponseHandler responseHandler) Performs a query to search for records that match the given constraints asynchronously. The response body will be a List of JsonObject objects.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.propSpecs- The optional list of properties to return in each record. A null or empty list returns all properties.where- The optional where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.sortSpec- The optional sort specification to order the returned records.responseHandler- The response handler that is called upon completion.
-
batch
Performs a batch query, specified by a JSON array. This is currently for internal use only and is not documented.- Parameters:
requests- A JsonArray of "request objects", each looking something like this: { "method": "GET", "headers": { "Content-type": "application/json" }, "uri": /types?where={"name":"ArsType"} } Note that anything past the "?" in the "uri" (which means the "where" clause in this case) must be URL encoded.responseHandler- The response handler that is called upon completion.
-
batch
Performs a synchronous batch query, specified by a JSON array. This is currently for internal use only and is not documented.- Parameters:
requests- A JsonArray of "request objects", each looking something like this: { "method": "GET", "headers": { "Content-type": "application/json" }, "uri": /types?where={"name":"ArsType"} } Note that anything past the "?" in the "uri" (which means the "where" clause in this case) must be URL encoded.- Returns:
- The response from the Vantiq server
-
select
public VantiqResponse select(String resource, List<String> propSpecs, Object where, SortSpec sortSpec) Returns the record for the given resource and specified id. The response is a single JsonObject. Performs a query to search for records that match the given constraints synchronously. The response body will be a List of JsonObject objects.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.propSpecs- The optional list of properties to return in each record. A null or empty list returns all properties.where- The optional where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.sortSpec- The optional sort specification to order the returned records.- Returns:
- The response from the Vantiq server
-
select
public VantiqResponse select(String resource, List<String> propSpecs, Object where, SortSpec sortSpec, long limit) Returns the record for the given resource and specified id. The response is a single JsonObject. Performs a query to search for records that match the given constraints synchronously. The response body will be a List of JsonObject objects.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.propSpecs- The optional list of properties to return in each record. A null or empty list returns all properties.where- The optional where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.sortSpec- The optional sort specification to order the returned records.limit- A limit to the number of records returned (limit less then or equals to 0 means no limit)- Returns:
- The response from the Vantiq server
-
select
public VantiqResponse select(String resource, List<String> propSpecs, Object where, SortSpec sortSpec, long limit, Map<String, String> options) Returns the record for the given resource and specified id. The response is a single JsonObject. Performs a query to search for records that match the given constraints synchronously. The response body will be a List of JsonObject objects.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.propSpecs- The optional list of properties to return in each record. A null or empty list returns all properties.where- The optional where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.sortSpec- The optional sort specification to order the returned records.limit- A limit to the number of records returned (limit less then or equals to 0 means no limit)options- Any additional options to be added to the queryParams- Returns:
- The response from the Vantiq server
-
selectOne
Returns the record for the given resource and specified id asynchronously. The response is a single JsonObject.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.id- The key used to lookup the record. The underlying "_id" can be used.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
selectOne
Returns the record for the given resource and specified id synchronously. The response is a single JsonObject.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.id- The key used to lookup the record. The underlying "_id" can be used.- Returns:
- The response from the Vantiq server
-
count
This method is similar toselect(java.lang.String, java.util.List<java.lang.String>, java.lang.Object, io.vantiq.client.SortSpec, io.vantiq.client.ResponseHandler)except returns only the count of matching records. The response is an Integer.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.where- The optional where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
count
This method is similar toselect(java.lang.String, java.util.List<java.lang.String>, java.lang.Object, io.vantiq.client.SortSpec, io.vantiq.client.ResponseHandler)except returns only the count of matching records. The response is an Integer.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.where- The optional where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.- Returns:
- The response from the Vantiq server
-
rawGet
public void rawGet(String fullPath, Map<String, String> queryParams, Map<String, String> extraHeaders, ResponseHandler responseHandler) Do a GET against the specified raw path type asynchronously.- Parameters:
fullPath- The full path to usequeryParams- optional query parametersextraHeaders- optional headersresponseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
rawGet
public VantiqResponse rawGet(String fullPath, Map<String, String> queryParams, Map<String, String> extraHeaders) Do a GET against the specified raw path type synchronously.- Parameters:
fullPath- The full path to usequeryParams- optional query parametersextraHeaders- optional headers- Returns:
- The response from the Vantiq server
-
post
Do a POST (insert) of the supplied data using the specified path type asynchronously.- Parameters:
path- The path to useobject- The object to insert. This will be converted to JSON using Gson.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
post
Do a POST (insert) of the supplied data using the specified path synchronously.- Parameters:
path- The path to useobject- The object to insert. This will be converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
put
Do a PUT (update) of the supplied data using the specified path type asynchronously.- Parameters:
path- The path to useobject- The object to insert. This will be converted to JSON using Gson.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
put
Do a PUT (update) of the supplied data using the specified path synchronously.- Parameters:
path- The path to useobject- The object to insert. This will be converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
del
Do a DELETE using the specified path asynchronously. The response is a boolean indicating the success of the removal.- Parameters:
path- The path to useresponseHandler- The response handler that is called upon completion.
-
del
Do a DELETE using the specified path synchronously. The response is a boolean indicating the success of the removal.- Parameters:
path- The path to use- Returns:
- The response from the Vantiq server
-
insert
Inserts a new record of the specified resource type asynchronously. The response is a JsonObject of the record just inserted.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.object- The object to insert. This will be converted to JSON using Gson.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
insert
Inserts a new record of the specified resource type synchronously. The response is a JsonObject of the record just inserted.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.object- The object to insert. This will be converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
update
Updates an existing record of the specified resource type asynchronously. The response is a JsonObject of the record just updated.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.id- The key used to lookup the record. The underlying "_id" can be used.object- The object to insert. This will be converted to JSON using Gson.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
update
Updates an existing record of the specified resource type synchronously. The response is a JsonObject of the record just updated.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.id- The key used to lookup the record. The underlying "_id" can be used.object- The object to insert. This will be converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
upsert
Upserts a record of the specified resource type asynchronously. If the record does not already exist, then a new record is inserted. If the record does exist, then the record is updated. The existence of the record is defined by the natural key defined on the type. The response is a JsonObject that is the record just upserted.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.object- The object to insert. This will be converted to JSON using Gson.responseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
upsert
Upserts a record of the specified resource type synchronously. If the record does not already exist, then a new record is inserted. If the record does exist, then the record is updated. The existence of the record is defined by the natural key defined on the type. The response is a JsonObject that is the record just upserted.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.object- The object to insert. This will be converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
delete
Deletes the matching records specified by a where constraint asynchronously. The response is a boolean indicating the success of the removal.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.where- The required where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.responseHandler- The response handler that is called upon completion.
-
delete
Deletes the matching records specified by a where constraint synchronously. The response is a boolean indicating the success of the removal.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.where- The required where constraint that filters the records returned. The where is structured following the structure outline in the API Documentation.- Returns:
- The response from the Vantiq server
-
deleteOne
Deletes the record for the given resource and specified id asynchronously. The response is a boolean indicating the success of the removal.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.id- The key used to lookup the record. The underlying "_id" can be used.responseHandler- The response handler that is called upon completion.
-
deleteOne
Deletes the record for the given resource and specified id synchronously. The response is a boolean indicating the success of the removal.- Parameters:
resource- The resource to query. This can be aSystemResourcesvalue or a user-defined type name.id- The key used to lookup the record. The underlying "_id" can be used.- Returns:
- The response from the Vantiq server
-
publish
Publishes to a specific topic or source asynchronously. A publish operation is fire-and-forget. The response is a boolean indicating the success of the publish. For sources, the parameters required are source specific and are the same as those required when performing aPUBLISH ... TO SOURCE ... USINGparams. Please refer to the specific source definition documentation in the Vantiq API Documentation.- Parameters:
resource- The resource to query. This must be the value of eitherVantiq.SystemResources.TOPICSorVantiq.SystemResources.SOURCES.id- The topic or source to publish.payload- For a topic, this is the message to publish. For a source, this is the parameters that defines the publish. This will be converted to JSON using Gson.responseHandler- The response handler that is called upon completion.
-
publish
Publishes to a specific topic or source synchronously. A publish operation is fire-and-forget. The response is a boolean indicating the success of the publish. For sources, the parameters required are source specific and are the same as those required when performing aPUBLISH ... TO SOURCE ... USINGparams. Please refer to the specific source definition documentation in the Vantiq API Documentation.- Parameters:
resource- The resource to query. This must be the value of eitherVantiq.SystemResources.TOPICSorVantiq.SystemResources.SOURCES.id- The topic or source to publish.payload- For a topic, this is the message to publish. For a source, this is the parameters that defines the publish. This will be converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
execute
Executes a specific procedure asynchronously. An execute operation is request-response. The response is a JsonObject with the result of the procedure.- Parameters:
procedure- The name of the procedure to execute.params- The arguments for the procedure. The parameters can be passed as positional parameters using a JsonArray or as named parameters using a JsonObject. The params is converted to JSON using Gson.responseHandler- The response handler that is called upon completion.
-
execute
Executes a specific procedure synchronously. An execute operation is request-response. The response is a JsonObject with the result of the procedure.- Parameters:
procedure- The name of the procedure to execute.params- The arguments for the procedure. The parameters can be passed as positional parameters using a JsonArray or as named parameters using a JsonObject. The params is converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
query
Performs a query operation on the specified source asynchronously. A query operation is request-response. The response is a JsonObject with the result of the source query operation. The parameters required are source specific and are the same as those required when performing aSELECT ... FROM SOURCE ... WITHparams. Please refer to the specific source definition documentation in the Vantiq API Documentation.- Parameters:
source- The name of the source to query.params- The arguments for the query operation. The params is converted to JSON using Gson.responseHandler- The response handler that is called upon completion.
-
query
Performs a query operation on the specified source synchronously. A query operation is request-response. The response is a JsonObject with the result of the source query operation. The parameters required are source specific and are the same as those required when performing aSELECT ... FROM SOURCE ... WITHparams. Please refer to the specific source definition documentation in the Vantiq API Documentation.- Parameters:
source- The name of the source to query.params- The arguments for the query operation. The params is converted to JSON using Gson.- Returns:
- The response from the Vantiq server
-
getNamespaceUsers
Returns a JsonArray containing objects which map between "username" and "preferredUsername"- Parameters:
namespace- The namespaceresponseHandler- The response handler that is called upon completion. If null, then the call is performed synchronously and the response is provided as the returned value.
-
getNamespaceUsers
Returns a JsonArray containing objects which map between "username" and "preferredUsername"- Parameters:
namespace- The namespace- Returns:
- The response from the Vantiq server
-
upload
public void upload(File file, String contentType, String documentPath, ResponseHandler responseHandler) Performs an upload of the given file asynchronously. The response provides info on the document uploaded.- Parameters:
file- The file to uploadcontentType- The MIME type for the filedocumentPath- The path of the document to store in VantiqresponseHandler- The response handler that is called upon completion.
-
upload
Performs an upload of the given file synchronously. The response provides info on the document uploaded.- Parameters:
file- The file to uploadcontentType- The MIME type for the filedocumentPath- The path of the file in the Vantiq system- Returns:
- The response from the Vantiq server
-
upload
public void upload(File file, String contentType, String filePath, String resourcePath, ResponseHandler responseHandler) Performs an upload of the given file asynchronously. The response provides info on the document uploaded.- Parameters:
file- The file to uploadcontentType- The MIME type for the filefilePath- The path of the file to store in VantiqresourcePath- The path of the VANTIQ Resource to upload toresponseHandler- The response handler that is called upon completion.
-
upload
Performs an upload of the given file synchronously. The response provides info on the document uploaded.- Parameters:
file- The file to uploadcontentType- The MIME type for the filefilePath- The path of the file in the Vantiq systemresourcePath- The path of the VANTIQ Resource to upload to- Returns:
- The response from the Vantiq server
-
download
Perform the download of a document synchronously from the specified path. This method is expected to be used to download documents uploaded using theupload(File, String, String)orupload(File, String, String, ResponseHandler)methods. The path used here is that returned in the "content" property returned in the response to the "upload" methods. The response body is an InputStream that provides the document content.- Parameters:
path- The path to the document to download- Returns:
- The response from the Vantiq server
-
download
Perform the download of a document asynchronously from the specified path. This method is expected to be used to download documents uploaded using theupload(File, String, String)orupload(File, String, String, ResponseHandler)methods. The path used here is that returned in the "content" property returned in the response to the "upload" methods. The response body is an InputStream that provides the document content.- Parameters:
path- The path to the document to downloadresponseHandler- The response handler that is called when the response starts downloading.
-
subscribe
public void subscribe(String resource, String id, Vantiq.TypeOperation operation, SubscriptionCallback callback, Map<String, Object> parameters) Subscribes to a specific topic, source, or type event. This method uses a WebSocket with the Vantiq server to listen for the specified events. For sources, this will subscribe to message arrival events. The name of the source is required (e.g. "MySource"). For topics, this will subscribe to any messages published on that topic. The name of the topic is required (e.g. "/foo/bar"). For types, this will subscribe to the specified type event. The name of the type and the operation (i.e. "insert", "update", or "delete") is required.- Parameters:
resource- The resource whose events to subscribe. This must be the value ofVantiq.SystemResources.TOPICS,Vantiq.SystemResources.SERVICES, orVantiq.SystemResources.SOURCESVantiq.SystemResources.TYPES.id- The id of the resourceoperation- Only for "types", the specific operation event to subscribe to.callback- The callback used when the event is receivedparameters- parameters
-
subscribe
public void subscribe(String resource, String id, Vantiq.TypeOperation operation, SubscriptionCallback callback) -
ack
Acknowledge the receipt of a reliable message- Parameters:
subscriptionId- subscription idrequestId- request idmsg- Message- Throws:
IOException- If request fails
-
unsubscribeAll
public void unsubscribeAll()Unsubscribes to all current subscriptions by closing the WebSocket to the Vantiq server. -
closeWebsocket
public void closeWebsocket()Closes the websocket to Vantiq -
setAccessToken
Sets the access token for use in future requests to the Vantiq server. This can be a normal or long-lived token.- Parameters:
accessToken- The access token to set
-
getAccessToken
Returns the current access token. If not authenticated, this is null.- Returns:
- The access token used for requests or null if not an authenticated session.
-
setTargetNamespace
Sets the target namespace for use in future requests to the Vantiq server.- Parameters:
targetNamespace- The target namespace to set for all requests
-
getTargetNamespace
Returns the current access token. If not authenticated, this is null.- Returns:
- The target namespace to be used on all requests
-
getIdToken
Returns the current idToken. If not authenticated, this is null.- Returns:
- The idToken or null if not an authenticated session (or an old pre-OAuth Vantiq server)
-
setReadTimeout
public void setReadTimeout(long timeout) Sets the read timeout for the connection- Parameters:
timeout- The timeout duration in milliseconds
-
getReadTimeout
public long getReadTimeout()Returns the read timeout for the connection- Returns:
- The timeout duration in milliseconds
-
setWriteTimeout
public void setWriteTimeout(long timeout) Sets the write timeout for the connection- Parameters:
timeout- The timeout duration in milliseconds
-
getWriteTimeout
public long getWriteTimeout()Returns the write timeout for the connection- Returns:
- The timeout duration in milliseconds
-
setConnectTimeout
public void setConnectTimeout(long timeout) Sets the connect timeout for the connection- Parameters:
timeout- The timeout duration in milliseconds
-
getConnectTimeout
public long getConnectTimeout()Gets the connect timeout for the connection- Returns:
- The timeout duration in milliseconds
-