Package org.servalproject.servaldna

Examples of org.servalproject.servaldna.ServalDInterfaceException


    try {
      return Integer.valueOf(str);
    }
    catch (NumberFormatException e) {
    }
    throw new ServalDInterfaceException("invalid header field: " + header + ": " + str);
  }
View Full Code Here


      if (value >= 0)
        return value;
    }
    catch (NumberFormatException e) {
    }
    throw new ServalDInterfaceException("invalid header field: " + header + ": " + str);
  }
View Full Code Here

  private static long headerUnsignedLong(HttpURLConnection conn, String header) throws ServalDInterfaceException
  {
    Long value = headerUnsignedLongOrNull(conn, header);
    if (value == null)
      throw new ServalDInterfaceException("missing header field: " + header);
    return value;
  }
View Full Code Here

          return cls.cast(method.invoke(null, integer));
        }
      }
      catch (NoSuchMethodException e) {
      }
      throw new ServalDInterfaceException("don't know how to instantiate: " + cls.getName());
    }
    catch (ServalDInterfaceException e) {
      throw e;
    }
    catch (InvocationTargetException e) {
      throw new ServalDInterfaceException("invalid header field: " + header + ": " + str, e.getTargetException());
    }
    catch (Exception e) {
      throw new ServalDInterfaceException("invalid header field: " + header + ": " + str, e);
    }
  }
View Full Code Here

  private static <T> T header(HttpURLConnection conn, String header, Class<T> cls) throws ServalDInterfaceException
  {
    T value = headerOrNull(conn, header, cls);
    if (value == null)
      throw new ServalDInterfaceException("missing header field: " + header);
    return value;
  }
View Full Code Here

  private final String restfulUsername;
  private final String restfulPassword;

  public ServalDClient(int httpPort, String restfulUsername, String restfulPassword) throws ServalDInterfaceException {
    if (httpPort < 1 || httpPort > 65535)
      throw new ServalDInterfaceException("invalid HTTP port number: " + httpPort);
    if (restfulUsername == null)
      throw new ServalDInterfaceException("invalid HTTP username");
    if (restfulPassword == null)
      throw new ServalDInterfaceException("invalid HTTP password");
    this.httpPort = httpPort;
    this.restfulUsername = restfulUsername;
    this.restfulPassword = restfulPassword;
  }
View Full Code Here

    HttpURLConnection conn;
    try {
      conn = (HttpURLConnection) uconn;
    }
    catch (ClassCastException e) {
      throw new ServalDInterfaceException("URL.openConnection() returned a " + uconn.getClass().getName() + ", expecting a HttpURLConnection", e);
    }
    conn.setAllowUserInteraction(false);
    try {
      conn.addRequestProperty("Authorization", "Basic " + Base64.encode((restfulUsername + ":" + restfulPassword).getBytes("US-ASCII")));
    }
    catch (UnsupportedEncodingException e) {
      throw new ServalDInterfaceException("invalid RESTful password", e);
    }
    return conn;
  }
View Full Code Here

TOP

Related Classes of org.servalproject.servaldna.ServalDInterfaceException

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.