public class IGCRestClient extends Object
registerPOJO(Class)| Modifier and Type | Field and Description |
|---|---|
static String |
EP_ASSET |
static String |
EP_BUNDLE_ASSETS |
static String |
EP_BUNDLES |
static String |
EP_LOGOUT |
static String |
EP_SEARCH |
static String |
EP_TYPES |
| Constructor and Description |
|---|
IGCRestClient() |
IGCRestClient(String baseURL,
String authorization)
Default constructor used by the IGCRestClient.
|
| Modifier and Type | Method and Description |
|---|---|
File |
createOpenIgcBundleFile(File directory)
Generates an OpenIGC bundle zip file from the provided directory path, and returns the temporary file it creates.
|
boolean |
deleteOpenIgcAsset(String assetXML)
Delete using the provided OpenIGC asset XML: deleting the asset(s) specified within it.
|
void |
disconnect()
Disconnect from IGC REST API and invalidate the session.
|
static String |
encodeBasicAuth(String username,
String password)
Utility function to easily encode a username and password to send through as authorization info.
|
com.fasterxml.jackson.databind.node.ArrayNode |
getAllPages(com.fasterxml.jackson.databind.node.ArrayNode items,
com.fasterxml.jackson.databind.JsonNode paging)
Retrieve all pages of results from a set of paging details and items
... |
List<Reference> |
getAllPages(List<Reference> items,
Paging paging)
Retrieve all pages of results from a set of Paging details and items
... |
Reference |
getAssetById(String rid)
Retrieve all information about an asset from IGC.
|
Reference |
getAssetRefById(String rid)
Retrieve only the minimal unique properties of an asset from IGC.
|
String |
getBaseURL()
Retrieve the base URL of this IGC REST API connection.
|
int |
getDefaultPageSize()
Retrieve the default page size for this IGC REST API connection.
|
IGCVersionEnum |
getIgcVersion()
Retrieve the version of the IGC environment (static member VERSION_115 or VERSION_117).
|
com.fasterxml.jackson.databind.JsonNode |
getJsonAssetById(String rid)
Retrieve all information about an asset from IGC.
|
com.fasterxml.jackson.databind.JsonNode |
getNextPage(com.fasterxml.jackson.databind.JsonNode paging)
Retrieve the next page of results from a set of paging details
... |
ReferenceList |
getNextPage(Paging paging)
Retrieve the next page of results from a set of Paging details
... |
List<String> |
getOpenIgcBundles()
Retrieve the set of OpenIGC bundles already defined in the environment.
|
Class |
getPOJOForType(String typeName)
Returns the POJO that is registered to serde the provided IGC asset type.
|
com.fasterxml.jackson.databind.node.ArrayNode |
getTypes()
Retrieves the list of metadata types supported by IGC.
|
String |
getValueAsJSON(Reference asset)
Attempt to convert the provided IGC object into JSON, based on the registered POJOs.
|
boolean |
isSuccessfullyInitialised()
Indicates whether the client was successfully initialised (true) or not (false).
|
Boolean |
isWorkflowEnabled()
Returns true iff the workflow is enabled in the environment against which the REST connection is defined.
|
com.fasterxml.jackson.databind.JsonNode |
makeRequest(String endpoint,
org.springframework.http.HttpMethod method,
org.springframework.http.MediaType contentType,
String payload)
General utility for making requests.
|
protected Reference |
readJSONIntoPOJO(com.fasterxml.jackson.databind.JsonNode jsonNode)
Attempt to convert a JSON structure into a Java object, based on the registered POJOs.
|
Reference |
readJSONIntoPOJO(String json)
Attempt to convert the JSON string into a Java object, based on the registered POJOs.
|
ReferenceList |
readJSONIntoReferenceList(String json)
Attempt to convert the JSON string into a ReferenceList.
|
void |
registerPOJO(Class clazz)
Register a POJO as an object to handle serde of JSON objects.
Note that this MUST be done BEFORE any object mappingRemoved (translation) is done! In general, you'll want your POJO to extend at least the model.Reference object in this package; more likely the model.MainObject (for your own OpenIGC object), or if you are adding custom attributes to one of the native asset types, consider directly extending that asset from model.generated.* To allow this dynamic registration to work, also ensure you have a 'public static String getIgcTypeId()' in your class set to the type that the IGC REST API uses to refer to the asset (eg. |
ReferenceList |
search(IGCSearch igcSearch)
Retrieve all assets that match the provided search criteria from IGC.
|
com.fasterxml.jackson.databind.JsonNode |
searchJson(IGCSearch igcSearch)
Retrieve all assets that match the provided search criteria from IGC.
|
com.fasterxml.jackson.databind.JsonNode |
searchJson(com.fasterxml.jackson.databind.JsonNode query)
Retrieve all assets that match the provided search criteria from IGC.
|
void |
setDefaultPageSize(int pageSize)
Set the default page size for this IGC REST API connection.
|
boolean |
update(IGCUpdate igcUpdate)
Apply the update described by the provided update object.
|
com.fasterxml.jackson.databind.JsonNode |
updateJson(String rid,
com.fasterxml.jackson.databind.JsonNode value)
Update the asset specified by the provided RID with the value(s) provided.
|
boolean |
uploadFile(String endpoint,
org.springframework.http.HttpMethod method,
org.springframework.core.io.AbstractResource file)
General utility for uploading binary files.
|
com.fasterxml.jackson.databind.JsonNode |
upsertOpenIgcAsset(String assetXML)
Upload the provided OpenIGC asset XML: creating the asset(s) if they do not exist, updating if they do.
|
boolean |
upsertOpenIgcBundle(String name,
org.springframework.core.io.AbstractResource file)
Upload the specified bundle, creating it if it does not already exist or updating it if it does.
|
public static final String EP_TYPES
public static final String EP_ASSET
public static final String EP_SEARCH
public static final String EP_LOGOUT
public static final String EP_BUNDLES
public static final String EP_BUNDLE_ASSETS
public IGCRestClient()
public IGCRestClient(String baseURL, String authorization)
baseURL - the base URL of the domain tier of Information Serverauthorization - the Basic-encoded authorization string to use to login to Information Serverpublic boolean isSuccessfullyInitialised()
protected Reference readJSONIntoPOJO(com.fasterxml.jackson.databind.JsonNode jsonNode)
jsonNode - the JSON structure to convertpublic Reference readJSONIntoPOJO(String json)
json - the JSON string to convertpublic ReferenceList readJSONIntoReferenceList(String json)
json - the JSON string to convertpublic String getValueAsJSON(Reference asset)
asset - the IGC asset to convertpublic IGCVersionEnum getIgcVersion()
public String getBaseURL()
public int getDefaultPageSize()
public void setDefaultPageSize(int pageSize)
pageSize - the new default page size to usepublic static String encodeBasicAuth(String username, String password)
username - username to encodepassword - password to encodepublic boolean uploadFile(String endpoint, org.springframework.http.HttpMethod method, org.springframework.core.io.AbstractResource file)
endpoint - the URL against which to upload the filemethod - HttpMethod (POST, PUT, etc)file - the Spring FileSystemResource or ClassPathResource containing the file to be uploadedpublic com.fasterxml.jackson.databind.JsonNode makeRequest(String endpoint, org.springframework.http.HttpMethod method, org.springframework.http.MediaType contentType, String payload)
endpoint - the URL against which to make the requestmethod - HttpMethod (GET, POST, etc)contentType - the type of content to expect in the payload (if any)payload - if POSTing some content, the JSON structure providing what should be POSTedpublic com.fasterxml.jackson.databind.node.ArrayNode getTypes()
public com.fasterxml.jackson.databind.JsonNode getJsonAssetById(String rid)
rid - the Repository ID of the assetpublic Reference getAssetById(String rid)
rid - the Repository ID of the assetgetAssetRefById(String)public Reference getAssetRefById(String rid)
rid - the Repository ID of the assetpublic com.fasterxml.jackson.databind.JsonNode searchJson(com.fasterxml.jackson.databind.JsonNode query)
query - the JSON query by which to searchpublic com.fasterxml.jackson.databind.JsonNode searchJson(IGCSearch igcSearch)
igcSearch - the IGCSearch object defining criteria by which to searchpublic ReferenceList search(IGCSearch igcSearch)
igcSearch - search conditions and criteria to usepublic com.fasterxml.jackson.databind.JsonNode updateJson(String rid, com.fasterxml.jackson.databind.JsonNode value)
rid - the Repository ID of the asset to updatevalue - the JSON structure defining what value(s) of the asset to update (and mode)public boolean update(IGCUpdate igcUpdate)
igcUpdate - update criteria to usepublic boolean upsertOpenIgcBundle(String name, org.springframework.core.io.AbstractResource file)
name - the bundleId of the bundlefile - the Spring FileSystemResource or ClassPathResource containing the file to be uploadedpublic File createOpenIgcBundleFile(File directory)
directory - the directory under which the OpenIGC bundle is defined (ie. including an
'asset_type_descriptor.xml', an 'i18n' subdirectory and an 'icons' subdirectory)public List<String> getOpenIgcBundles()
List<String>public com.fasterxml.jackson.databind.JsonNode upsertOpenIgcAsset(String assetXML)
assetXML - the XML string defining the OpenIGC assetpublic boolean deleteOpenIgcAsset(String assetXML)
assetXML - the XML string defining the OpenIGC asset deletionpublic com.fasterxml.jackson.databind.JsonNode getNextPage(com.fasterxml.jackson.databind.JsonNode paging)
paging - the "paging" portion of the JSON response from which to retrieve the next pagepublic com.fasterxml.jackson.databind.node.ArrayNode getAllPages(com.fasterxml.jackson.databind.node.ArrayNode items,
com.fasterxml.jackson.databind.JsonNode paging)
items - the "items" array of the JSON response for which to retrieve all pagespaging - the "paging" portion of the JSON response for which to retrieve all pagespublic ReferenceList getNextPage(Paging paging)
paging - the "Paging" object from which to retrieve the next pagepublic List<Reference> getAllPages(List<Reference> items, Paging paging)
items - the List of items for which to retrieve all pagespaging - the Paging object for which to retrieve all pagesList<Reference> - an List containing all items from all pages of resultspublic void disconnect()
public void registerPOJO(Class clazz)
clazz - the Java Class (POJO) object to registergetPOJOForType(String)public Class getPOJOForType(String typeName)
typeName - name of the IGC assetregisterPOJO(Class)public Boolean isWorkflowEnabled()
Copyright © 2018–2019 ODPi. All rights reserved.