You are looking at documentation for an older release. Not what you want? See the current release documentation.
Reading the Document properties and content stream are two separate operations. Getting the content stream is possible after the properties set has been read and the content stream ID is extracted from it.
Get document properties.
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
String url = "http://localhost:8080/rest/private/cmisatom/";
url += repository;
url += "/object/";
url += obj_id;
HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
client.getHttpConnectionManager().
getParams().setConnectionTimeout(10000);
GetMethod get = new GetMethod(url);
try {
int result = client.executeMethod(get);
final String strResponse = get.getResponseBodyAsString();
// use response...
} finally {
get.releaseConnection();
}
Get document content-stream.
To get the Document's content stream, an URL must contain a "/file
" part, object ID, and optionally the content
stream ID, which can be used, for example, to obtain renditions. If no stream ID is specified, the default stream will be returned.
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
String url = "http://localhost:8080/rest/private/cmisatom/";
url += repository;
url += "/file/";
url += obj_id;
//Optionally
url += "?";
url += "streamid=";
url += streamID;
HttpClient client = new HttpClient();
client.getHttpConnectionManager().
getParams().setConnectionTimeout(10000);
GetMethod get = new GetMethod(url);
try {
int result = client.executeMethod(get);
final InputStream stream = get.getResponseBodyAsStream();
try {
// use stream...
int dataByte = stream.read();
} finally {
stream.close();
}
} finally {
get.releaseConnection();
}
Get document properties.
Create a URL to make a request (consisting of repository name, method name, for example "/children/", and folder ID to get the children from):
var url = "http://localhost:8080/rest/private/cmisatom/";
url += repository;
url += "/object/";
url += obj_id;
Perform the request:
var params = {};
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.FEED;
gadgets.io.makeRequest(url, handler, params);
You can also use the ContentType.DOM
parameter to parse the feed in your application (Using DOMParser for example).
Get document content-stream.
Performing a content stream request in JavaScript will cause the browser dialog for a file download.
var url = "http://localhost:8080/rest/private/cmisatom/";
url += repository;
url += "/file/";
url += obj_id;
//Optionally
url += "?";
url += "streamid=";
url += streamID;