5.5.2. List of documents (folder, files)

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

There are several methods to get the documents lists, such as getChildren(), getFolderTree() and getDescendants(). The difference between them is the usage of different URL segments to get data ("/children" for getChildren(), "/foldertree" for getFolderTree(), "/descendants" for getDescendants()), and (getChildren() returns a flat structure, while getFolderTree() and getDescendants() 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 a URL to make a request (consisting of repository name, 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 specified while making a request - the same way 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