use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class ResourceList method getRandom.
public Resource getRandom() {
int l = this.size();
if (l == 0) {
return null;
}
List<Resource> list = new ArrayList<Resource>();
for (Resource res : this) {
list.add(res);
}
if (list.isEmpty()) {
return null;
}
Random rnd = new Random();
int pos = rnd.nextInt(list.size());
return list.get(pos);
}
use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class FckFileManagerResource method find.
private Resource find(CollectionResource wrappedResource, Path p) throws NotAuthorizedException, BadRequestException {
Resource r = wrappedResource;
for (String s : p.getParts()) {
if (r instanceof CollectionResource) {
CollectionResource col = (CollectionResource) r;
r = col.child(s);
if (r == null) {
log.trace("not found: " + s + " in path: " + p);
return null;
}
} else {
log.trace("not a collection: " + r.getName() + " in path: " + p);
return null;
}
}
return r;
}
Aggregations