Package org.imixs.melman
Class DocumentClient
- java.lang.Object
-
- org.imixs.melman.AbstractClient
-
- org.imixs.melman.DocumentClient
-
- Direct Known Subclasses:
WorkflowClient
public class DocumentClient extends AbstractClient
This ServiceClient is a WebService REST Client which encapsulate the communication with a REST web serice based on the Imixs Workflow REST API. The Implementation is based on the JAXB API 2.0.- Author:
- Ralph Soika
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PAGE_SIZEstatic StringDEFAULT_TYPEstatic StringITEM_ERROR_CODEstatic StringITEM_ERROR_MESSAGEprotected Stringitemsprotected intpageIndexprotected intpageSizeprotected StringsortByprotected booleansortReverseprotected Stringtype-
Fields inherited from class org.imixs.melman.AbstractClient
baseURI, requestFilterList, sslContext
-
-
Constructor Summary
Constructors Constructor Description DocumentClient(String base_uri)Initialize the client by a BASE_URL.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcountDocuments(String query)Counts a given lucene search resultorg.imixs.workflow.ItemCollectioncreateAdminPJob(org.imixs.workflow.ItemCollection document)Creates a new AdminPJobInstancevoiddeleteDocument(String uniqueid)Deletes a single workItem or document instance by UniqueID.org.imixs.workflow.ItemCollectiongetDocument(String uniqueid)Returns a single document instance by UniqueID.StringgetItems()intgetPageIndex()intgetPageSize()StringgetSortBy()StringgetType()retruns the document type.booleanisSortReverse()voidpostXMLDataCollection(String uri, org.imixs.workflow.xml.XMLDataCollection xmlDataCollection)Posts a XMLDocument collection to a custom resource.org.imixs.workflow.xml.XMLDataCollectionpostXMLDocument(String uri, org.imixs.workflow.xml.XMLDocument xmlWorkitem)Posts a XMLDocument to a custom resource.org.imixs.workflow.ItemCollectionsaveDocument(org.imixs.workflow.ItemCollection document)Creates or updates a single document instance.List<org.imixs.workflow.ItemCollection>searchDocuments(String query)Returns the the search result of a lucene search.voidsetItems(String items)Set a comma separated list of items to be returned.voidsetPageIndex(int pageIndex)voidsetPageSize(int pageSize)voidsetSortBy(String sortBy)voidsetSortOrder(String sortBy, boolean sortReverse)voidsetSortReverse(boolean sortReverse)voidsetType(String type)-
Methods inherited from class org.imixs.melman.AbstractClient
getBaseURI, getCustomResource, getCustomResourceXML, getRequestFilterList, getSslContext, getWebTarget, logout, newClient, registerClientRequestFilter, setBaseURI, setSslContext
-
-
-
-
Field Detail
-
ITEM_ERROR_CODE
public static final String ITEM_ERROR_CODE
- See Also:
- Constant Field Values
-
ITEM_ERROR_MESSAGE
public static final String ITEM_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_TYPE
public static final String DEFAULT_TYPE
- See Also:
- Constant Field Values
-
sortBy
protected String sortBy
-
sortReverse
protected boolean sortReverse
-
type
protected String type
-
pageSize
protected int pageSize
-
pageIndex
protected int pageIndex
-
items
protected String items
-
-
Constructor Detail
-
DocumentClient
public DocumentClient(String base_uri)
Initialize the client by a BASE_URL.- Parameters:
base_uri-
-
-
Method Detail
-
getPageSize
public int getPageSize()
-
setPageSize
public void setPageSize(int pageSize)
-
getPageIndex
public int getPageIndex()
-
setPageIndex
public void setPageIndex(int pageIndex)
-
getItems
public String getItems()
-
setItems
public void setItems(String items)
Set a comma separated list of items to be returned.- Parameters:
items-
-
getType
public String getType()
retruns the document type. The default value is "workitem"- Returns:
-
setType
public void setType(String type)
-
getSortBy
public String getSortBy()
-
setSortBy
public void setSortBy(String sortBy)
-
isSortReverse
public boolean isSortReverse()
-
setSortReverse
public void setSortReverse(boolean sortReverse)
-
setSortOrder
public void setSortOrder(String sortBy, boolean sortReverse)
-
saveDocument
public org.imixs.workflow.ItemCollection saveDocument(org.imixs.workflow.ItemCollection document) throws RestAPIExceptionCreates or updates a single document instance.- Parameters:
document- - a ItemCollection representing the document.- Returns:
- updated document instance
- Throws:
RestAPIException
-
createAdminPJob
public org.imixs.workflow.ItemCollection createAdminPJob(org.imixs.workflow.ItemCollection document) throws RestAPIExceptionCreates a new AdminPJobInstance- Parameters:
document- - a ItemCollection representing the job.- Returns:
- updated job instance
- Throws:
RestAPIException
-
getDocument
public org.imixs.workflow.ItemCollection getDocument(String uniqueid) throws RestAPIException
Returns a single document instance by UniqueID.- Parameters:
uniqueid-- Returns:
- workitem
- Throws:
RestAPIException
-
deleteDocument
public void deleteDocument(String uniqueid) throws RestAPIException
Deletes a single workItem or document instance by UniqueID.- Parameters:
userid-- Throws:
RestAPIException
-
searchDocuments
public List<org.imixs.workflow.ItemCollection> searchDocuments(String query) throws RestAPIException, UnsupportedEncodingException
Returns the the search result of a lucene search.The method creates a search URL and requests a CustomResource by GET. The lucene query is encoded by this method. The method throws a UnsupportedEncodingException if the query string can not be encoded.
- Parameters:
query- - lucene search query- Returns:
- result list
- Throws:
RestAPIExceptionUnsupportedEncodingException
-
countDocuments
public long countDocuments(String query) throws RestAPIException, UnsupportedEncodingException
Counts a given lucene search resultThe method returns the count of documents included in the result of a given lucene query
- Parameters:
query- - lucene search query- Returns:
- count of total hits
- Throws:
RestAPIExceptionUnsupportedEncodingException
-
postXMLDocument
public org.imixs.workflow.xml.XMLDataCollection postXMLDocument(String uri, org.imixs.workflow.xml.XMLDocument xmlWorkitem) throws RestAPIException
Posts a XMLDocument to a custom resource.This method expects that the response is a XMLDataCollection containing the posted document. In case of an HTTP Result other than 200=OK the method throws an exception containing the the error_code and error_message stored in the returnded XMLDocument
- Parameters:
document- - a ItemCollection representing the document.- Returns:
- updated document instance or null if no document was returned by the API
- Throws:
RestAPIException
-
postXMLDataCollection
public void postXMLDataCollection(String uri, org.imixs.workflow.xml.XMLDataCollection xmlDataCollection) throws RestAPIException
Posts a XMLDocument collection to a custom resource.- Parameters:
documents- - a collection of ItemCollection objects- Throws:
RestAPIException
-
-