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();
}
}