Search in sources :

Example 1 with GlanceImageUpdate

use of org.openstack4j.openstack.image.v2.domain.GlanceImageUpdate in project openstack4j by ContainX.

the class ImageServiceImpl method update.

/**
     * {@inheritDoc}
     */
@Override
public Image update(Image image) {
    checkNotNull(image);
    ObjectMapper objectMapper = new ObjectMapper();
    Image origImage = get(image.getId());
    ObjectNode origJson;
    ObjectNode newJson;
    try {
        String oImg = objectMapper.writeValueAsString(origImage);
        origJson = (ObjectNode) objectMapper.readTree(oImg);
        String img = objectMapper.writeValueAsString(image);
        newJson = (ObjectNode) objectMapper.readTree(img);
        JsonNode jsonDiff = JsonDiff.asJson(origJson, newJson);
        GlanceImageUpdate giu = new GlanceImageUpdate(jsonDiff);
        return update(image.getId(), giu);
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) GlanceImageUpdate(org.openstack4j.openstack.image.v2.domain.GlanceImageUpdate) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) GlanceImage(org.openstack4j.openstack.image.v2.domain.GlanceImage) Image(org.openstack4j.model.image.v2.Image) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 Image (org.openstack4j.model.image.v2.Image)1 GlanceImage (org.openstack4j.openstack.image.v2.domain.GlanceImage)1 GlanceImageUpdate (org.openstack4j.openstack.image.v2.domain.GlanceImageUpdate)1