Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.GetableResource


        return false;
    }

    public long getSize() {
        if( r instanceof GetableResource ) {
            GetableResource gr = (GetableResource) r;
            Long ll = gr.getContentLength();
            if( ll == null ) return 0;
            return ll.longValue();
        } else {
            return 0;
        }
View Full Code Here


        }
    }

    public InputStream createInputStream( long offset ) throws IOException {
        if( r instanceof GetableResource ) {
            GetableResource gr = (GetableResource) r;
            String ct = gr.getContentType( null );
            BufferingOutputStream out = new BufferingOutputStream( 50000 );
            try {
                gr.sendContent( out, null, null, ct );
                out.close();
                return out.getInputStream();
            } catch( BadRequestException ex ) {
                log.warn( "bad request", ex );
                return null;
View Full Code Here

                    if( !( r instanceof CollectionResource ) ) {
                        el = writer().begin( "File" );
                        String nm = Utils.escapeXml( r.getName() );
                        el.writeAtt( "name", nm );
                        if( r instanceof GetableResource ) {
                            GetableResource gr = (GetableResource) r;
                            Long sz = gr.getContentLength();
                            String sSize = ( sz == null ? "" : sz.toString() );
                            el.writeAtt( "size", sSize );
                            el.noContent();
                        } else {
                            el.writeAtt( "size", "" );
View Full Code Here

    if( res == null) {
      String method = params.get(methodParamName);
      res = jsonResourceFactory.wrapResource(host, this, method, href);
    }
    if( res instanceof GetableResource) {
      GetableResource gr = (GetableResource) res;
      gr.sendContent(out, range, params, contentType);
    }
  }
View Full Code Here

            int i = path.lastIndexOf( suffix);
            String p2 = path.substring( 0, i);
            Resource r = wrapped.getResource( host, p2);
            if( r != null) {
                if( r instanceof GetableResource) {
                    GetableResource gr = (GetableResource) r;
                    Path pathFull = Path.path( path );
                    log.debug( "found an ajax resource, wrapping a: " + gr.getClass());
                    return new AjaxLoginResource( pathFull.getName(), gr );
                } else {
                    return r;
                }
            }
View Full Code Here

                if( newContentLength == null ) {
                    log.debug( "new content length is not available, cant check quota, reject" );
                    return StorageErrorReason.SER_QUOTA_EXCEEDED;
                }
                if( replaced instanceof GetableResource ) {
                    GetableResource gr = (GetableResource) replaced;
                    Long existingLength = gr.getContentLength();
                    if( existingLength == null ) {
                        log.debug( "existing content length cant be determined, cant check quota, reject");
                        return StorageErrorReason.SER_QUOTA_EXCEEDED;
                    } else {
                        long diff = existingLength - newContentLength;
                        if( diff > 0 ) {
                            return null;
                        } else {
                            log.debug( "new content is larger then existing content, but no quota is available, reject");
                            return StorageErrorReason.SER_QUOTA_EXCEEDED;
                        }
                    }
                } else {
                    log.debug( "existing content length cant be determined, cant check quota, reject");
                    return StorageErrorReason.SER_QUOTA_EXCEEDED;
                }
            } else {
                // difference of new content to existing must be less then available, but if in doubt allow
                Long newContentLength = request.getContentLengthHeader();
                if( newContentLength == null ) {
                    log.debug( "new content length is not available, cant check quota, allow" );
                    return null;
                }
                if( replaced instanceof GetableResource ) {
                    GetableResource gr = (GetableResource) replaced;
                    Long existingLength = gr.getContentLength();
                    if( existingLength == null ) {
                        log.debug( "existing content length cant be determined, cant check quota, allow");
                        return null;
                    } else {
                        long diff = newContentLength - existingLength; // this is the amount extra needed
View Full Code Here

    class ContentTypePropertyWriter implements StandardProperty<String> {

        public String getValue( PropFindableResource res ) {
            if( res instanceof GetableResource ) {
                GetableResource getable = (GetableResource) res;
                return getable.getContentType( null );
            } else {
                return "";
            }
        }
View Full Code Here

    class ContentLengthPropertyWriter implements StandardProperty<Long> {

        public Long getValue( PropFindableResource res ) {
            if( res instanceof GetableResource ) {
                GetableResource getable = (GetableResource) res;
                Long l = getable.getContentLength();
                return l;
            } else {
                return null;
            }
        }
View Full Code Here

      throws NotAuthorizedException, BadRequestException,
      ConflictException, NotFoundException {
    if (log.isTraceEnabled()) {
      log.trace("process: " + request.getAbsolutePath());
    }
    GetableResource r = (GetableResource) resource;
    if (checkIfNoneMatch(r, request)) {
      if (log.isTraceEnabled()) {
        log.trace("respond not modified with: "
            + responseHandler.getClass().getCanonicalName());
      }
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.GetableResource

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.