Examples of PutableResource


Examples of com.bradmcevoy.http.PutableResource

            CollectionResource col;
            col = getParent();
            if( col == null ) {
                throw new IOException( "parent not found" );
            } else if( col instanceof PutableResource ) {
                final PutableResource putableResource = (PutableResource) col;
                final String newName = path.getName();
                Runnable runnable = new Runnable() {

                    public void run() {
                        try {
                            putableResource.createNew( newName, out.getInputStream(), out.getSize(), null );
                        } catch( BadRequestException ex ) {
                            throw new RuntimeException( ex );
                        } catch( NotAuthorizedException ex ) {
                            throw new RuntimeException( ex );
                        } catch( ConflictException ex ) {
View Full Code Here

Examples of com.bradmcevoy.http.PutableResource

                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

Examples of com.bradmcevoy.http.PutableResource

        }

        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" );
                }
View Full Code Here

Examples of com.bradmcevoy.http.PutableResource

        if (rParent instanceof PutableResource) {
          log.trace("found parent resource, implements PutableResource");
          FileInputStream fin = null;
          try {
            fin = new FileInputStream(mergedFile);
            PutableResource putable = (PutableResource) rParent;
            putable.createNew(r.getName(), fin, mergedFile.length(), r.getContentType(null));
          } finally {
            StreamUtils.close(fin);
          }
        } else {
          throw new RuntimeException("Tried to update non-replaceable resource by doing createNew on parent, but the parent doesnt implement PutableResource. parent path: " + parentPath + " host: " + host + " parent type: " + rParent.getClass());
View Full Code Here

Examples of com.bradmcevoy.http.PutableResource

        }
        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 );
                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) {
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.