Package org.apache.wookie.w3c.exceptions

Examples of org.apache.wookie.w3c.exceptions.InvalidContentTypeException


    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url.toString());
    client.executeMethod(method);
    if (!ignoreContentType){
        Header header = method.getResponseHeader("Content-Type");
        if (header == null) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received no content type description.");
      String type = header.getValue();
      if (!type.startsWith(WIDGET_CONTENT_TYPE)) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
    }
    File file = File.createTempFile("wookie", null);
    FileUtils.writeByteArrayToFile(file, IOUtils.toByteArray(method.getResponseBodyAsStream()));
    method.releaseConnection();
    return file;
View Full Code Here


      fType = IW3CXMLConfiguration.DEFAULT_MEDIA_TYPE;
    } else {
      // Split the content type, as we may also have a charset parameter
      String[] type = fType.split(";");
      // If a type attribute is specified, and is either invalid or unsupported, we must treat it as an invalid widget
      if (!isSupported(type[0], IW3CXMLConfiguration.SUPPORTED_CONTENT_TYPES)) throw new InvalidContentTypeException("Content type is not supported");
      fType = type[0];
      // Get the charset parameter if present
      if (type.length > 1){
        String charset[] = type[type.length-1].split("=");
        charsetParameter = charset[charset.length-1]
View Full Code Here

  private File download(URL url, boolean ignoreContentType) throws InvalidContentTypeException, HttpException, IOException {
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url.toString());
    client.executeMethod(method);
    String type = method.getResponseHeader("Content-Type").getValue();
    if (!ignoreContentType && !type.startsWith(WIDGET_CONTENT_TYPE)) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
    File file = File.createTempFile("wookie", null);
    FileUtils.writeByteArrayToFile(file, IOUtils.toByteArray(method.getResponseBodyAsStream()));
    method.releaseConnection();
    return file;
  }
View Full Code Here

  private File download(URL url, boolean ignoreContentType) throws InvalidContentTypeException, HttpException, IOException {
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url.toString());
    client.executeMethod(method);
    String type = method.getResponseHeader("Content-Type").getValue();
    if (!ignoreContentType && !type.startsWith(WIDGET_CONTENT_TYPE)) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
    File file = File.createTempFile("wookie", null);
    FileUtils.writeByteArrayToFile(file, IOUtils.toByteArray(method.getResponseBodyAsStream()));
    method.releaseConnection();
    return file;
  }
View Full Code Here

    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url.toString());
    client.executeMethod(method);
    if (!ignoreContentType){
        Header header = method.getResponseHeader("Content-Type");
        if (header == null) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received no content type description.");
      String type = header.getValue();
      if (!type.startsWith(WIDGET_CONTENT_TYPE)) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
    }
    File file = File.createTempFile("wookie", null);
    FileUtils.writeByteArrayToFile(file, IOUtils.toByteArray(method.getResponseBodyAsStream()));
    method.releaseConnection();
    return file;
View Full Code Here

      fType = IW3CXMLConfiguration.DEFAULT_MEDIA_TYPE;
    } else {
      // Split the content type, as we may also have a charset parameter
      String[] type = fType.split(";");
      // If a type attribute is specified, and is either invalid or unsupported, we must treat it as an invalid widget
      if (!isSupported(type[0], IW3CXMLConfiguration.SUPPORTED_CONTENT_TYPES)) throw new InvalidContentTypeException("Content type is not supported");
      fType = type[0];
      // Get the charset parameter if present
      if (type.length > 1){
        String charset[] = type[type.length-1].split("=");
        charsetParameter = charset[charset.length-1]
View Full Code Here

  private File download(URL url, boolean ignoreContentType) throws InvalidContentTypeException, HttpException, IOException {
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url.toString());
    client.executeMethod(method);
    String type = method.getResponseHeader("Content-Type").getValue();
    if (!ignoreContentType && !type.startsWith(WIDGET_CONTENT_TYPE)) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
    File file = File.createTempFile("wookie", null);
    FileUtils.writeByteArrayToFile(file, IOUtils.toByteArray(method.getResponseBodyAsStream()));
    method.releaseConnection();
    return file;
  }
View Full Code Here

      fType = IW3CXMLConfiguration.DEFAULT_MEDIA_TYPE;
    } else {
      // Split the content type, as we may also have a charset parameter
      String[] type = fType.split(";");
      // If a type attribute is specified, and is either invalid or unsupported, we must treat it as an invalid widget
      if (!isSupported(type[0], IW3CXMLConfiguration.SUPPORTED_CONTENT_TYPES)) throw new InvalidContentTypeException("Content type is not supported");
      fType = type[0];
      // Get the charset parameter if present
      if (type.length > 1){
        String charset[] = type[type.length-1].split("=");
        charsetParameter = charset[charset.length-1]
View Full Code Here

  private File download(URL url, boolean ignoreContentType) throws InvalidContentTypeException, HttpException, IOException {
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url.toString());
    client.executeMethod(method);
    String type = method.getResponseHeader("Content-Type").getValue();
    if (!ignoreContentType && !type.startsWith(WIDGET_CONTENT_TYPE)) throw new InvalidContentTypeException("Problem downloading widget: expected a content type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
    File file = File.createTempFile("wookie", null);
    FileUtils.writeByteArrayToFile(file, IOUtils.toByteArray(method.getResponseBodyAsStream()));
    method.releaseConnection();
    return file;
  }
View Full Code Here

TOP

Related Classes of org.apache.wookie.w3c.exceptions.InvalidContentTypeException

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.