Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.HTTPException


    private HTTPException notYetImplemented(DAVRequest request)
  throws ProtocolException
    {
  Reply error = request.makeReply(HTTP.NOT_IMPLEMENTED) ;
  error.setContent("Method "+request.getMethod()+" not implemented.") ;
  throw new HTTPException (error);
    }
View Full Code Here


          default:
        // error
        Reply error =
            request.makeReply(HTTP.BAD_REQUEST);
        error.setContent("Invalid request");
        throw new HTTPException (error);
          }
      if (dps != null) {
          dr.addDAVNode(dps);
      }
        }
        saveDeadProperties();
    } catch (DAVPropertyException ex) {
        // stop all an undo change
        reloadDeadProperties();
        this.values = oldvalues;
        // report error
        DAVPropStat dpss[] = (DAVPropStat[])ex.getReason();
        for (int j = 0 ; j < dpss.length ; j++) {
      dr.addDAVNode(dpss[j]);
        }
        dr.setDescription(ex.getMessage());
    }
    return createDAVReply(request,
              WEBDAV.MULTI_STATUS,
              document);
      }
  }
  Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
  error.setContent("Invalid request");
  throw new HTTPException (error);
    }
View Full Code Here

        if (rr == null) {
      Reply error =
          request.makeReply(HTTP.UNSUPPORTED_MEDIA_TYPE);
      error.setContent("Failed to create collection "+
           newcol);
      throw new HTTPException (error);
        } else {
      Reply reply = request.makeReply(HTTP.CREATED);
      reply.setContent("<P>Collection "+newcol+
           " succesfully created");
     
      return reply;
        }
    } else {
        Reply error = request.makeReply(HTTP.FORBIDDEN);
        error.setContent("The server doen't allow collection "+
             "creation here.");
        throw new HTTPException (error);
    }
      } else {
    Reply error = request.makeReply(HTTP.NOT_ALLOWED);
    error.setContent(dresource.getIdentifier()+
         " already exists!");
    throw new HTTPException (error);
      }
  } else {
      Reply error = request.makeReply(HTTP.NOT_ALLOWED);
      error.setContent(dresource.getIdentifier()+" already exists!");
      throw new HTTPException (error);
  }
    }
View Full Code Here

      rep = (DAVReply) getServer().perform(req);
      closeInternalReply(rep);
  } catch (Exception ex) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent(ex.getMessage());
      throw new HTTPException(error);
  }
  boolean overwrite = false;
  if (rep.getStatus() != HTTP.NOT_FOUND) {
      overwrite = request.getOverwrite();
      if (! overwrite) {
    // 412 Precondition failed
    String msg = "The state of the destination is non-null";
    Reply error = request.makeReply(HTTP.PRECONDITION_FAILED) ;
    error.setContent(msg);
    return error;
      } else {
    // overwrite but DELETE before
    req = createInternalRequest(request, "DELETE", dst, null);
    try {
        rep = (DAVReply) getServer().perform(req);
        closeInternalReply(rep);
    } catch (Exception ex) {
        Reply error =
      request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
        error.setContent(ex.getMessage());
        throw new HTTPException(error);
    }
    // silent error, if delete failed try to overwrite...
      }
  }
  // ok, perform the real copy now
