Package org.eclipse.ecf.remoteservice.rest

Examples of org.eclipse.ecf.remoteservice.rest.RestException


    return os.toByteArray();
  }

  protected void handleException(String message, Throwable e, int responseCode, byte[] responseBody) throws RestException {
    logException(message, e);
    throw new RestException(message, e, responseCode, responseBody);
  }
View Full Code Here


  protected HttpRequestBase createAndPrepareHttpMethod(String uri, IRemoteCall call, IRemoteCallable callable) throws RestException {
    HttpRequestBase httpMethod = null;

    IRemoteCallableRequestType requestType = callable.getRequestType();
    if (requestType == null)
      throw new RestException("Request type for call cannot be null"); //$NON-NLS-1$
    try {
      if (requestType instanceof HttpGetRequestType) {
        httpMethod = prepareGetMethod(uri, call, callable);
      } else if (requestType instanceof HttpPostRequestType) {
        httpMethod = preparePostMethod(uri, call, callable);
      } else if (requestType instanceof HttpPutRequestType) {
        httpMethod = preparePutMethod(uri, call, callable);
      } else if (requestType instanceof HttpDeleteRequestType) {
        httpMethod = prepareDeleteMethod(uri, call, callable);
      } else {
        throw new RestException("HTTP method " + requestType + " not supported"); //$NON-NLS-1$ //$NON-NLS-2$
      }
    } catch (NotSerializableException e) {
      String message = "Could not serialize parameters for uri=" + uri + " call=" + call + " callable=" + callable; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      logException(message, e);
      throw new RestException(message);
    } catch (UnsupportedEncodingException e) {
      String message = "Could not serialize parameters for uri=" + uri + " call=" + call + " callable=" + callable; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      logException(message, e);
      throw new RestException(message);
    }
    // add additional request headers
    addRequestHeaders(httpMethod, call, callable);
    // handle authentication
    setupAuthenticaton(httpClient, httpMethod);
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.remoteservice.rest.RestException

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.