Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.HTTPException


      return reply;
  }
  Reply error = request.makeReply(HTTP.NOT_ALLOWED) ;
  error.setHeaderValue(Reply.H_ALLOW, getAllow());
  error.setContent("Method POST not allowed on this resource.") ;
  throw new HTTPException (error) ;
    }
View Full Code Here


    protected Reply putOtherResource(Request request)
  throws ProtocolException
    {
  Reply error = request.makeReply(HTTP.NOT_IMPLEMENTED) ;
  error.setContent("Method PUT not implemented.") ;
  throw new HTTPException (error) ;
    }
View Full Code Here

  // Is this resource writable ?
  if ( ! getPutableFlag() ) {
      Reply error = request.makeReply(HTTP.NOT_ALLOWED) ;
      error.setHeaderValue(Reply.H_ALLOW, getAllow());
      error.setContent("Method PUT not allowed.") ;
      throw new HTTPException (error) ;
  }
  // Check validators:
  int cim = checkIfMatch(request)
  if ((cim == COND_FAILED) || (cim == COND_WEAK)
      || (checkIfNoneMatch(request) == COND_FAILED)
      || (checkIfModifiedSince(request) == COND_FAILED)
      || (checkIfUnmodifiedSince(request) == COND_FAILED)) {
      Reply r = request.makeReply(HTTP.PRECONDITION_FAILED);
      r.setContent("Pre-condition failed.");
      return r;
  }
  // Check the request:
  InputStream in = null;
  try {
      in = request.getInputStream();
      if ( in == null ) {
    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.NOT_IMPLEMENTED);
      error.setContent("partial PUT not supported.");
      throw new HTTPException(error);
  }
// REMOVED as it is impossile for clients to behave properly.
// Of course it is fare more unsafe now, but it was too impractical IRL.
  // Check that if some type is provided it doesn't conflict:
//  if ( request.hasContentType() ) {
//      MimeType rtype = request.getContentType() ;
//      MimeType type  = getContentType() ;
//      if ( type == null ) {
//    setValue (ATTR_CONTENT_TYPE, rtype) ;
//      } else if ( (rtype.match (type) < 0 ) && !rtype.equiv(type) ) {
//    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: "+rtype.toString()
//          + " is not matching resource MIME type: "
//          +type.toString());
//    throw new HTTPException (error) ;
//      }
//  }
  // 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 ) {
    // FIXME we should check for "100-continue" explicitely
    client.sendContinue();
      }
      if ( fresource.newContent(request.getInputStream()) )
    status = HTTP.CREATED;
      else
    status = HTTP.NO_CONTENT;
  } catch (IOException ex) {
      if (debug)
    ex.printStackTrace();
      // so we have a problem replacing or creating the content
      // it is then a configuration problem (access right for the
      // underlying fle resource for example...
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setReason("File Access Error");
      error.setContent("<p>Unable to save " + request.getURL()
           +" due to IO problems");
      throw new HTTPException (error) ;     
  }
  if ( status == HTTP.CREATED ) {
      reply = request.makeReply(status);
      reply.setContent("<P>Resource succesfully created");
      if (request.hasState(STATE_CONTENT_LOCATION))
View Full Code Here

      }
  } else {
      Reply error = request.makeReply(HTTP.NOT_ALLOWED) ;
      error.setContent("Method DELETE not allowed.") ;
      error.setHeaderValue(Reply.H_ALLOW, getAllow());
      throw new HTTPException (error) ;
  }
    }
View Full Code Here

  } catch (MultipleLockException ex) {
      Reply error = request.makeReply(HTTP.FORBIDDEN);
      error.setContent("Can't delete resource: "+
           resource.getIdentifier()+
           " is locked. Try again later.");
      throw new HTTPException(error);
  }
  olddir.renameTo(newdir);
  return request.makeReply(HTTP.NO_CONTENT);
    }
View Full Code Here

  } catch (MultipleLockException ex) {
      Reply error = request.makeReply(HTTP.FORBIDDEN);
      error.setContent("Can't delete resource: "+
           resource.getIdentifier()+
           " is locked. Try again later.");
      throw new HTTPException(error);
  }
  oldfile.renameTo(newfile);
  return request.makeReply(HTTP.NO_CONTENT);
    }
View Full Code Here

    error.setContent ("<h1>Document not found</h1>"+
          "<p>The document "+
          request.getURL()+
          " is indexed but not available."+
          "<p>The server is misconfigured.") ;
    throw new HTTPException (error) ;
      }
      // Have we already an up-to-date computed a listing ?
      if ((listing == null)
    || (dirResource.getDirectory().lastModified() > listing_stamp)
    || (dirResource.getLastModified() > listing_stamp)
View Full Code Here

           " met by the resource");
      return reply;
  }
  Reply error = request.makeReply(HTTP.NOT_IMPLEMENTED) ;
  error.setContent("Method DELETE not implemented.") ;
  throw new HTTPException (error) ;
    }
View Full Code Here

           " met by the resource");
      return reply;
  }
  Reply error = request.makeReply(HTTP.NOT_IMPLEMENTED) ;
  error.setContent("Method LINK not implemented.") ;
  throw new HTTPException (error) ;
    }
View Full Code Here

           " met by the resource");
      return reply;
  }
  Reply error = request.makeReply(HTTP.NOT_IMPLEMENTED) ;
  error.setContent("Method UNLINK not implemented.") ;
  throw new HTTPException (error) ;
    }
View Full Code Here

TOP

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

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.