use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class MiltonFsView method getResource.
public ResourceAndPath getResource(Path p) throws NotAuthorizedException, BadRequestException {
log.debug("getResource: " + p);
if (p.isRelative()) {
p = Path.path(currentPath.toString() + '/' + p.toString());
Resource r = resourceFactory.getResource(user.domain, p.toString());
return new ResourceAndPath(r, p);
} else {
Resource r = resourceFactory.getResource(user.domain, p.toString());
return new ResourceAndPath(r, p);
}
}
use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class MiltonFtpAdapter method createFileSystemView.
@Override
public FileSystemView createFileSystemView(User user) throws FtpException {
MiltonUser mu = (MiltonUser) user;
Resource root;
try {
root = resourceFactory.getResource(mu.domain, "/");
} catch (NotAuthorizedException ex) {
throw new FtpException(ex);
} catch (BadRequestException ex) {
throw new FtpException(ex);
}
return new MiltonFsView(Path.root, (CollectionResource) root, resourceFactory, (MiltonUser) user);
}
use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class ResourceHandlerHelper method findClosestParent.
private Resource findClosestParent(HttpManager manager, String host, Path p) throws NotAuthorizedException, BadRequestException {
p = p.getParent();
if (p == null) {
return null;
}
Resource parent = manager.getResourceFactory().getResource(host, p.toString());
if (parent != null) {
return parent;
}
return findClosestParent(manager, host, p);
}
use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class WellKnownResourceFactory method getResource.
//
// public WellKnownResourceFactory(ResourceFactory wrapped) {
// this.wrapped = wrapped;
// }
@Override
public Resource getResource(String host, String sPath) throws NotAuthorizedException, BadRequestException {
if (sPath.startsWith(URI_PREFIX)) {
Path path = Path.path(sPath);
path = path.getStripFirst();
WellKnownHandler wellKnown = mapOfWellKnownHandlers.get(path.getFirst());
if (wellKnown != null) {
Resource hostRes = wrapped.getResource(host, "/");
if (hostRes != null) {
return wellKnown.locateWellKnownResource(hostRes);
}
}
}
return wrapped.getResource(host, sPath);
}
use of io.milton.resource.Resource in project lobcder by skoulouzis.
the class LockHandler method processNonExistingResource.
private void processNonExistingResource(HttpManager manager, Request request, Response response, String host, String url) throws NotAuthorizedException, BadRequestException {
String name;
Path parentPath = Path.path(url);
name = parentPath.getName();
parentPath = parentPath.getParent();
url = parentPath.toString();
Resource r = manager.getResourceFactory().getResource(host, url);
if (r != null) {
if (!handlerHelper.checkAuthorisation(manager, r, request)) {
responseHandler.respondUnauthorised(r, response, request);
return;
} else {
processCreateAndLock(manager, request, response, r, name);
}
} else {
// log.debug("couldnt find parent to execute lock-null, returning not found");
// respondNotFound(response,request);
response.setStatus(Status.SC_CONFLICT);
}
}
Aggregations