existingEmail = existingEmail.toLowerCase();
//newEmail should not be present and oldEmail should be already present
UserEntity entity = ofy().load().type(UserEntity.class).id(newEmail).get();
if (entity != null)
throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
"User [" + newEmail + "] already present");
entity = ofy().load().type(UserEntity.class).id(existingEmail).get();
if (entity == null)
throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
"User [" + existingEmail + "] is not present");
entity.email = newEmail;
ofy().save().entity(entity).now();
}