Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.CollectionResource


        if( r == null ) {
            throw new RuntimeException( "resource not saved yet" );
        } else if( r instanceof MoveableResource ) {
            MoveableResource src = (MoveableResource) r;
            MiltonFtpFile dest = (MiltonFtpFile) newFile;
            CollectionResource crDest;
            crDest = dest.getParent();
            String newName = dest.path.getName();
            try {
                src.moveTo( crDest, newName );
                return true;
View Full Code Here


    public List<FtpFile> listFiles() {
        log.debug( "listfiles" );
        List<FtpFile> list = new ArrayList<FtpFile>();
        if( r instanceof CollectionResource ) {
            CollectionResource cr = (CollectionResource) r;
            for( Resource child : cr.getChildren() ) {
                list.add( ftpFactory.wrap( path.child( child.getName() ), child ) );
            }
        }
        return list;
    }
View Full Code Here

                }
            };
            out.setOnClose( runnable );
            return out;
        } else {
            CollectionResource col;
            col = getParent();
            if( col == null ) {
                throw new IOException( "parent not found" );
            } else if( col instanceof PutableResource ) {
                final PutableResource putableResource = (PutableResource) col;
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 {
View Full Code Here

                    log.debug( "has child" );
                    errNumber = 101;
                } else {
                    if( target instanceof MakeCollectionableResource ) {
                        MakeCollectionableResource mk = (MakeCollectionableResource) target;
                        CollectionResource f = mk.createCollection( newFolderName );
                    } else {
                        throw new BadRequestException( target, "Folder does not allow creating subfolders" );
                    }
                    log.debug( "add new child ok" );
                    errNumber = 0;
View Full Code Here

    @Override
    public Resource getResource(String host, String url) {
        Path path = Path.path(url);
        if (FckFileManagerResource.URL.equals(path)) {
            CollectionResource h = getParent(host, path.getParent());
            if( h == null ) return null;
            FckFileManagerResource fck = new FckFileManagerResource(h);
            return fck;
        } else if (FckQuickUploaderResource.URL.equals(path)) {
            CollectionResource h = getParent(host, path.getParent());
            if( h == null ) return null;
            FckQuickUploaderResource fck = new FckQuickUploaderResource(h);
            return fck;
        } else {
            return null;
View Full Code Here

        }
        return null;
    }

    private void processFileUpload( FileItem f, Map<String, String> params ) throws BadRequestException {
        CollectionResource target = null;
        if( wrappedResource == null ) {
            throw new BadRequestException(this, "collection not found" );
        }
        target = (CollectionResource) wrappedResource.child( "uploads" );
        if( target == null ) {
            try {
                if( wrappedResource instanceof MakeCollectionableResource ) {
                    MakeCollectionableResource mk = (MakeCollectionableResource) wrappedResource;
                    target = mk.createCollection( "uploads" );
                } else {
                    throw new BadRequestException( target, "Cant create subfolder" );
                }
            } catch( ConflictException ex ) {
                throw new RuntimeException( ex );
            } catch( NotAuthorizedException ex ) {
                throw new RuntimeException( ex );
            } catch( BadRequestException ex ) {
                throw new RuntimeException( ex );
            }
        }

        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

        errorProperties.put(Status.SC_NOT_FOUND, unknownProperties);
        PropFindResponse r = new PropFindResponse(href, knownProperties, errorProperties);
        responses.add(r);

        if (requestedDepth > currentDepth && resource instanceof CollectionResource) {
            CollectionResource col = (CollectionResource) resource;
            List<? extends Resource> list = col.getChildren();
            list = new ArrayList<Resource>(list);
            for (Resource child : list) {
                if (child instanceof PropFindableResource) {
                    String childName = child.getName();
                    if (childName == null) {
View Full Code Here

        this.href = href;
    }

    public String processForm( Map<String, String> parameters, Map<String, FileItem> files ) throws BadRequestException, NotAuthorizedException {
        try {
            CollectionResource col = wrapped.createCollection( parameters.get( "name" ) );
            if( eventManager != null ) {
                eventManager.fireEvent( new NewFolderEvent( col ) );
            }
            return null;
        } catch( ConflictException ex ) {
View Full Code Here

            parentPath = pDest.getParent().toString();
        }
        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);
                    throw new BadRequestException( rDestParent, "conflict: " + ex.getMessage());
                }
                return null;
            } else {
                log.warn( "destination already exists: " + pDest.getName() + " in folder: " + colDestParent.getName());
                throw new BadRequestException( rDestParent, "File already exists");
            }
        } else {
            throw new BadRequestException( wrapped, "The destination parent is not a collection resource");
        }
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.CollectionResource

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.