Examples of FirebaseException


Examples of net.thegreshams.firebase4j.error.FirebaseException

  public Firebase( String baseUrl ) throws FirebaseException {

    if( baseUrl == null || baseUrl.trim().isEmpty() ) {
      String msg = "baseUrl cannot be null or empty; was: '" + baseUrl + "'";
      LOGGER.error( msg );
      throw new FirebaseException( msg );
    }
    this.baseUrl = baseUrl.trim();
    LOGGER.info( "intialized with base-url: " + this.baseUrl );
  }
View Full Code Here

Examples of net.thegreshams.firebase4j.error.FirebaseException

     
    } catch( Throwable t ) {
     
      String msg = "unable to create entity from data; data was: " + jsonData;
      LOGGER.error( msg );
      throw new FirebaseException( msg, t );
     
    }
   
    return result;
  }
View Full Code Here

Examples of net.thegreshams.firebase4j.error.FirebaseException

    // sanity-check
    if( request == null ) {
     
      String msg = "request cannot be null";
      LOGGER.error( msg );
      throw new FirebaseException( msg );
    }
   
    try {
     
      HttpClient client = new DefaultHttpClient();
      response = client.execute( request );
     
    } catch( Throwable t ) {
   
      String msg = "unable to receive response from request(" + request.getMethod() ") @ " + request.getURI();
      LOGGER.error( msg );
      throw new FirebaseException( msg, t );
     
    }
     
    return response;
  }
View Full Code Here

Examples of net.thegreshams.firebase4j.error.FirebaseException

    // sanity-checks
    if( method == null ) {
     
      String msg = "method cannot be null";
      LOGGER.error( msg );
      throw new FirebaseException( msg );
    }
    if( httpResponse == null ) {
     
      String msg = "httpResponse cannot be null";
      LOGGER.error( msg );
      throw new FirebaseException( msg );
    }
   
    // get the response-entity
    HttpEntity entity = httpResponse.getEntity();
   
    // get the response-code
    int code = httpResponse.getStatusLine().getStatusCode();
   
    // set the response-success
    boolean success = false;
    switch( method ) {
      case DELETE:
        if( httpResponse.getStatusLine().getStatusCode() == 204
          && "No Content".equalsIgnoreCase( httpResponse.getStatusLine().getReasonPhrase() ) )
        {
          success = true;
        }
        break;
      case PUT:
      case POST:
      case GET:
        if( httpResponse.getStatusLine().getStatusCode() == 200
          && "OK".equalsIgnoreCase( httpResponse.getStatusLine().getReasonPhrase() ) )
        {
          success = true;
        }
        break;
      default:
        break;
       
    }
   
    // get the response-body
    Writer writer = new StringWriter();
    if( entity != null ) {
     
      try {
       
        InputStream is = entity.getContent();
        char[] buffer = new char[1024];
        Reader reader = new BufferedReader( new InputStreamReader( is, "UTF-8" ) );
        int n;
        while( (n=reader.read(buffer)) != -1 ) {
          writer.write( buffer, 0, n );
        }
       
      } catch( Throwable t ) {
       
        String msg = "unable to read response-content; read up to this point: '" + writer.toString() + "'";
        writer = new StringWriter(); // don't want to later give jackson partial JSON it might choke on
        LOGGER.error( msg );
        throw new FirebaseException( msg, t );
       
      }
    }
   
    // convert response-body to map
    Map<String, Object> body = null;
    try {
     
      body = JacksonUtility.GET_JSON_STRING_AS_MAP( writer.toString() );
     
    } catch( JacksonUtilityException jue ) {
     
      String msg = "unable to convert response-body into map; response-body was: '" + writer.toString() + "'";
      LOGGER.error( msg );
      throw new FirebaseException( msg, jue );
    }
   
    // build the response
    response = new FirebaseResponse( success, code, body, writer.toString() );
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.