Search in sources :

Example 1 with Base64BlobSerializer

use of org.apache.jackrabbit.oak.json.Base64BlobSerializer in project jackrabbit-oak by apache.

the class IndexDefinitionUpdater method getIndexDefnStates.

private static Map<String, NodeState> getIndexDefnStates(String json) throws IOException {
    Base64BlobSerializer blobHandler = new Base64BlobSerializer();
    Map<String, NodeState> indexDefns = Maps.newHashMap();
    JsopReader reader = new JsopTokenizer(json);
    reader.read('{');
    if (!reader.matches('}')) {
        do {
            String indexPath = reader.readString();
            if (!indexPath.startsWith("/")) {
                String msg = String.format("Invalid format of index definitions. The key name [%s] should " + "be index path ", indexPath);
                throw new IllegalArgumentException(msg);
            }
            reader.read(':');
            if (reader.matches('{')) {
                JsonDeserializer deserializer = new JsonDeserializer(blobHandler);
                NodeState idxState = deserializer.deserialize(reader);
                indexDefns.put(indexPath, idxState);
            }
        } while (reader.matches(','));
        reader.read('}');
    }
    return indexDefns;
}
Also used : JsopReader(org.apache.jackrabbit.oak.commons.json.JsopReader) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) JsonDeserializer(org.apache.jackrabbit.oak.json.JsonDeserializer) Base64BlobSerializer(org.apache.jackrabbit.oak.json.Base64BlobSerializer) JsopTokenizer(org.apache.jackrabbit.oak.commons.json.JsopTokenizer)

Aggregations

JsopReader (org.apache.jackrabbit.oak.commons.json.JsopReader)1 JsopTokenizer (org.apache.jackrabbit.oak.commons.json.JsopTokenizer)1 Base64BlobSerializer (org.apache.jackrabbit.oak.json.Base64BlobSerializer)1 JsonDeserializer (org.apache.jackrabbit.oak.json.JsonDeserializer)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1