Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.Resource


    }

    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 + " for url: " + url + " and path: " + path );
        return r;
    }
View Full Code Here


    private Resource find( Path path ) {
        if( path.isRoot() ) {
            return ROOT;
        }
        Resource r = find( path.getParent() );
        if( r == null ) return null;
        if( r instanceof TFolderResource ) {
            TFolderResource folder = (TFolderResource) r;
            for( Resource rChild : folder.getChildren() ) {
                Resource r2 = rChild;
                if( r2.getName().equals( path.getName() ) ) {
                    return r2;
                }
            }
        }
        log.debug( "not found: " + path );
View Full Code Here

            String newHref = buildNewHref(href, newName);
            nf.setHref(newHref);
            newFiles.add(nf);
            log.debug("creating resource: " + newName + " size: " + file.getSize());
            InputStream in = null;
            Resource newResource;
            try {
                in = file.getInputStream();
                Resource existing = wrapped.child(newName);
                if( existing != null ) {
                    if( existing instanceof ReplaceableResource ) {
                        log.trace("existing resource is replaceable, so replace content");
                        ReplaceableResource rr = (ReplaceableResource) existing;
                        rr.replaceContent(in, null);
View Full Code Here

        }
        boolean nonBlankName = initialName != null && initialName.trim().length() > 0;
        boolean autoname = (parameters.get(PARAM_AUTONAME) != null);
        boolean overwrite = (parameters.get(PARAM_OVERWRITE) != null);
        if (nonBlankName) {
            Resource child = wrapped.child(initialName);
            if (child == null) {
                log.trace("no existing file with that name");
                return initialName;
            } else {
                if (overwrite) {
View Full Code Here

        }
        return col;
    }

    protected Result validate( CollectionResource cur, String newName ) {
        Resource existing = cur.child( newName );
        if( existing != null ) {
            return result( "An item of that name already exists. Is a: " + existing.getClass() );
        } else {
            return null;
        }
    }
View Full Code Here

        log.debug( "rename: " + srcPath + "->" + destName );

        Path pSrc = Path.path( srcPath );

        Cursor sourceCursor = cursor.find( pSrc );
        Resource target = sourceCursor.getResource();

        if( target == null ) {
            log.debug( "target not found: " + srcPath );
            return result( "target not found: " + srcPath );
        } else {
View Full Code Here

    public Resource getResource( String host, String path ) {
        log.debug( "path: " + path + " ::::::::::: consolePath:" + consolePath );
        if( path.startsWith( consolePath ) ) {
            path = stripConsolePath( path, consolePath );
            Resource secureResource = wrappedFactory.getResource( host, secureResourcePath );
            if( secureResource == null ) {
                throw new IllegalArgumentException( "Could not locate a resource to authorise against. path: " + secureResourcePath + " - resourceFactory: " + wrappedFactory.getClass() + " host: " + host );
            }
           
            if( path.endsWith( "index.html" ) ) {
View Full Code Here

        this.resultFormatter = resultFormatter;
    }

    @Override
    public Result execute() {
        Resource cur = currentResource();
        if( cur == null ) {
            return result("current dir not found: " + cursor.getPath().toString());
        }
        CollectionResource target;
        Cursor newCursor;
View Full Code Here

    public Result execute() {
        log.debug("execute");
        String sPath = args.get(0);
        Path path = Path.path(sPath);
        log.debug("cd path: " + path.toString());
        Resource r;
        Cursor c = cursor.find( path );
        if( !c.exists() ) {
            return result("not found: " + path);
        } else if( !c.isFolder()) {
            return result("not a folder: " + path);
View Full Code Here


    public Cursor find( Path newPath ) {
        log.debug( "find: " + newPath);
        Path lastPath;
        Resource child;
        if( newPath.isRelative() ) {
            child = getResource();
            lastPath = path;
        } else {
            lastPath = Path.root();
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.