Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.HTTPException


    d.parse () ;
      } catch (URLDecoderException e) {
    Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
    error.setContent("Invalid request: "+
         "unable to decode form data.");
    throw new HTTPException (error) ;
      } catch (IOException e) {
    Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
    error.setContent("Invalid request: unable to read form data.");
    throw new HTTPException (error) ;
      }
      return handle (request, d) ;
  }
  Reply reply = createDefaultReply(request, HTTP.OK);
  PageCompileOutputStream out = new PageCompileOutputStream();
View Full Code Here


  } else if ( format.equals ("signed") ) {
      return LabelBureauInterface.FMT_SIGNED ;
  }
  Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
  error.setContent ("Unknown label format: "+format);
  throw new HTTPException (error) ;
    }
View Full Code Here

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

    {
  if (labelb == null) {
      Reply reply = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
      reply.setContent("LabelBureauFrame not configured properly: "+
           "must be attached to a LabelBureauResource.");
      throw new HTTPException(reply);
  }
  // Get opt (only generic/normal/insert)
  String opt        = data.getValue("opt") ;
  String urls[]     = parseURLs (data.getMultipleValues ("u")) ;
  int    iformat   = parseFormat(request,data.getValue("format"));
  String services[] = parseURLs (data.getMultipleValues ("s")) ;
  if (services == null)
      services = labelb.getServices();
  if ((services == null) || (services.length == 0))
      return labelb.makePICSErrorReply(request,
             "no-ratings \"unknown service\"");
  // Perform request
  if (labelb.getDebugFlag()) {
      System.out.println("******** PICS REQUEST ********");
      System.out.println("opt      : "+opt);
      System.out.println("format   : "+data.getValue("format"));
      System.out.print("services : ");
      for (int i=0; i < services.length; i++)
    System.out.println(services[i]);
      System.out.print("urls     : ");
      for (int i=0; i < urls.length; i++)
    System.out.println(urls[i]);
      System.out.println("******************************");
  }
  if ( opt.equals ("generic") ) {
      return labelb.getGenericLabels (request, iformat,
              urls, services, data) ;
  } else if ( opt.equals ("normal") ) {
      return labelb.getNormalLabels (request, iformat, urls,
             services, data) ;
  } else if ( opt.equals ("tree") ) {
      return labelb.getTreeLabels (request, iformat, urls,
           services, data) ;
  } else  if ( opt.equals ("generic+tree") ) {
      return labelb.getGenericTreeLabels(request,iformat,
                 urls, services, data);
  } else {
      Reply error = request.makeReply(HTTP.BAD_REQUEST);
      error.setContent ("Invalid label bureau query, bad option: "+opt);
      throw new HTTPException (error) ;
  }
    }
View Full Code Here

  String method = request.getMethod();
  if (method.equals("DELETE")) {
      Reply error = request.makeReply(HTTP.FORBIDDEN);
      error.setContent("DELETE is forbidden on CVS controlled"+
           " directories in this version of JigEdit");
      throw new HTTPException (error);
  }
  return super.delete(request);
    }
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 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

        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) ;
    }
    refresh =
      (dresource.getDirectory().lastModified() >
                                             listing_stamp);
      }
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 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);
    }
      }
  }
  if ( super.lookup(ls, lr) ) {
      if ( ! ls.isDirectory() && ! ls.isInternal() ) {
    // The directory lookup URL doesn't end with a slash:
    Request request = (Request)ls.getRequest() ;
    if ( request == null ) {
        lr.setTarget(null);
        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

      return getDirectoryResource(request);
  } else {
      // we don't manage this kind of resource
      Reply error = request.makeReply(HTTP.NOT_IMPLEMENTED) ;
      error.setContent("Method GET not implemented.") ;
      throw new HTTPException (error) ;
  }
    }
View Full Code Here

    error.setContent ("<h1>Document Gone</h1>"+
          "<p>The document "+
          request.getURL()+
          " is indexed but no longer available.</p>"+
          "<p>"+ex.getMessage()+"</p>");
    throw new HTTPException (error) ;
      }
  }
  // Emit an error back:
  Reply error = request.makeReply(HTTP.GONE) ;
  error.setContentMD5(null);
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.