This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. Document Library files atom collections
List file entries #
File entries atom collection of some folder is located at: http://localhost:8080/tunnel-web/secure/atom/files?folderId=12801. It is enough to specify the folder with just 'folderId' parameter. For root folders (folderId == 0), you must specify the 'groupId' request parameter instead. This collection supports pagination, using 'page' and 'max' request parameters.
Resulting Atom XML looks similar to this:
This atom collection consists of media entries. Actual media content is specified by the src link.
View entries #
Collection entry can be viewed in two ways: as an atom entry (xml content) or as media (binary content).
To view file as atom entry, URL looks like this:
http://localhost:8080/tunnel-web/secure/atom/files/12802
To view actual media content, just append ':media' to the entry id:
http://localhost:8080/tunnel-web/secure/atom/files/12802:media
Post new media entries #
There are two ways how to add new media content to the collection. The first one is through atom xml, the other one is using directly.
This is an example that creates new media entry using atom xml:
Abdera abdera = new Abdera();
Factory factory = abdera.getFactory();
Entry entry = factory.newEntry();
entry.setId(FOMHelper.generateUuid());
entry.setUpdated(new java.util.Date());
entry.setTitle("leaf1.jpg");
entry.setSummary("This is a leaf!");
File f = new File("c:\\list.jpg");
FileInputStream fis = new FileInputStream(f);
entry.setContent(fis, "image/jpeg");
AbderaClient client = new AbderaClient(abdera);
RequestOptions options = createRequestOptions(client);
options.setSlug(f.getName());
options.setContentType("application/atom+xml");
options.setHeader("Media-Content-Type", "image/jpeg");
// Response response = client.post(URL + "?repositoryId=10175", entry, options);
Response response = client.post(URL + "?folderId=11911", entry, options);
File is added as an atom entry content and it will be coded using base64 into atom xml file that is sent to the server. However, this way we can't send the content type of the media. Therefore, media content type will be resolved from the file name, unless it is explicitly specified in header as 'Media-Content-Type'.
Second approach is to post media content directly, using InputStreamRequestEntity. Since this time we are sending raw media content, we need to specify missing values for some atom entry properties, such as title and summary. Therefore, these values are sent to atom server as header parameters ("Title", "Summary"). Example:
Abdera abdera = new Abdera();
File f = new File("c:\\list.jpg");
FileInputStream fis = new FileInputStream(f);
AbderaClient client = new AbderaClient(abdera);
RequestOptions options = createRequestOptions(client);
options.setSlug(f.getName());
options.setContentType("image/jpeg");
InputStreamRequestEntity streamRequest = new InputStreamRequestEntity(fis, "image/jpeg");
options.setHeader("Title", "leaf");
options.setHeader("Summary", "Summary!");
// Response response = client.post(URL + "?repositoryId=10175", streamRequest, options);
Response response = client.post(URL + "?folderId=11911", streamRequest, options);Update #
Updating also can be done in two ways. When updating media directly, we need to provide title and summary as header parameters and use media URL.
Example using atom xml:
Factory factory = abdera.getFactory();
Entry entry = factory.newEntry();
entry.setId("tag:liferay.com:dl:entry:12601");
entry.setUpdated(new java.util.Date());
entry.setTitle("title.jpg");
entry.setSummary("Updated summary");
entry.addAuthor("Chuck");
File f = new File("c:\\download\\liferay-mind-twister.jpg");
FileInputStream fis = new FileInputStream(f);
entry.setContent(fis, "image/jpeg");
AbderaClient client = new AbderaClient(abdera);
RequestOptions options = createRequestOptions(client);
options.setContentType("application/atom+xml");
options.setSlug(f.getName());
Response response = client.put(URL + "/12601", entry, options);Example using media:
Abdera abdera = new Abdera();
File f = new File("c:\\download\\liferay-mind-twister.jpg");
FileInputStream fis = new FileInputStream(f);
AbderaClient client = new AbderaClient(abdera);
RequestOptions options = createRequestOptions(client);
options.setSlug(f.getName());
options.setContentType("image/jpeg");
InputStreamRequestEntity streamRequest = new InputStreamRequestEntity(fis, "image/jpeg");
options.setHeader("Title", "opet list.jpg");
options.setHeader("Summary", "Summary!");
Response response = client.put(URL + "/12610:media", streamRequest, options);Delete #
Deleting entries can be done as usual, by sending DELETE request to entry URL.