3.5.2. List of documents (folder, files)

There are several methods to get the documents lists, such as getChildren(), getFolderTree() and getDescentants(), their usage will be described below. The difference between them is the usage of different URL segments to get data ("/children" for getChildren(), "/foldertree" for getFolderTree(), "/descendants" for getDescentants()), and a different kind of results (getChildren() returns a flat structure, while a getFolderTree() and getDescentants() have a tree of items in response).

Using Java

 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 += "/children/";
 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();
 } finally {
   get.releaseConnection();
 }

Using JavaScript

Creating an URL to make a request (consists of repository name, the method name, for example "/children/", and folderID to get children from):

 var url = "http://localhost:8080/rest/private/cmisatom/";

 url += repository;
 url += "/children/";
 url += obj_id;

Performing 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);

Processing results (the code is located in the handler is specified while making a request, the same way it might be used for all examples in this chapter):

 var handler = function(resp) {

  var data = eval(resp.data.Entry);
   for (var i = 0; i < data.length; i++) {
 var doc = data[i];
 alert(doc.Title);
 alert(doc.Date);
  ...etc..
   }
}
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus