final String childCollections[] = current.listChildCollections();
final String childResources[] = current.listResources();
resources = new String[childCollections.length + childResources.length];
//Collection child;
Permission perm;
final List<ResourceDescriptor> tableData = new ArrayList<ResourceDescriptor>(resources.length); // A list of ResourceDescriptor for the GUI
final String cols[] = new String[4];
int i = 0;
for (; i < childCollections.length; i++) {
//child = current.getChildCollection(childCollections[i]);
perm = mgtService.getSubCollectionPermissions(current, childCollections[i]);
if ("true".equals(properties.getProperty("permissions"))) {
cols[0] = perm.toString();
cols[1] = getOwnerName(perm);
cols[2] = getGroupName(perm);
cols[3] = URIUtils.urlDecodeUtf8(childCollections[i]);
resources[i] = 'd' + formatString(cols, colSizes);
} else {
resources[i] = URIUtils.urlDecodeUtf8(childCollections[i]);
}
final Date created = mgtService.getSubCollectionCreationTime(current, childCollections[i]);
if (startGUI) {
tableData.add( new ResourceDescriptor.Collection(
XmldbURI.create(childCollections[i]),
getOwnerName(perm),
getGroupName(perm),
"c" + ((perm instanceof ACLPermission && ((ACLPermission)perm).getACECount() > 0) ? perm.toString() + '+' : perm.toString()),
created ) );
}
completitions.add(childCollections[i]);
}
Resource res;
for (int j = 0; j < childResources.length; i++, j++) {
res = current.getResource(childResources[j]);
perm = mgtService.getPermissions(res);
if (perm == null) {
System.out.println("null"); //TODO this is not useful!
}
if ("true".equals(properties.getProperty("permissions"))) {
resources[i] = '-' + perm.toString() + '\t' + perm.getOwner().getName()
+ '\t' + perm.getGroup().getName() + '\t'
+ URIUtils.urlDecodeUtf8(childResources[j]);
} else {
resources[i] = URIUtils.urlDecodeUtf8(childResources[j]);
}
final Date lastModificationTime = ((EXistResource)res).getLastModificationTime();
resources[i] += "\t" + lastModificationTime;
if (startGUI) {
tableData.add(new ResourceDescriptor.Document(
XmldbURI.create(childResources[j]),
getOwnerName(perm),
getGroupName(perm),
"-" + ((perm instanceof ACLPermission && ((ACLPermission)perm).getACECount() > 0) ? perm.toString() + '+' : perm.toString()),
lastModificationTime ) );
}
completitions.add(childResources[j]);
}
if (startGUI) {