Search in sources :

Example 21 with Resource

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);
    }
}
Also used : CollectionResource(io.milton.resource.CollectionResource) Resource(io.milton.resource.Resource)

Example 22 with Resource

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);
}
Also used : CollectionResource(io.milton.resource.CollectionResource) Resource(io.milton.resource.Resource) BadRequestException(io.milton.http.exceptions.BadRequestException) FtpException(org.apache.ftpserver.ftplet.FtpException) NotAuthorizedException(io.milton.http.exceptions.NotAuthorizedException)

Example 23 with Resource

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);
}
Also used : Resource(io.milton.resource.Resource)

Example 24 with Resource

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);
}
Also used : Path(io.milton.common.Path) Resource(io.milton.resource.Resource)

Example 25 with Resource

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);
    }
}
Also used : Path(io.milton.common.Path) LockingCollectionResource(io.milton.resource.LockingCollectionResource) Resource(io.milton.resource.Resource) LockableResource(io.milton.resource.LockableResource)

Aggregations

Resource (io.milton.resource.Resource)37 CollectionResource (io.milton.resource.CollectionResource)23 BadRequestException (io.milton.http.exceptions.BadRequestException)11 NotAuthorizedException (io.milton.http.exceptions.NotAuthorizedException)10 Path (io.milton.common.Path)9 MakeCollectionableResource (io.milton.resource.MakeCollectionableResource)8 PutableResource (io.milton.resource.PutableResource)8 GetableResource (io.milton.resource.GetableResource)7 ConflictException (io.milton.http.exceptions.ConflictException)6 ReplaceableResource (io.milton.resource.ReplaceableResource)6 DeletableResource (io.milton.resource.DeletableResource)5 PostableResource (io.milton.resource.PostableResource)4 IOException (java.io.IOException)4 PutEvent (io.milton.event.PutEvent)3 LockableResource (io.milton.resource.LockableResource)3 PropFindableResource (io.milton.resource.PropFindableResource)3 NewFolderEvent (io.milton.event.NewFolderEvent)2 CopyableResource (io.milton.resource.CopyableResource)2 LockingCollectionResource (io.milton.resource.LockingCollectionResource)2 MoveableResource (io.milton.resource.MoveableResource)2