Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.CollectionResource.child()


    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 {
View Full Code Here


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

        Path pDest = Path.path( dest );
        Resource rDestParent = resourceFactory.getResource( host, pDest.getParent().toString());
        if( rDestParent == null ) throw new BadRequestException( wrapped, "The destination parent does not exist");
        if(rDestParent instanceof CollectionResource ) {
            CollectionResource colDestParent = (CollectionResource) rDestParent;
            if( colDestParent.child( pDest.getName()) == null ) {
                try {
                    wrapped.copyTo( colDestParent, pDest.getName() );
                } catch( ConflictException ex ) {
                    log.warn( "Exception copying to: " + pDest.getName(), ex);
                    throw new BadRequestException( rDestParent, "conflict: " + ex.getMessage());
View Full Code Here

        }
        Resource rDestParent = resourceFactory.getResource( host, parentPath);
        if( rDestParent == null ) throw new BadRequestException( wrapped, "The destination parent does not exist");
        if(rDestParent instanceof CollectionResource ) {
            CollectionResource colDestParent = (CollectionResource) rDestParent;
            if( colDestParent.child( pDest.getName()) == null ) {
                try {
                    System.out.println("move to: " + colDestParent.getName());
                    wrapped.moveTo( colDestParent, pDest.getName() );
                } catch( ConflictException ex ) {
                    log.warn( "Exception copying to: " + pDest.getName(), ex);
View Full Code Here

        if( !cursor.isFolder() ) {
            return result("Couldnt find current folder");
        }
        CollectionResource cur = (CollectionResource) cursor.getResource();
        if( cur.child(newName) != null ) return result("File already exists: " + newName);

        if( cur instanceof PutableResource ) {
            PutableResource putable = (PutableResource) cur;
            try {
                putable.createNew( newName, inputStream, (long) content.length(), newName );
View Full Code Here

            } else if( p.equals( "." ) ) {
                // do nothing
            } else {               
                if( child instanceof CollectionResource ) {
                    CollectionResource col = (CollectionResource) child;
                    child = col.child( p );
                    lastPath = Path.path( lastPath, p );
                    if( child == null ) {
                        String s = "child " + p + " not found in folder " + lastPath;
                        return new Cursor( resourceFactory, host, lastPath, null, s);
                    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.