001package org.nuxeo.ecm.automation.core.io;
002
003import static org.nuxeo.ecm.core.io.registry.reflect.Instantiations.SINGLETON;
004import static org.nuxeo.ecm.core.io.registry.reflect.Priorities.REFERENCE;
005
006import java.io.IOException;
007
008import org.codehaus.jackson.JsonNode;
009import org.codehaus.jackson.node.ObjectNode;
010import org.nuxeo.ecm.automation.core.util.ComplexTypeJSONDecoder;
011import org.nuxeo.ecm.core.api.Blob;
012import org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonReader;
013import org.nuxeo.ecm.core.io.registry.reflect.Setup;
014
015@Setup(mode = SINGLETON, priority = REFERENCE)
016public class BlobJsonReader extends AbstractJsonReader<Blob> {
017
018    @Override
019    public Blob read(JsonNode jn) throws IOException {
020        if (jn.isObject()) {
021            return ComplexTypeJSONDecoder.getBlobFromJSON((ObjectNode) jn);
022        }
023        return null;
024    }
025
026}