Package com.bradmcevoy.common

Examples of com.bradmcevoy.common.Path


    }
   
   
    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


        this.wrapped = copyableResource;
        this.resourceFactory = resourceFactory;
    }
    public String processForm( Map<String, String> parameters, Map<String, FileItem> files ) throws BadRequestException, NotAuthorizedException {
        String dest = parameters.get( "destination");
        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());
                }
                return null;
            } else {
                log.warn( "destination already exists: " + pDest.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

    }
    return r;
  }

  public File resolvePath(File root, String url) {
    Path path = Path.path(url);
    File f = root;
    for (String s : path.getParts()) {
      f = new File(f, s);
    }
    return f;
  }
View Full Code Here

                    return result( "conflict exception: " + ex.getMessage() );
                } catch( NotAuthorizedException ex ) {
                    log.debug( "ex", ex );
                    return result( "you are not authorized to create a folder here: " + ex.getMessage() );
                }
                Path newPath = cursor.getPath().child( newName );
                return new Result( cursor.getPath().toString(), "created: <a href='" + newPath + "'>" + newCol.getName() + "</a>" );
            } else {
                return result( "current dir does not support creating child collections: " + cursor.getPath() );
            }
        }
View Full Code Here

    public Result execute() {
        String srcPath = args.get( 0 );
        String destName = args.get( 1 );
        log.debug( "rename: " + srcPath + "->" + destName );

        Path pSrc = Path.path( srcPath );

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

        if( target == null ) {
View Full Code Here

        if( cur instanceof PutableResource ) {
            PutableResource putable = (PutableResource) cur;
            try {
                putable.createNew( newName, inputStream, (long) content.length(), newName );
                Path newPath = cursor.getPath().child( newName );
                return result( "created <a href='" + newPath + "'>" + newName + "</a>");
            } catch(BadRequestException e) {
                return result("bad request exception");
            } catch(NotAuthorizedException ex) {
                return result("not authorised");
View Full Code Here

    }

    @Override
    public Result execute() {
        String sPath = args.get( 0 );
        Path path = Path.path( sPath );

        Cursor sourceCursor = cursor.find( path );

        if( !sourceCursor.exists() ) {
            // try regex
View Full Code Here

    @Override
    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()) {
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();
            child = host();
        }
        for( String p : newPath.getParts() ) {
            if( p.equals( ".." ) ) {
                lastPath = lastPath.getParent();
                if( lastPath != null ) {
                    child = resourceFactory.getResource( host, lastPath.toString() );
                } else {
                    child = null;
                }
            } else if( p.equals( "." ) ) {
                // do nothing
View Full Code Here

    public Result execute() {
        String srcPath = args.get( 0 );
        String destPath = args.get( 1 );
        log.debug( "copy: " + srcPath + "->" + destPath );

        Path pSrc = Path.path( srcPath );
        Path pDest = Path.path( destPath );

        Cursor sourceCursor = cursor.find( pSrc );
        Cursor destCursor = cursor.find( pDest );
        if( !sourceCursor.exists() ) {
            List<Resource> list = sourceCursor.getParent().childrenWithFilter( sourceCursor.getPath().getName() );
View Full Code Here

TOP

Related Classes of com.bradmcevoy.common.Path

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.