|
Qizx fe-4.4p2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.qizx.util.rest.RESTClient
com.qizx.apps.restapi.RestAPIConnection
public class RestAPIConnection
HTTP client for the Qizx REST API.
Provides most of functionalities of Library
, with a few
restrictions and slightly different semantics.
This class is not thread-safe. As many instances as desired can be created.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.qizx.util.rest.RESTClient |
---|
com.qizx.util.rest.RESTClient.Get, com.qizx.util.rest.RESTClient.Post, com.qizx.util.rest.RESTClient.Put, com.qizx.util.rest.RESTClient.Request, com.qizx.util.rest.RESTClient.Response |
Field Summary |
---|
Fields inherited from class com.qizx.util.rest.RESTClient |
---|
DEFAULT_CHAR_ENCODING, ERROR_TYPE, OPER, PATH |
Fields inherited from interface com.qizx.apps.restapi.RestAPI |
---|
CONFIGURATION_FIELDS, COUNTING_ESTIMATE, COUNTING_EXACT, COUNTING_NONE, E_COUNT, EXPERT_LEVEL, FORMAT_HTML, FORMAT_ITEMS, FORMAT_XML, INFO_FIELDS, NAME, NODES_FIELDS, PROFILE, PROFILING, PROPERTY, RUNNING_QUERIES_FIELDS, STATS_FIELDS, T_COUNT, TASKS_FIELDS, TYPE_ATTR |
Constructor Summary | |
---|---|
RestAPIConnection(String URL)
Creates a Qizx REST API client. |
Method Summary | |
---|---|
void |
addProperty(String name,
String type,
String value)
Adds a Property to a batch of setprop operations |
String |
backup(String path)
Wraps the "backup" command. |
String |
cancelRunningQuery(String exprId)
Cancels a currently executing XQuery. |
boolean |
changeConfiguration(Properties properties)
Changes a set of configuration properties. |
String |
copy(String src,
String dst)
Copies a Document or Collection. |
String |
createCollection(String path,
boolean createParents)
Wraps the mkcol request. |
void |
createLibrary(String libraryName)
Wraps the "mklib" command. |
boolean |
delete(String path)
Deletes a Document or Collection given by its path. |
void |
deleteLibrary(String libraryName)
Wraps the "dellib" command. |
ItemSequence |
eval(String query,
String format)
Sends an evaluates an XQuery script, returns the response as a sequence of XQuery Items. |
ItemSequence |
eval(String query,
String format,
String encoding,
int maxTime,
String counting,
String mode,
int itemCount,
int firstItem)
Sends an evaluates an XQuery script, returns the response as a page of XQuery Items. |
ItemSequence |
evalAsItems(String query,
String mode,
int itemCount,
int firstItem)
Sends an evaluates an XQuery script, returns the response as a page of XQuery Items. |
String |
finishProperties()
Finishes a batch of setprop operations |
String[] |
finishPut()
Called to finish a bulk load (after startPut and a series of addDocument) |
com.qizx.util.rest.RESTClient.Response |
get(String path)
Gets the contents of a Document or of a Collection. |
com.qizx.util.rest.RESTClient.Response |
get(String path,
int limit)
Gets the contents of a Document or of a Collection. |
com.qizx.util.rest.RESTClient.Response |
get(String path,
String options,
int limit)
Gets the contents of a Document or of a Collection. |
String |
getAcl(String path,
boolean inherited)
Returns the ACL information for a Library member of the current XML Library. |
LibraryMemberIterator |
getChildren(String collectionPath,
int limit)
Returns children of Collection: documents or collections as an iterator. |
String |
getClusterName()
Returns |
com.qizx.apps.util.TabularData |
getClusterNodes()
Returns |
com.qizx.apps.util.TabularData |
getConfiguration(boolean expert)
Returns a table of configuration properties. |
Indexing |
getIndexing()
Wraps the "getindexing" command. |
Map<String,com.qizx.apps.util.Property> |
getMemberProperties(String path,
String[] propNames)
Returns metadata properties of a Library Member (document or collection) |
LibraryMemberIterator |
getMembers(String path,
int depth,
String[] properties)
Returns an iterator over XML Library members |
double |
getProgress(String id)
Wraps the "progress" command. |
com.qizx.apps.util.TabularData |
getStats(String level)
Returns a table of statistics from the server. |
String |
incrementalBackup(String path)
Wraps the "incrbackup" command. |
Map<String,com.qizx.apps.util.Property> |
info()
Returns a map of system properties describing the Qizx server. |
String[] |
listLibraries()
Wraps the "listlib" command. |
com.qizx.apps.util.TabularData |
listMaintenanceTasks(int timeline)
Gets a list of background tasks |
com.qizx.apps.util.TabularData |
listRunningQueries()
Returns a table of queries currently executing in one of the XML Libraries managed by the server. |
String |
login()
This request checks that the client can access the server. |
String |
move(String src,
String dst)
Wraps the move request. |
com.qizx.util.rest.RESTClient.Get |
newGet(String name,
String path)
Internal. |
com.qizx.util.rest.RESTClient.Post |
newPost(String name,
String path)
Internal. |
com.qizx.util.rest.RESTClient.Put |
newPut(String name,
String path)
Internal. |
String |
optimize()
Wraps the "optimize" command. |
void |
putDocument(String path,
File contents,
String contentType)
Adds a document to the current import operation. |
void |
putDocument(String path,
String contents)
Adds a document to the current import operation. |
LibraryMemberIterator |
queryProp(String path,
String query,
String[] properties)
Looks for Library members matching a query on metadata properties. |
String |
quickOptimize(int timeHint,
boolean blocking)
Wraps the "quickoptimize" command. |
com.qizx.util.rest.RESTClient.Response |
rawEval(String query,
String format,
String encoding,
int maxTime,
String counting,
String mode,
int itemCount,
int firstItem)
Evaluation without parsing of the response (internal use). |
String |
reindex()
Wraps the "reindex" command. |
String |
serverControl(String command)
Wraps the "server" command. |
void |
setAcl(String data)
Adds ACL rules to the current XML Library Wraps the "setacl" command. |
void |
setCredentials(String username,
String password)
Defines user credentials for Basic and Digest authentication schemes. |
void |
setIndexing(File spec)
Wraps the "setindexing" command. |
void |
setIndexing(String spec)
Wraps the "setindexing" command. |
void |
setLibraryName(String name)
Sets the name of the current XML Library. |
void |
startPut()
Starts an import of XML documents. |
void |
startPutNonXML()
Starts an import of non-XML documents. |
void |
startSetProp(String path,
String name,
String type,
String value)
Starts a batch of setprop operations on a Library Member (document or collection) |
String[] |
streamingPut(InputStream data)
Store wrapped XML documents. |
Methods inherited from class com.qizx.util.rest.RESTClient |
---|
getBaseURL, newGet, newPost, newPut |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RestAPIConnection(String URL) throws MalformedURLException
URL
- an URL pointing to the API Service of a Qizx Server.
MalformedURLException
Method Detail |
---|
public void setLibraryName(String name)
Can be left to null if the server manages only one XML Library.
name
- name of an XML Library (database) managed by the server.public void setCredentials(String username, String password)
com.qizx.util.rest.RESTClient
setCredentials
in class com.qizx.util.rest.RESTClient
public String login() throws com.qizx.util.rest.RESTException
User credentials should be set before attempting any connection.
See setCredentials(String, String)
.
com.qizx.util.rest.RESTException
public com.qizx.util.rest.RESTClient.Response get(String path) throws com.qizx.util.rest.RESTException
path
- database path of the Document or Collection.limit
- maximum number of members for collection; no limit if < 0
com.qizx.util.rest.RESTException
Response
public com.qizx.util.rest.RESTClient.Response get(String path, int limit) throws com.qizx.util.rest.RESTException
path
- database path of the Document or Collection.limit
- maximum number of members for collection; no limit if < 0
com.qizx.util.rest.RESTException
Response
public com.qizx.util.rest.RESTClient.Response get(String path, String options, int limit) throws com.qizx.util.rest.RESTException
path
- database path of the Document or Collection.options
- serialization options for Documents: a comma or tab-separated
list of options in the form option=value
, for example
method=XML, encoding=ISO8859-1
. See XMLSerializer
for options details.limit
- maximum number of members for collection; no limit if < 0
com.qizx.util.rest.RESTException
RESTClient.Response
public ItemSequence eval(String query, String format) throws com.qizx.util.rest.RESTException, EvaluationException
query
- an XQuery script.format
- a String with value "items", "XML" or "HTML".
com.qizx.util.rest.RESTException
EvaluationException
public ItemSequence evalAsItems(String query, String mode, int itemCount, int firstItem) throws com.qizx.util.rest.RESTException, EvaluationException
query
- an XQuery script.mode
- null in normal execution, or "profile"itemCount
- desired number of items.firstItem
- the rank of the first desired item (first rank is 1).
com.qizx.util.rest.RESTException
EvaluationException
public ItemSequence eval(String query, String format, String encoding, int maxTime, String counting, String mode, int itemCount, int firstItem) throws com.qizx.util.rest.RESTException, EvaluationException
query
- an XQuery script.format
- a String with value "items", "XML" or "HTML".encoding
- encoding used for the responsemaxTime
- number of milliseconds the query is allowed to run. Ignored if <= 0.counting
- counting method (applicable to format "items" only): value
can be: mode
- execution mode: null for normal execution, or "profile" for profilingitemCount
- desired number of items.firstItem
- the rank of the first desired item (first rank is 1).
com.qizx.util.rest.RESTException
EvaluationException
public com.qizx.util.rest.RESTClient.Response rawEval(String query, String format, String encoding, int maxTime, String counting, String mode, int itemCount, int firstItem) throws com.qizx.util.rest.RESTException, EvaluationException
com.qizx.util.rest.RESTException
EvaluationException
public void startPut() throws com.qizx.util.rest.RESTException
A typical import snippet looks like:
restCx.startPut(); restCx.addDocument("/docs/path1", stringData); restCx.addDocument("/docs/path2", new File(myfile), null); String[] status = restCx.finishPut();
com.qizx.util.rest.RESTException
putDocument
,
finishPut()
public void startPutNonXML() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
#putDocument #finishPut
public void putDocument(String path, File contents, String contentType) throws com.qizx.util.rest.RESTException
path
- database path of the documentcontents
- a well-formed XML document, if called after startPut,
or any data if following startPutNonXML.contentType
- can be null or "text/xml" for XML data, or an
appropriate Mime type for non-XML documents.
com.qizx.util.rest.RESTException
#startPutNonXML #finishPut
public void putDocument(String path, String contents) throws com.qizx.util.rest.RESTException
path
- database path of the documentcontents
- a well-formed XML document as a String, if called after
startPut, or any text data if following startPutNonXML.
com.qizx.util.rest.RESTException
#startPutNonXML
public String[] finishPut() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
#startPutNonXML #putDocument
public String[] streamingPut(InputStream data) throws com.qizx.util.rest.RESTException
Data is pulled from a stream: due to http-client library constraints, this cannot work in push mode.
The format is:
... contents ... ... contents ...
data
- XML input stream
com.qizx.util.rest.RESTException
public String createCollection(String path, boolean createParents) throws com.qizx.util.rest.RESTException
mkcol
request.
path
- database path of the collectioncreateParents
- true if parent collection are to be created if they
do not yet exist.
com.qizx.util.rest.RESTException
public String move(String src, String dst) throws com.qizx.util.rest.RESTException
move
request.
src
- path of a collection or document to be renameddst
- target path of a collection or document
com.qizx.util.rest.RESTException
public String copy(String src, String dst) throws com.qizx.util.rest.RESTException
Wraps the copy
request.
src
- path of a collection or document to be copieddst
- target path of a collection or document
com.qizx.util.rest.RESTException
public boolean delete(String path) throws com.qizx.util.rest.RESTException
path
- path of a collection or document to be deleted
com.qizx.util.rest.RESTException
public LibraryMemberIterator getChildren(String collectionPath, int limit) throws com.qizx.util.rest.RESTException
collectionPath
- parent collection
com.qizx.util.rest.RESTException
public LibraryMemberIterator getMembers(String path, int depth, String[] properties) throws com.qizx.util.rest.RESTException, EvaluationException
path
- root path (a Collection if depth > 0)depth
- if 0, return only the properties of the root member,
if dept > 0 then the root path must be that of a Collection,
and the method returns members within that depth (depth=1 : children,
depth=2: grand-children etc)properties
- names of properties to return. By default, all properties
are returned. The names are separated by commas or whitespace.
com.qizx.util.rest.RESTException
EvaluationException
public Map<String,com.qizx.apps.util.Property> getMemberProperties(String path, String[] propNames) throws com.qizx.util.rest.RESTException
path
- path of the Library MemberpropNames
- selected property names. If null or empty, all properties
are returned.
com.qizx.util.rest.RESTException
public void startSetProp(String path, String name, String type, String value) throws com.qizx.util.rest.RESTException
path
- path of the Library Membername
- property nametype
- property typevalue
- property value, matching the type
com.qizx.util.rest.RESTException
public void addProperty(String name, String type, String value) throws com.qizx.util.rest.RESTException
name
- property nametype
- property typevalue
- property value, matching the type
com.qizx.util.rest.RESTException
public String finishProperties() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public LibraryMemberIterator queryProp(String path, String query, String[] properties) throws com.qizx.util.rest.RESTException, EvaluationException
path
- root collection defining a search domain (null for the whole
database)query
- a query on metadata properties.properties
- names of desired properties for each returned member (If
null or empty, all properties are returned).
com.qizx.util.rest.RESTException
EvaluationException
public Map<String,com.qizx.apps.util.Property> info() throws com.qizx.util.rest.RESTException, DataModelException
com.qizx.util.rest.RESTException
DataModelException
public String[] listLibraries() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public String serverControl(String command) throws com.qizx.util.rest.RESTException
command
-
com.qizx.util.rest.RESTException
public String getClusterName() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public com.qizx.apps.util.TabularData getClusterNodes() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public void createLibrary(String libraryName) throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public void deleteLibrary(String libraryName) throws com.qizx.util.rest.RESTException
libraryName
- name of an existing XML Library
com.qizx.util.rest.RESTException
public Indexing getIndexing() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public void setIndexing(File spec) throws com.qizx.util.rest.RESTException
spec
- a specification of Indexing options for the Library, as an XML file.
com.qizx.util.rest.RESTException
public void setIndexing(String spec) throws com.qizx.util.rest.RESTException
spec
- spec a specification of Indexing options for the Library, as an XML fragment
com.qizx.util.rest.RESTException
public String reindex() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public String optimize() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public String quickOptimize(int timeHint, boolean blocking) throws com.qizx.util.rest.RESTException
timeHint
- maximum desired time to spend optimizing, in secondsblocking
- true if method waits for a result
com.qizx.util.rest.RESTException
public String backup(String path) throws com.qizx.util.rest.RESTException
path
- path of a Directory on the server host, target of the backup
com.qizx.util.rest.RESTException
public String incrementalBackup(String path) throws com.qizx.util.rest.RESTException
path
- path of a Directory on the server host, target of the backup
com.qizx.util.rest.RESTException
public double getProgress(String id) throws com.qizx.util.rest.RESTException
id
- an identifier returned by backup reindex etc
com.qizx.util.rest.RESTException
public String getAcl(String path, boolean inherited) throws com.qizx.util.rest.RESTException
path
- inherited
-
IOException
com.qizx.util.rest.RESTException
public void setAcl(String data) throws com.qizx.util.rest.RESTException
data
-
com.qizx.util.rest.RESTException
public com.qizx.apps.util.TabularData getStats(String level) throws com.qizx.util.rest.RESTException
level
- "admin" or "expert"
com.qizx.util.rest.RESTException
public com.qizx.apps.util.TabularData getConfiguration(boolean expert) throws com.qizx.util.rest.RESTException
expert
- false for basic/admin configuration, true for most detailed
configuration
com.qizx.util.rest.RESTException
public boolean changeConfiguration(Properties properties) throws com.qizx.util.rest.RESTException
properties
- a map of properties with their value
com.qizx.util.rest.RESTException
public com.qizx.apps.util.TabularData listRunningQueries() throws com.qizx.util.rest.RESTException
com.qizx.util.rest.RESTException
public String cancelRunningQuery(String exprId) throws com.qizx.util.rest.RESTException
exprId
- unique identifier of the query, as returned by
listRunningQueries()
com.qizx.util.rest.RESTException
public com.qizx.apps.util.TabularData listMaintenanceTasks(int timeline) throws com.qizx.util.rest.RESTException
timeline
- if 0, return only currently running tasks, otherwise return
tasks that started within this number of hours in the past. For
example timeline=24 returns all tasks that started in the past 24
hours.
com.qizx.util.rest.RESTException
public com.qizx.util.rest.RESTClient.Get newGet(String name, String path)
com.qizx.util.rest.RESTClient
newGet
in class com.qizx.util.rest.RESTClient
public com.qizx.util.rest.RESTClient.Put newPut(String name, String path)
com.qizx.util.rest.RESTClient
newPut
in class com.qizx.util.rest.RESTClient
public com.qizx.util.rest.RESTClient.Post newPost(String name, String path)
com.qizx.util.rest.RESTClient
newPost
in class com.qizx.util.rest.RESTClient
|
© 2010 Axyana Software | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |