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
{
try
{
ContentTypeDefinitionVO contentTypeDefinitionVO = contentController.getContentTypeDefinition(theNode.getId());
if(contentTypeDefinitionVO != null)
elm.addAttribute("contentTypeId","" + contentTypeDefinitionVO.getContentTypeDefinitionId());
}
catch (Exception e)
{