View Full Code Here

      creply = manager.runDAVRequest(crequest);
      skipBody(creply);
  } catch (org.w3c.www.protocol.http.HttpException ex) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent(ex.getMessage());
      throw new HTTPException (error);
  }
  if (creply.getStatus() != HTTP.CREATED) {
      return dupReply(request, creply, false);
  }
  org.w3c.www.protocol.webdav.DAVReply mkcolreply = creply;
  // Copy Properties
  copyProperties(request, destination, body);
  // CHILDREN? (Depth can only be 0 or infinity see RFC 2518 - 8.8.3)
  if (request.getDepth() == 0) {
      // only me so return
      return dupReply(request, creply, overwrite);
  } else {
      // XML Document
      DAVMultiStatus dms =
    DAVFactory.createMultiStatus(document.getDocumentElement());
      boolean multistatus = false;
      // Children resource
      Enumeration       e = dresource.enumerateResourceIdentifiers();
      ResourceReference rr   = null;
      FramedResource    fr   = null;
      while (e.hasMoreElements()) {
    String name = (String)e.nextElement();
    rr = dresource.lookup(name);
    if (rr != null) {
        try {
      fr = (FramedResource) rr.lock();
      if (fr == resource) { // for root
          continue;
      }
      DAVFrame df   = (DAVFrame)fr.getFrame(DAVFrame.class);
      URL      dest = null;
      if (df != null) {
          try {
        dest = computeDestURL(destination, df);
          } catch (MalformedURLException ex) {
        Reply error =
        request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
        String msg = "Can't build destination URI : "+
            ex.getMessage();
        error.setContent(msg);
        throw new HTTPException(error);
          }
          if (df.isCollection()) {
        try {
            // silent success
            df.copyCollection(dest,
View Full Code Here

      creply = (DAVReply) getServer().perform(crequest);
      closeInternalReply(creply);
  } catch (Exception ex) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent(ex.getMessage());
      throw new HTTPException (error);
  }
  if (creply.getStatus() != HTTP.CREATED) {
      return creply;
  }
  DAVReply mkcolreply = creply;
  // Copy Properties
  internalCopyProperties(request, destination, body);
  // CHILDREN? (Depth can only be 0 or infinity see RFC 2518 - 8.8.3)
  if (request.getDepth() == 0) {
      // only me so return
      if (overwrite) {
    creply.setStatus(HTTP.NO_CONTENT);
      }
      return creply;
  } else {
      // XML Document
      DAVMultiStatus dms =
    DAVFactory.createMultiStatus(document.getDocumentElement());
      boolean multistatus = false;
      // Children resource
      Enumeration       e = dresource.enumerateResourceIdentifiers();
      ResourceReference rr   = null;
      FramedResource    fr   = null;
      while (e.hasMoreElements()) {
    String name = (String)e.nextElement();
    rr = dresource.lookup(name);
    if (rr != null) {
        try {
      fr = (FramedResource) rr.lock();
      if (fr == resource) { // for root
          continue;
      }
      DAVFrame df   = (DAVFrame)fr.getFrame(DAVFrame.class);
      URL      dest = null;
      if (df != null) {
          try {
        dest = computeDestURL(destination, df);
          } catch (MalformedURLException ex) {
        Reply error =
        request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
        String msg = "Can't build destination URI : "+
            ex.getMessage();
        error.setContent(msg);
        throw new HTTPException(error);
          }
          if (df.isCollection()) {
        try {
            // silent success
            df.internalCopyCollection(dest,
View Full Code Here

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

    return ok;
      }
      // bad request
      Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
      error.setContent("Invalid request: missing lockinfo");
      throw new HTTPException (error);
  }
    }
View Full Code Here

      (ResourceReference) request.getState(LOCKED_REREFENCE);
        if (rr == null) {
      Reply error =
          request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent("Unable to unlock, no request state");
      throw new HTTPException(error);
        } else {
      try {
          DAVFrame fr = (DAVFrame)rr.lock();
          fr.unlock();
      } catch (Exception ex) {
          ex.printStackTrace();
          Reply error =
        request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
          error.setContent(ex.getMessage());
          throw new HTTPException(error);
      } finally {
          rr.unlock();
      }
        }
    }
    return request.makeReply(HTTP.NO_CONTENT);
      } else {
    Reply reply = request.makeReply(WEBDAV.LOCKED);
    reply.setContent("The resource is locked");
    return reply;
      }
  }
  // sorry
  Reply error = request.makeReply(HTTP.FORBIDDEN) ;
  error.setContent("You are not allowed to unlock this resource");
  throw new HTTPException (error);
    }
View Full Code Here

             "Failed to create resource "+
             name +" : "+
             "Unable to create the appropriate file:"+
             request.getURLPath()+
             " this media type is not supported");
          throw new HTTPException (error);
      }
        } else { //FORBIDDEN IN WEBDAV
      Reply error = request.makeReply(HTTP.CONFLICT) ;
      error.setContent(name +" does not exists!");
      throw new HTTPException (error);
        }
    } else if (rr == null) {
        Reply error = request.makeReply(HTTP.FORBIDDEN) ;
        error.setContent("You are not allowed to create resource "+
             name +" : "+
             dresource.getIdentifier()+
             " is not extensible.");
        throw new HTTPException (error);
    }
      } else if (request.getMethod().equals("MKCOL")) {
    String            name = ls.peekNextComponent() ;
    ResourceReference rr   = dresource.lookup(name);
    if (rr == null) {
        if (ls.countRemainingComponents() == 1) {
      request.setState(REMAINING_PATH, name);
      return true;
        } else {
      Reply error = request.makeReply(HTTP.CONFLICT) ;
      error.setContent("Can't create "+
           ls.getRemainingPath(true));
      throw new HTTPException (error);
        }
    }
      }
  }
  // normal lookup
  if ( super.lookupOther(ls, lr) ) {
      if ( ! ls.isDirectory() && ! ls.isInternal() ) {
    // The directory lookup URL doesn't end with a slash:
    if ( request == null ) {
        lr.setTarget(null);
        return true;
    } else if (! acceptRedirect(request)) {
        return true;
    }
    URL url = null;
    try {
        if ((request != null ) &&
      request.hasState(Request.ORIG_URL_STATE)) {
      URL oldurl;
      oldurl = (URL)request.getState(Request.ORIG_URL_STATE);
      url = new URL(oldurl, oldurl.getFile() + "/");
        } else {
      url = (ls.hasRequest()
             ? getURL(request)
             : new URL(getServer().getURL(),
           resource.getURLPath()));
        }
    } catch (MalformedURLException ex) {
        getServer().errlog(this, "unable to build full URL.");
        throw new HTTPException("Internal server error");
    }
    String msg = "Invalid requested URL: the directory resource "+
        " you are trying to reach is available only through "+
        " its full URL: <a href=\""+
        url + "\">" + url + "</a>.";
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.