CoreSession session = ctx.getCoreSession();
DocumentModel doc = session.getDocument(docRef);
args.put("currentDoc", doc);
PaginableDocumentModelList docs;
DocumentModel socialWorkspace = null;
if (isSearch) {
docs = search(doc, pageSize, page, queryText);
socialWorkspace = doc;
args.put("queryText", queryText);
} else {
docs = getChildren(doc, pageSize, page);
List<DocumentModel> ancestors = getAncestors(doc);
DocumentModel parent = null;
if (ancestors.size() > 1) {
parent = ancestors.get(ancestors.size() - 2);
}
args.put("parent", parent);
if (!ancestors.isEmpty() && isSocialWorkspace(ancestors.get(0))) {
socialWorkspace = ancestors.remove(0);
}
args.put("ancestors", ancestors);
args.put("queryText", "");
}
args.put("socialWorkspace", socialWorkspace);
args.put("docs", docs);
args.put("publishablePublic",
getPublishableDocs(socialWorkspace, docs, true));
args.put("publishablePrivate",
getPublishableDocs(socialWorkspace, docs, false));
args.put("removable", getDocsWithDeleteRight(docs));
args.put(
"isPublicSocialWorkspace",
socialWorkspace.getPropertyValue(SOCIAL_WORKSPACE_IS_PUBLIC_PROPERTY));
args.put("collaboration_views", getCollaborationViews(docs));
// add navigation arguments
args.put("page", docs.getCurrentPageIndex());
args.put("maxPage", docs.getNumberOfPages());
if (docs.getNumberOfPages() > 0) {
args.put("nextPage", page < docs.getNumberOfPages() - 1 ? page + 1
: page);
} else {
// unknown size
args.put("nextPage", page + 1);
}