Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.ClientException


    Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
    error.setContent ("<p>Request doesn't have a valid content.");
    throw new HTTPException (error) ;
      }
  } catch (IOException ex) {
      throw new ClientException(request.getClient(), ex);
  }
  // We do not support (for the time being) put with ranges:
  if ( request.hasContentRange() ) {
      Reply error = request.makeReply(HTTP.BAD_REQUEST);
      error.setContent("partial PUT not supported.");
      throw new HTTPException(error);
  }
  // Check that if some type is provided it doesn't conflict:
  if ( request.hasContentType() ) {
      MimeType rtype = request.getContentType() ;
      MimeType type  = getCommentType() ;
      if ( type == null ) {
    setValue (ATTR_CONTENT_TYPE, rtype) ;
      } else if ( rtype.match (type) < 0 ) {
    if (debug) {
        System.out.println("No match between: ["+
               rtype.toString()+"] and ["+
               type.toString()+"]");
    }
    Reply error = request.makeReply(HTTP.UNSUPPORTED_MEDIA_TYPE) ;
    error.setContent ("<p>Invalid content type: "+type.toString());
    throw new HTTPException (error) ;
      }
  }
  ImageFileResource ifresource = (ImageFileResource) fresource;
  // Write the body back to the file:
  try {
      // We are about to accept the put, notify client before continuing
      Client client = request.getClient();
      if ( client != null  && request.getExpect() != null ) {
    client.sendContinue();
      }
      if ( ifresource.newMetadataContent(request.getInputStream()) )
    status = HTTP.CREATED;
      else
    status = HTTP.NO_CONTENT;
  } catch (IOException ex) {
      throw new ClientException(request.getClient(), ex);
  }
  if ( status == HTTP.CREATED ) {
      reply = createCommentReply(request, status);
      reply.setContent("<P>Resource succesfully created");
      if (request.hasState(STATE_CONTENT_LOCATION))
View Full Code Here


         "form data.") ;
    throw new HTTPException (error) ;
      } catch (IOException ex) {
    Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
    error.setContent("Invalid request: unable to read form data.");
    throw new ClientException(request.getClient(), ex) ;
      }
  }
  // Handle the stuff:
  return handle (request, dec) ;
    }
View Full Code Here

    Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
    error.setContent ("<p>Request doesn't have a valid content.");
    throw new HTTPException (error) ;
      }
  } catch (IOException ex) {
      throw new ClientException(request.getClient(), ex);
  }
  // We do not support (for the time being) put with ranges:
  if ( request.hasContentRange() ) {
      Reply error = request.makeReply(HTTP.BAD_REQUEST);
      error.setContent("partial PUT not supported.");
      throw new HTTPException(error);
  }
  // Check that if some type is provided it doesn't conflict:
  if ( request.hasContentType() ) {
      MimeType rtype = request.getContentType() ;
      MimeType type  = xmptype ;
      if ( type == null ) {
    setValue (ATTR_CONTENT_TYPE, rtype) ;
      } else if ( rtype.match (type) < 0 ) {
    if (debug) {
        System.out.println("No match between: ["+
               rtype.toString()+"] and ["+
               type.toString()+"]");
    }
    Reply error = request.makeReply(HTTP.UNSUPPORTED_MEDIA_TYPE) ;
    error.setContent ("<p>Invalid content type: "+type.toString());
    throw new HTTPException (error) ;
      }
  }
  ImageFileResource ifresource = (ImageFileResource) fresource;
  // Write the body back to the file:
  try {
      // We are about to accept the put, notify client before continuing
      Client client = request.getClient();
      if ( client != null  && request.getExpect() != null ) {
    client.sendContinue();
      }
      if ( ifresource.newMetadataContent(request.getInputStream()) )
    status = HTTP.CREATED;
      else
    status = HTTP.NO_CONTENT;
  } catch (IOException ex) {
      throw new ClientException(request.getClient(), ex);
  }
  if ( status == HTTP.CREATED ) {
      reply = createXMPReply(request, status);
      reply.setContent("<P>Resource succesfully created");
      if (request.hasState(STATE_CONTENT_LOCATION))
View Full Code Here

TOP

Related Classes of org.w3c.jigsaw.http.ClientException

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.