HttpSession session, Iterator<? extends XResource> it,int _level,
boolean parentIsOwner,boolean standalone,
boolean isSuggested,boolean inOwn,String serviceAddr,String selectedUri,
Set<List<String>> pathsToUri) {
Person issuer = null;
int level = _level;
XResource xfr = resource.getIssuedBy();
if(xfr instanceof Person)
issuer = (Person)xfr;
boolean isDir = resource.isDirectory();
boolean isOwner = false;
boolean hasContent = resource.hasContent();
boolean reachable = checkCredit(viewer, resource);
boolean isDyn = false;
boolean isDiu = false; //is del.icio.us main directory
boolean onPath = false;
if(!isOwner&&resource.checkIsImportRootDir()) //TODO: resource.getStringURI().startsWith("http://del.icio.us/"))
{
isDyn = true;
isDiu = true;
}
if(issuer!=null) isOwner = viewer.equals(issuer);
if(isOwner==false&&resource.getIssuedBy()!=null) {
if(resource.getIssuedBy() instanceof SscfTagger) {
SscfTagger st =(SscfTagger)(resource.getIssuedBy());
isOwner = st.isConnectedWithPerson(viewer);
if(isOwner) issuer = viewer;
else {issuer = st.getConnectedPerson();}
}
}
if(hasContent==false) hasContent = resource.hasSuggestedContent();
if(reachable)
{
level++;
NodeContainer nc = new NodeContainer();
//** selected link/filtering **
Set<List<String>> newPathsToUri = pathsToUri;
if(pathsToUri!=null)
{
//check if node is on one of the paths in pathsToUri - if yes cut off this path
for(List<String> path:pathsToUri)
{
if(!path.isEmpty())
if(path.get(0).equals(resource.getStringURI()))
{
onPath = true;
break;
}
}
//if the current node is on some path - rewrite the list, and remove current node from it.
if(onPath)
{
newPathsToUri = new HashSet<List<String>>();
for(List<String> path:pathsToUri)
{
if(!path.isEmpty())
if(path.get(0).equals(resource.getStringURI()))
{
path.remove(0);
}
if(!path.isEmpty())
{
newPathsToUri.add(path);
}
}
}
}
//need to think some more wise way to tell when script should stop go deeper
//FIXME: del.icio.us would be always dynamic!
if(level>=maxAbsoluteLevel&&hasContent&&!onPath) {
isDyn = true;
}
nc.setDyn(isDyn);
//special case for filtering and user's own directory. there is no need to generate elements
//that has been already generated.
//maxAbsoluteLevel==0 means that there is filtering mode enabled
boolean isSelected = false;
if(selectedUri!=null&&!"".equals(selectedUri.trim())) {
isSelected = (resource.getStringURI().equals(selectedUri));
if(!isSelected&&selectedUri.length()>40)
isSelected = resource.getStringURI().endsWith(selectedUri.substring(selectedUri.length()-40,selectedUri.length()));
}
if(maxAbsoluteLevel!=0||onPath||isSelected||!isOwner)
{
if(isDiu)
{
nc.setType("diuDirectory");
if(onPath)
{
isDyn = false;
nc.setDyn(isDyn);
}
DirectoryNode dn = new DirectoryNode();
dn.setId(resource.getResource().toString());
dn.setLevel(level);
String label = resource.getStringURI();
if(label.length()>9)
label = label.substring(0,label.length()-9);
dn.setLabel(label+" bookmarks");
dn.setOwn(isOwner);
dn.setOwnerMbox((issuer != null) ? (issuer.getId()) : "");
dn.setOwnerName((issuer != null) ? (issuer.getName()) : "");
dn.setRemovable(!hasContent);
dn.setLinkedIn(parentIsOwner&!isOwner);
dn.setOpened(onPath);
dn.setStandalone(standalone);
nc.setContent(dn);
}
//normal directory
else if(isDir&&!isSuggested)
{
nc.setType("directory");
DirectoryNode dn = new DirectoryNode();
dn.setId(resource.getResource().toString());
dn.setLevel(level);
if(resource.getLabel().contains("\"")||resource.getLabel().contains("'"))
{
dn.setLabel("bleble "+resource.getLabel().replace("\"", "\\\"").replace("'","\\'"));
}
else if(resource.getLabel().trim().equals(""))
{
dn.setLabel(resource.getStringURI());
}
else
{
dn.setLabel(resource.getLabel());
}
dn.setOwn(isOwner);
dn.setOwnerMbox((issuer != null) ? (issuer.getId()) : "");
dn.setOwnerName((issuer != null) ? (issuer.getName()) : "");
dn.setRemovable(!hasContent);
dn.setLinkedIn(parentIsOwner&!isOwner);
dn.setOpened(onPath);
//check if user select this directory - we can get id or whole uri.
if(isSelected)
{
dn.setSelected(true);
dn.setOpened(false);
}
else dn.setSelected(false);
dn.setStandalone(standalone);
nc.setContent(dn);
}
//suggested directory
else if(isDir&&isSuggested)
{
nc.setType("sugDirectory");
SugDirectoryNode sdn = new SugDirectoryNode();
sdn.setId(resource.getResource().toString());
sdn.setLevel(level);
sdn.setLabel(resource.getLabel());
sdn.setOwnerMbox((issuer != null) ? (issuer.getId()) : "");
sdn.setOwnerName((issuer != null) ? (issuer.getName()) : "");
sdn.setOpened(onPath);
//check if user select this directory - we can get id or whole uri.
if(isSelected)