Package org.parse4j.command

Examples of org.parse4j.command.ParseResponse


    else {
      command =  new ParsePutCommand(getEndPoint(), getObjectId());
    }
   
    command.setData(getParseData());
    ParseResponse response = command.perform();
    if(!response.isFailed()) {
      JSONObject jsonResponse = response.getJsonObject();
      if (jsonResponse == null) {
        LOGGER.error("Empty response");
        throw response.getException();
      }
      try {
        if(getObjectId() == null) {
          setObjectId(jsonResponse.getString(ParseConstants.FIELD_OBJECT_ID));
          String createdAt = jsonResponse.getString(ParseConstants.FIELD_CREATED_AT);
          setCreatedAt(Parse.parseDate(createdAt));
          setUpdatedAt(Parse.parseDate(createdAt));
        }
        else {
          String updatedAt = jsonResponse.getString(ParseConstants.FIELD_UPDATED_AT);
          setUpdatedAt(Parse.parseDate(updatedAt));
        }
       
        this.isDirty = false;
        this.operations.clear();
        this.dirtyKeys.clear();
      }
      catch (JSONException e) {
        LOGGER.error("Request failed.");
        throw new ParseException(
            ParseException.INVALID_JSON,
            "Although Parse reports object successfully saved, the response was invalid.",
            e);
      }     
    }
    else {
      LOGGER.error("Request failed.");
      throw response.getException();
    }
  }
View Full Code Here


  public void delete() throws ParseException {
   
    if(objectId == null) return;
   
    ParseCommand command = new ParseDeleteCommand(getEndPoint(), getObjectId());
    ParseResponse response = command.perform();
    if(response.isFailed()) {
      throw response.getException();
    }
   
    this.updatedAt = null;
    this.createdAt = null;
    this.objectId = null;
View Full Code Here

 
    ParseGetCommand command = new ParseGetCommand(getEndPoint(), getObjectId());
    //JSONObject query = new JSONObject();
    //query.put("objectId", getObjectId());
    //command.setData(query);
    ParseResponse response = command.perform();
    if(!response.isFailed()) {
      JSONObject jsonResponse = response.getJsonObject();
      if (jsonResponse == null) {
        throw response.getException();
      }
     
      T obj = parseData(jsonResponse);
      return obj;
     
    }
    else {
      throw response.getException();
    }
   
  }
View Full Code Here

TOP

Related Classes of org.parse4j.command.ParseResponse

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.