public class MaximoConnector extends Object
MaximoConnector
is a Connector between Oslc Client and Maximo Server.
It provides the authentication setting, connect, basic requests and disconnect for Server.
This object can be created by MaximoConnector
with Options
.
The following code shows how to initial MaximoConnector
using MaximoConnector
and Options
Constructor
MaximoConnector mc = new MaximoConnector(new Options().user(userName)
.password(password).mt(true).lean(false).auth(authMethod)
.host(hostAddress).port(portNum));
The following examples demonstrate how to build a new MaximoConnector
Options op = new Options();
MaximoConnector mc = new MaximoConnector();
mc.options(op);
MaximoConnector mc = new MaximoConnector(Options);
The following examples demonstrate how to set authentication, method, cookie for session to MaximoConnector
mc.setAuth(authMethod);
mc.setMethod(httpConnection,method);
mc.setCookieForSession(httpConnection);
The following examples show how to connect, get, create, update, merge, delete and disconnect to Maximo Server by MaximoConnector
.
The properties can be empty
mc.connect();
JsonObject jo = mc.get(uri);
byte[] docBytes = mc.getAttachmentData(uri);
byte[] docBytes = mc.attachedDoc(uri);
JsonObject jp = mc.getAttachmentMeta(uri);
JsonObject jo = mc.create(uri, jsonObject, properties);
JsonObject jo = mc.createAttachment(uri, data, name, decription, meta);
JsonObject jo = mc.update(uri, jsonObject, properties);
JsonObject jo = mc.merge(uri, jsonObject, properties);
mc.delete(uri);
mc.deleteResource(uri);
mc.deleteAttachment(uri);
mc.disconnect();
The following examples show how to get ResourceSet
or Resource
or Attachment
by MaximoConnector
ResourceSet rs = mc.resourceSet(osName);
ResourceSet rs = mc.resourceSet(url);
Resource re = mc.resource(uri);
Attachment att = mc.attachment(uri);
Modifier and Type | Field and Description |
---|---|
static String |
HTTP_METHOD_BULK |
static String |
HTTP_METHOD_DELETE |
static String |
HTTP_METHOD_GET |
static String |
HTTP_METHOD_MERGE |
static String |
HTTP_METHOD_MERGESYNC |
static String |
HTTP_METHOD_PATCH |
static String |
HTTP_METHOD_POST |
static String |
HTTP_METHOD_SYNC |
String |
httpMethod |
static Logger |
logger |
Constructor and Description |
---|
MaximoConnector() |
MaximoConnector(Options options) |
Modifier and Type | Method and Description |
---|---|
Attachment |
attachment(String uri,
String... properties) |
javax.json.JsonObject |
attachmentDocMeta(String uri) |
javax.json.JsonArray |
bulk(String uri,
javax.json.JsonArray ja) |
javax.json.JsonArray |
bulk(String uri,
javax.json.JsonArray ja,
Map<String,Object> headers) |
void |
connect()
Connect to Maximo Server
|
void |
connect(Proxy proxy)
Connect to Maximo Server with Proxy
|
javax.json.JsonObject |
create(String uri,
javax.json.JsonObject jo,
Map<String,Object> headers,
String... properties) |
javax.json.JsonObject |
create(String uri,
javax.json.JsonObject jo,
String... properties)
Create new Resource
|
javax.json.JsonObject |
createAttachment(String uri,
byte[] data,
String name,
String description,
String meta)
Create new attachment
|
javax.json.JsonObject |
createAttachment(String uri,
byte[] data,
String name,
String description,
String meta,
Map<String,Object> headers) |
MaximoConnector |
debug(boolean isDebug) |
void |
delete(String uri)
Delete the resource/attachment
|
void |
delete(String uri,
Map<String,Object> headers) |
void |
deleteAttachment(String uri) |
void |
deleteResource(String uri) |
void |
disconnect()
Disconnect with Maximo Server
|
static String |
encode(String userName,
String password) |
javax.json.JsonObject |
get(String uri) |
javax.json.JsonObject |
get(String uri,
Map<String,Object> headers) |
byte[] |
getAttachmentData(String uri)
Load DocumentData
|
byte[] |
getAttachmentData(String uri,
Map<String,Object> headers) |
String |
getCurrentURI() |
int |
getLastResponseCode()
Get the last response code
|
Options |
getOptions() |
javax.json.JsonArray |
groupBy(String uri)
Fetch Group By data
|
javax.json.JsonArray |
groupBy(String uri,
Map<String,Object> headers) |
boolean |
isDebug() |
boolean |
isLean() |
boolean |
isValid() |
javax.json.JsonObject |
merge(String uri,
javax.json.JsonObject jo,
Map<String,Object> headers,
String... properties) |
javax.json.JsonObject |
merge(String uri,
javax.json.JsonObject jo,
String... properties) |
javax.json.JsonObject |
mergeSync(String uri,
javax.json.JsonObject jo,
Map<String,Object> headers,
String... properties) |
javax.json.JsonObject |
mergeSync(String uri,
javax.json.JsonObject jo,
String... properties) |
MaximoConnector |
options(Options op) |
Resource |
resource(String uri,
String... properties) |
ResourceSet |
resourceSet() |
ResourceSet |
resourceSet(String osName) |
ResourceSet |
resourceSet(URL url) |
protected HttpURLConnection |
setAuth(String uri) |
protected HttpURLConnection |
setAuth(String uri,
Proxy proxy) |
protected HttpURLConnection |
setHeaders(HttpURLConnection con,
Map<String,Object> headers) |
protected HttpURLConnection |
setMethod(HttpURLConnection con,
String method,
String... properties) |
javax.json.JsonObject |
sync(String uri,
javax.json.JsonObject jo,
Map<String,Object> headers,
String... properties) |
javax.json.JsonObject |
sync(String uri,
javax.json.JsonObject jo,
String... properties) |
javax.json.JsonObject |
update(String uri,
javax.json.JsonObject jo,
Map<String,Object> headers,
String... properties) |
javax.json.JsonObject |
update(String uri,
javax.json.JsonObject jo,
String... properties)
Update the Resource
|
public static final Logger logger
public static final String HTTP_METHOD_POST
public static final String HTTP_METHOD_GET
public static final String HTTP_METHOD_PATCH
public static final String HTTP_METHOD_MERGE
public static final String HTTP_METHOD_DELETE
public static final String HTTP_METHOD_BULK
public static final String HTTP_METHOD_SYNC
public static final String HTTP_METHOD_MERGESYNC
public String httpMethod
public MaximoConnector()
public MaximoConnector(Options options)
public ResourceSet resourceSet()
public ResourceSet resourceSet(String osName)
public ResourceSet resourceSet(URL url) throws IOException, OslcException
IOException
OslcException
public Resource resource(String uri, String... properties) throws IOException, OslcException
IOException
OslcException
public Attachment attachment(String uri, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject attachmentDocMeta(String uri) throws IOException, OslcException
IOException
OslcException
public MaximoConnector options(Options op)
public String getCurrentURI()
public Options getOptions()
public MaximoConnector debug(boolean isDebug)
public boolean isDebug()
public boolean isValid()
public boolean isLean()
public void connect() throws IOException, OslcException
IOException
OslcException
public void connect(Proxy proxy) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject get(String uri) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject get(String uri, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonArray groupBy(String uri) throws IOException, OslcException
uri
- IOException
OslcException
public javax.json.JsonArray groupBy(String uri, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
public byte[] getAttachmentData(String uri) throws IOException, OslcException
IOException
OslcException
public byte[] getAttachmentData(String uri, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject create(String uri, javax.json.JsonObject jo, String... properties) throws IOException, OslcException
jo
- IOException
OslcException
public javax.json.JsonObject create(String uri, javax.json.JsonObject jo, Map<String,Object> headers, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject createAttachment(String uri, byte[] data, String name, String description, String meta) throws IOException, OslcException
data
- name
- description
- meta
- IOException
OslcException
public javax.json.JsonObject createAttachment(String uri, byte[] data, String name, String description, String meta, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject update(String uri, javax.json.JsonObject jo, String... properties) throws IOException, OslcException
jo
- IOException
OslcException
public javax.json.JsonObject update(String uri, javax.json.JsonObject jo, Map<String,Object> headers, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject merge(String uri, javax.json.JsonObject jo, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject merge(String uri, javax.json.JsonObject jo, Map<String,Object> headers, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonArray bulk(String uri, javax.json.JsonArray ja) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonArray bulk(String uri, javax.json.JsonArray ja, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject sync(String uri, javax.json.JsonObject jo, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject sync(String uri, javax.json.JsonObject jo, Map<String,Object> headers, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject mergeSync(String uri, javax.json.JsonObject jo, String... properties) throws IOException, OslcException
IOException
OslcException
public javax.json.JsonObject mergeSync(String uri, javax.json.JsonObject jo, Map<String,Object> headers, String... properties) throws IOException, OslcException
IOException
OslcException
public void delete(String uri) throws IOException, OslcException
IOException
OslcException
public void delete(String uri, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
public void deleteResource(String uri) throws IOException, OslcException
IOException
OslcException
public void deleteAttachment(String uri) throws IOException, OslcException
IOException
OslcException
public static String encode(String userName, String password) throws UnsupportedEncodingException
UnsupportedEncodingException
protected HttpURLConnection setAuth(String uri) throws IOException
IOException
protected HttpURLConnection setAuth(String uri, Proxy proxy) throws IOException
IOException
protected HttpURLConnection setHeaders(HttpURLConnection con, Map<String,Object> headers) throws IOException, OslcException
IOException
OslcException
protected HttpURLConnection setMethod(HttpURLConnection con, String method, String... properties) throws IOException, OslcException
IOException
OslcException
public int getLastResponseCode()
public void disconnect() throws IOException
IOException
Copyright © 2018. All rights reserved.