if (useTemplate) return "success";
Document doc = DocumentHelper.createDocument();
Element root = doc.addElement("tree");
INodeSupplier sup;
if(repositoryId == null)
{
List repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), false);
for(Iterator i=repositories.iterator();i.hasNext();)
{
RepositoryVO r = (RepositoryVO) i.next();
BaseEntityVO entityVO = getRootEntityVO(r.getId(), this.getInfoGluePrincipal());
String src= action + "?repositoryId=" + r.getId() + urlArgSeparator + (sortLanguageId != null ? "sortLanguageId=" + sortLanguageId : "") + urlArgSeparator + "parent=" + entityVO.getId();
if(createAction && src.length() >0) src += urlArgSeparator + "createAction=true";
if(action.length()>0 && src.length() >0) src += urlArgSeparator + "action=" + action;
String allowedContentTypeIdsUrlEncodedString = getAllowedContentTypeIdsAsUrlEncodedString();
logger.info("allowedContentTypeIdsUrlEncodedString1:" + allowedContentTypeIdsUrlEncodedString);
if(allowedContentTypeIdsUrlEncodedString.length()>0 && src.length() >0)
src += urlArgSeparator + allowedContentTypeIdsUrlEncodedString;
logger.info("src:" + src);
String text=r.getName();
Element element = root.addElement("tree");
element
.addAttribute("id", "" + r.getId())
.addAttribute("repositoryId", "" + r.getId())
.addAttribute("text", encode(text))
.addAttribute("src", src)
.addAttribute("hasChildren", "true")
.addAttribute("type", TYPE_REPOSITORY);
}
out(getFormattedDocument(doc));
return null;
}
sup = getNodeSupplier();
if(parent == null)
{
BaseNode node = sup.getRootNode();
String text = node.getTitle();
String type = TYPE_FOLDER;
String src = action + "?repositoryId=" + repositoryId + urlArgSeparator + (sortLanguageId != null ? "sortLanguageId=" + sortLanguageId : "") + urlArgSeparator + "parent=" + node.getId();
if(createAction && src.length() >0) src += urlArgSeparator + "createAction=true";
if(action.length()>0 && src.length() >0) src += urlArgSeparator + "action=" + action;
String allowedContentTypeIdsUrlEncodedString = getAllowedContentTypeIdsAsUrlEncodedString();
logger.info("allowedContentTypeIdsUrlEncodedString2:" + allowedContentTypeIdsUrlEncodedString);
if(allowedContentTypeIdsUrlEncodedString.length()>0 && src.length() >0)
src += urlArgSeparator + allowedContentTypeIdsUrlEncodedString;
//logger.info("src2:" + src);
Element elm = root.addElement("tree");
elm
.addAttribute("id", "" + node.getId())
.addAttribute("repositoryId", "" + repositoryId)
.addAttribute("text", encode(text))
.addAttribute("src", src)
.addAttribute("isLocalized", (String)node.getParameters().get("isLocalized"))
.addAttribute("isLanguageAvailable", (String)node.getParameters().get("isLanguageAvailable"))
.addAttribute("isHidden", (String)node.getParameters().get("isHidden"))
.addAttribute("hasChildren", "true")
.addAttribute("type", type);
if(node.getParameters().containsKey("contentTypeDefinitionId"))
elm.addAttribute("contentTypeDefinitionId", (String)node.getParameters().get("contentTypeDefinitionId"));
if(node.getParameters().containsKey("isProtected"))
elm.addAttribute("isProtected", (String)node.getParameters().get("isProtected"));
if(node.getParameters().containsKey("stateId"))
elm.addAttribute("stateId", (String)node.getParameters().get("stateId"));
out(getFormattedDocument(doc));
return null;
}
if(parent.intValue() > -1)
{
Collection containerNodes = sup.getChildContainerNodes(parent);
Collection childNodes = sup.getChildLeafNodes(parent);
ContentController contentController = ContentController.getContentController();
ContentVersionController contentVersionController = ContentVersionController.getContentVersionController();
Iterator it = containerNodes.iterator();
while (it.hasNext())
{
BaseNode theNode = (BaseNode) it.next();
if (theNode.isContainer() && sup.hasChildren())
{
theNode.setChildren(sup.hasChildren(theNode.getId()));
}
// String src = theNode.hasChildren() ? action + "?repositoryId=" + repositoryId + urlArgSeparator + "parent=" + theNode.getId(): "";
String src = action + "?repositoryId=" + repositoryId + urlArgSeparator + (sortLanguageId != null ? "sortLanguageId=" + sortLanguageId : "") + urlArgSeparator + "parent=" + theNode.getId();
if(createAction && src.length() >0) src += urlArgSeparator + "createAction=true";
if(createAction && src.length() >0) src += urlArgSeparator + "showLeafs=" + showLeafs;
if(action.length()>0 && src.length() >0) src += urlArgSeparator + "action=" + action;
String allowedContentTypeIdsUrlEncodedString = getAllowedContentTypeIdsAsUrlEncodedString();
if(allowedContentTypeIdsUrlEncodedString.length()>0 && src.length() >0) src += urlArgSeparator + allowedContentTypeIdsUrlEncodedString;
Element elm = root.addElement("tree");
elm
.addAttribute("id", "" + theNode.getId())
.addAttribute("parent", "" + parent)
.addAttribute("repositoryId", "" + repositoryId)
.addAttribute("text", encode(theNode.getTitle()))
.addAttribute("src", src)
.addAttribute("isLocalized", (String)theNode.getParameters().get("isLocalized"))
.addAttribute("isLanguageAvailable", (String)theNode.getParameters().get("isLanguageAvailable"))
.addAttribute("isHidden", (String)theNode.getParameters().get("isHidden"))
.addAttribute("type", TYPE_FOLDER)
.addAttribute("hasChildren", "" + theNode.hasChildren());
if(theNode.getParameters().containsKey("contentTypeDefinitionId"))
elm.addAttribute("contentTypeDefinitionId", "" + theNode.getParameters().get("contentTypeDefinitionId"));
if(theNode.getParameters().containsKey("isProtected"))
elm.addAttribute("isProtected", (String)theNode.getParameters().get("isProtected"));
if(theNode.getParameters().containsKey("stateId"))
elm.addAttribute("stateId", (String)theNode.getParameters().get("stateId"));
if(createAction) elm.addAttribute("action", makeAction(theNode));
}
it = childNodes.iterator();
while (it.hasNext())
{
BaseNode theNode = (BaseNode) it.next();
String text = theNode.getTitle();
String action = makeAction(theNode);
String type = TYPE_ITEM;
Element elm = root.addElement("tree");
elm
.addAttribute("id", "" + theNode.getId())
.addAttribute("parent", "" + parent)
.addAttribute("repositoryId", "" + repositoryId)
.addAttribute("text", encode(text))
.addAttribute("type", type)
;
if(theNode.getParameters().containsKey("contentTypeDefinitionId"))
elm.addAttribute("contentTypeDefinitionId", "" + theNode.getParameters().get("contentTypeDefinitionId"));
if(theNode.getParameters().containsKey("isProtected"))
elm.addAttribute("isProtected", (String)theNode.getParameters().get("isProtected"));
if(theNode.getParameters().containsKey("stateId"))
elm.addAttribute("stateId", (String)theNode.getParameters().get("stateId"));
if(createAction)
elm.addAttribute("action", action);
else
{
ContentVersionVO activeVersion = contentVersionController.getLatestActiveContentVersionVO(theNode.getId(), LanguageController.getController().getMasterLanguage(repositoryId).getLanguageId());
if(activeVersion!=null && !useTemplate)
{
elm.addAttribute("activeVersion", "" + activeVersion.getContentVersionId());
elm.addAttribute("activeVersionStateId", "" + activeVersion.getStateId());
elm.addAttribute("activeVersionModifier", "" + activeVersion.getVersionModifier());
}
}
//TODO - this was a quickfix only
if(!useTemplate && sup.getClass().getName().indexOf("Content") > -1)
{
if(theNode.getParameters().containsKey("contentTypeDefinitionId"))
elm.addAttribute("contentTypeId", "" + theNode.getParameters().get("contentTypeDefinitionId"));
else
{