Search in sources :

Example 11 with JsopBuilder

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

the class NodeDocument method asString.

public String asString() {
    JsopWriter json = new JsopBuilder();
    toJson(json, data);
    return json.toString();
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) JsopWriter(org.apache.jackrabbit.oak.commons.json.JsopWriter)

Example 12 with JsopBuilder

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

the class DocumentNodeState method asString.

public String asString() {
    JsopWriter json = new JsopBuilder();
    json.key("path").value(path);
    json.key("rev").value(rootRevision.toString());
    if (lastRevision != null) {
        json.key("lastRev").value(lastRevision.toString());
    }
    if (hasChildren) {
        json.key("hasChildren").value(true);
    }
    if (properties.size() > 0) {
        json.key("prop").object();
        for (Map.Entry<String, PropertyState> e : bundlingContext.getAllProperties().entrySet()) {
            json.key(e.getKey()).value(asString(e.getValue()));
        }
        json.endObject();
    }
    return json.toString();
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) JsopWriter(org.apache.jackrabbit.oak.commons.json.JsopWriter) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 13 with JsopBuilder

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

the class DocumentNodeState method asString.

private String asString(PropertyState prop) {
    if (prop == null) {
        return null;
    } else if (prop instanceof DocumentPropertyState) {
        return ((DocumentPropertyState) prop).getValue();
    }
    JsopBuilder builder = new JsopBuilder();
    new JsonSerializer(builder, store.getBlobSerializer()).serialize(prop);
    return builder.toString();
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) JsonSerializer(org.apache.jackrabbit.oak.json.JsonSerializer)

Example 14 with JsopBuilder

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

the class JournalEntry method getChanges.

private static String getChanges(TreeNode node) {
    JsopBuilder builder = new JsopBuilder();
    for (String name : node.keySet()) {
        builder.tag('^');
        builder.key(name);
        builder.object().endObject();
    }
    return builder.toString();
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder)

Example 15 with JsopBuilder

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

the class ClusterViewDocument method asHistoryEntry.

/** Converts a previous clusterView document into a history 'string' **/
private static String asHistoryEntry(final ClusterViewDocument previousView, int retiringClusterNodeId, Date retireTime) {
    if (previousView == null) {
        throw new IllegalArgumentException("previousView must not be null");
    }
    String h;
    JsopBuilder b = new JsopBuilder();
    b.object();
    b.key(VIEW_SEQ_NUM_KEY);
    b.value(previousView.getViewSeqNum());
    b.key(CREATED_KEY);
    b.value(String.valueOf(previousView.getCreatedAt()));
    b.key(CREATOR_KEY);
    b.value(previousView.getCreatedBy());
    b.key(RETIRED_KEY);
    b.value(String.valueOf(standardDateFormat.format(retireTime)));
    b.key(RETIRER_KEY);
    b.value(retiringClusterNodeId);
    b.key(ACTIVE_KEY);
    b.value(setToCsv(previousView.getActiveIds()));
    b.key(RECOVERING_KEY);
    b.value(setToCsv(previousView.getRecoveringIds()));
    b.key(INACTIVE_KEY);
    b.value(setToCsv(previousView.getInactiveIds()));
    b.endObject();
    h = b.toString();
    return h;
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder)

Aggregations

JsopBuilder (org.apache.jackrabbit.oak.commons.json.JsopBuilder)18 JsopWriter (org.apache.jackrabbit.oak.commons.json.JsopWriter)9 Test (org.junit.Test)5 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)2 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)2 DelegatingDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.secondary.DelegatingDocumentNodeState)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1 Node (javax.jcr.Node)1 NodeIterator (javax.jcr.NodeIterator)1 Value (javax.jcr.Value)1