/** * Informs Livefyre to either create or update a collection based on the attributes of this * Collection. Makes an external API call. Returns this. * * @return Collection */ public Collection createOrUpdate() { ClientResponse response = invokeCollectionApi("create"); if (response.getStatus() == 200) { data.setId( LivefyreUtil.stringToJson(response.getEntity(String.class)) .getAsJsonObject("data") .get("collectionId") .getAsString()); return this; } else if (response.getStatus() == 409) { response = invokeCollectionApi("update"); if (response.getStatus() == 200) { data.setId( LivefyreUtil.stringToJson(response.getEntity(String.class)) .getAsJsonObject("data") .get("collectionId") .getAsString()); return this; } } throw new ApiException(response.getStatus()); }