Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
// execute
ObjectInFolderList children = service.getChildren(repositoryId, folderId, filter, orderBy,
includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems,
skipCount, null);
if (children == null) {
throw new CmisRuntimeException("Children are null!");
}
ObjectInfo folderInfo = service.getObjectInfo(repositoryId, folderId);
if (folderInfo == null) {
throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
.getLastModificationDate(), null, children.getNumItems());
// write links
UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
feed.writeServiceLink(baseUrl.toString(), repositoryId);
feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), null);
feed.writeDescribedByLink(compileUrl(baseUrl, RESOURCE_TYPE, folderInfo.getTypeId()));
feed.writeAllowableActionsLink(compileUrl(baseUrl, RESOURCE_ALLOWABLEACIONS, folderInfo.getId()));
feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
if (folderInfo.supportsDescendants()) {
feed.writeDownLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()),
Constants.MEDIATYPE_DESCENDANTS);
}
if (folderInfo.supportsFolderTree()) {
feed.writeFolderTreeLink(compileUrl(baseUrl, RESOURCE_FOLDERTREE, folderInfo.getId()));
}
if (folderInfo.hasParent()) {
feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
}
if (folderInfo.getRenditionInfos() != null) {
for (RenditionInfo ri : folderInfo.getRenditionInfos()) {
feed.writeAlternateLink(compileUrl(baseUrl, RESOURCE_CONTENT, ri.getId()), ri.getContenType(), ri
.getKind(), ri.getTitle(), ri.getLength());
}
}
if (folderInfo.hasAcl()) {
feed.writeAclLink(compileUrl(baseUrl, RESOURCE_ACL, folderInfo.getId()));
}
if (folderInfo.supportsPolicies()) {
feed.writeAclLink(compileUrl(baseUrl, RESOURCE_POLICIES, folderInfo.getId()));
}
if (folderInfo.supportsRelationships()) {
feed.writeRelationshipsLink(compileUrl(baseUrl, RESOURCE_RELATIONSHIPS, folderInfo.getId()));
}
UrlBuilder pagingUrl = new UrlBuilder(compileUrlBuilder(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()));
pagingUrl.addParameter(Constants.PARAM_FILTER, filter);
pagingUrl.addParameter(Constants.PARAM_ORDER_BY, orderBy);
pagingUrl.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
pagingUrl.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
pagingUrl.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
pagingUrl.addParameter(Constants.PARAM_PATH_SEGMENT, includePathSegment);
feed.writePagingLinks(pagingUrl, maxItems, skipCount, children.getNumItems(), children.hasMoreItems(),
AtomPubUtils.PAGE_SIZE);
// write collection
feed.writeCollection(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), null, "Folder collection",
Constants.MEDIATYPE_CMISATOM);
// write entries
if (children.getObjects() != null) {
AtomEntry entry = new AtomEntry(feed.getWriter());
for (ObjectInFolderData object : children.getObjects()) {
if ((object == null) || (object.getObject() == null)) {
continue;
}
writeObjectEntry(service, entry, object.getObject(), null, repositoryId, object.getPathSegment(), null,
baseUrl, false);