use of org.apache.jackrabbit.oak.commons.json.JsopWriter 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();
}
use of org.apache.jackrabbit.oak.commons.json.JsopWriter in project jackrabbit-oak by apache.
the class Commit method addChangesToDiffCacheEntry.
/**
* Apply the changes of a node to the cache.
*
* @param path the path
* @param added the list of added child nodes
* @param removed the list of removed child nodes
* @param changed the list of changed child nodes
* @param cacheEntry the cache entry changes are added to
*/
private void addChangesToDiffCacheEntry(String path, List<String> added, List<String> removed, List<String> changed, DiffCache.Entry cacheEntry) {
// update diff cache
JsopWriter w = new JsopStream();
for (String p : added) {
w.tag('+').key(PathUtils.getName(p)).object().endObject();
}
for (String p : removed) {
w.tag('-').value(PathUtils.getName(p));
}
for (String p : changed) {
w.tag('^').key(PathUtils.getName(p)).object().endObject();
}
cacheEntry.append(path, w.toString());
}
use of org.apache.jackrabbit.oak.commons.json.JsopWriter in project jackrabbit-oak by apache.
the class NodeStateJsonUtils method toJson.
public static String toJson(NodeState state, boolean includeHiddenContent) {
JsopWriter json = new JsopBuilder();
copyAsJson(json, state, includeHiddenContent);
return json.toString();
}
use of org.apache.jackrabbit.oak.commons.json.JsopWriter in project jackrabbit-oak by apache.
the class BundledDocumentDifferTest method diffWithSecondary.
@Test
public void diffWithSecondary() throws Exception {
configureSecondary();
NodeBuilder builder = createContentStructure();
NodeState r1 = merge(store, builder);
NodeState rs1 = DelegatingDocumentNodeState.wrap(secondary.getRoot(), store);
builder = store.getRoot().builder();
childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("foo", "bar");
NodeState r2 = merge(store, builder);
JsopWriter w = new JsopBuilder();
String path = "/test/book.jpg";
assertFalse(differ.diff(adns(rs1, path), adns(r2, path), w));
assertEquals("^\"jcr:content\":{}", w.toString());
}
use of org.apache.jackrabbit.oak.commons.json.JsopWriter in project jackrabbit-oak by apache.
the class BundledDocumentDifferTest method jsopDiff.
@Test
public void jsopDiff() throws Exception {
JsopWriter w = new JsopBuilder();
differ.diffChildren(of("a", "b"), of("b", "c"), w);
//removed a
//changed b
//added b
assertEquals("-\"a\"^\"b\":{}+\"c\":{}", w.toString());
}
Aggregations