Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.Resource


    if ("".equals(betterUrl))
      return root;
   
    Key<WebdavFolder> rootKey = ofy.query(WebdavFolder.class).filter("parent", getKey(wu)).getKey();

    Resource res = getLastItem(rootKey, i, 0);
    return res;
  }
View Full Code Here


   
   
    public Resource getResource(String host, String url) {
        log.debug("getResource: url: " + url );
        Path path = Path.path(url);
        Resource r = find(path);
        log.debug("_found: " + r);
        return r;
    }
View Full Code Here

            }
        }
    }

    private Resource find( CollectionResource wrappedResource, Path p ) {
        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;
    }
View Full Code Here

        }

        void process() throws ConflictException {
            String relFolder = sFolder.substring( 1 );
            Path p = Path.path( relFolder );
            Resource r = find( wrappedResource, p );
            if( r instanceof CollectionResource ) {
                target = (CollectionResource) r;
            } else {
                log.warn("not found or not CollectionResource: " + r);
            }
View Full Code Here

        private void processFileUpload( FileItem f ) throws ConflictException {
            String sFolder = params.get( "CurrentFolder" );
            log.debug( "sFolder: " + sFolder + " - " + sFolder.length() );
            String relFolder = sFolder.substring( 1 );
            Path p = Path.path( relFolder );
            Resource r = find( wrappedResource, p );
            if( r instanceof PutableResource ) {
                target = (PutableResource) r;
            }
            if( target == null ) {
                log.warn( "No putable folder with that path: " + sFolder );
                throw new ConflictException( target );
            }

            String name = f.getName(); //utilFile().sanitiseName(f.getName());
            log.debug( "processFileUpload: " + name );
            boolean isFirst = true;
            while( target.child( name ) != null ) {
                name = FileUtils.incrementFileName( name, isFirst );
                newName = name;
                isFirst = false;
            }

            PutableResource putable;
            if( target instanceof PutableResource) {
                putable = (PutableResource) target;
            } else {
                log.warn("The collection is not putable: " + r.getName() + " - " + r.getClass().getCanonicalName());
                throw new ConflictException( r );
            }

            long size = f.getSize();
            try {
                Resource newRes = putable.createNew( name, f.getInputStream(), size, null );
            } catch( ConflictException ex ) {
                throw ex;
            } catch( NotAuthorizedException ex ) {
                throw new RuntimeException( ex );
            } catch( BadRequestException ex ) {
View Full Code Here

*/
public class TResourceFactoryFindTest {
  public static void main(String[] args)
  {
    TResourceFactory factory = new TResourceFactory();
    Resource resource = factory.getResource(null, "http://localhost:9080/calendarHome/calendarOne/");
    System.out.println("FOUND : "+resource);
  }
View Full Code Here

        }
    }
   

    private CollectionResource getParent( String host, Path path ) {
        Resource r = wrappedFactory.getResource( host, path.toString() );
        if( r instanceof CollectionResource ) {
            return (CollectionResource) r;
        } else {
            log.warn( "Could not locate a CollectionResource at: http://" + host + "/" + path);
            return null;
View Full Code Here

            NameAndAuthority naa = NameAndAuthority.parse( user );
            if( naa.domain == null ) {
                log.warn( "invalid login. no domain specified. use form: user#domain" );
                return null;
            }
            Resource hostRoot = resourceFactory.getResource( naa.domain, "/" );
            if( hostRoot == null ) {
                log.warn( "failed to find root for domain: " + naa.domain );
                return null;
            }

            Object oUser = hostRoot.authenticate( naa.toMilton(), password );
            if( oUser != null ) {
                return new MiltonUser( oUser, naa.toMilton(), naa.domain );
            } else {
                log.debug( "authentication failed: " + user );
                return null;
View Full Code Here

        return resourceFactory.getResource( host, path.toString() );
    }

    public FileSystemView createFileSystemView( User user ) throws FtpException {
        MiltonUser mu = (MiltonUser) user;
        Resource root = resourceFactory.getResource( mu.domain, "/" );
        return new MiltonFsView( Path.root, (CollectionResource) root, resourceFactory, (MiltonUser) user );
    }
View Full Code Here

        long size = f.getSize();
        try {
            if( target instanceof PutableResource ) {
                PutableResource putable = (PutableResource) target;
                Resource newRes = putable.createNew( name, f.getInputStream(), size, null );
                if( newRes != null ) {
                    log.trace( "created: " + newRes.getName() + " of type: " + newRes.getClass() );
                } else {
                    log.trace( "createNew returned null" );
                }
            } else {
                throw new BadRequestException(target, "Does not implement PutableResource");
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.