if (policies == null) {
throw new CmisRuntimeException("Policies are null!");
}
ObjectInfo objectInfo = service.getObjectInfo(repositoryId, objectId);
if (objectInfo == null) {
throw new CmisRuntimeException("Object Info is missing!");
}
// set headers
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType(Constants.MEDIATYPE_FEED);
// write XML
AtomFeed feed = new AtomFeed();
feed.startDocument(response.getOutputStream());
feed.startFeed(true);
// write basic Atom feed elements
feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
objectInfo.getLastModificationDate(), null, null);
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
feed.writeServiceLink(baseUrl.toString(), repositoryId);
feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_POLICIES, objectInfo.getId()), null);
// write entries
AtomEntry entry = new AtomEntry(feed.getWriter());
for (ObjectData policy : policies) {
if (policy == null) {
continue;
}
writePolicyEntry(service, entry, objectInfo.getId(), policy, repositoryId, baseUrl);
}
// we are done
feed.endFeed();
feed.endDocument();