use of org.codehaus.jackson.node.ObjectNode in project exhibitor by soabase.
the class ExplorerResource method getNode.
@GET
@Path("node")
@Produces("application/json")
public String getNode(@QueryParam("key") String key) throws Exception {
ArrayNode children = JsonNodeFactory.instance.arrayNode();
try {
List<String> childrenNames = context.getExhibitor().getLocalConnection().getChildren().forPath(key);
SmartSort.sortChildren(childrenNames);
for (String name : childrenNames) {
ObjectNode node = children.addObject();
node.put("title", name);
node.put("key", ZKPaths.makePath(key, name));
node.put("isLazy", true);
node.put("expand", false);
}
} catch (Throwable e) {
context.getExhibitor().resetLocalConnection();
context.getExhibitor().getLog().add(ActivityLog.Type.ERROR, "getNode: " + key, e);
ObjectNode node = children.addObject();
node.put("title", "* Exception *");
node.put("key", ERROR_KEY);
node.put("isLazy", false);
node.put("expand", false);
}
return children.toString();
}
use of org.codehaus.jackson.node.ObjectNode in project modules.playframework.org by playframework.
the class FeaturedModules method update.
public static Result update() {
Result result;
Form<FeaturedModule> form = form(FeaturedModule.class).bindFromRequest();
if (form.hasErrors()) {
result = badRequest(form.errorsAsJson());
} else {
FeaturedModule incoming = form.get();
FeaturedModule storedVersion = FeaturedModule.FIND.byId(incoming.id);
storedVersion.description = StringUtils.isEmpty(incoming.description) ? storedVersion.playModule.description : incoming.description;
storedVersion.sticky = incoming.sticky;
storedVersion.save();
// Annoying - converting storedVersion directly to JSON results in a cycle according to Jackson
// Buggered if I can see why though
ObjectNode node = Json.newObject();
node.put("id", storedVersion.id);
node.put("description", storedVersion.description);
node.put("sticky", storedVersion.sticky);
result = ok(node);
}
return result;
}
use of org.codehaus.jackson.node.ObjectNode in project stanbol by apache.
the class AnalyzedTextParser method parseAnalyzedTextSpan.
private void parseAnalyzedTextSpan(JsonNode node, AnalysedText at) throws IOException {
if (node.isObject()) {
ObjectNode jSpan = (ObjectNode) node;
int[] spanPos = new int[] { -1, -1 };
Collection<Entry<String, JsonNode>> jAnnotations = new ArrayList<Entry<String, JsonNode>>(4);
SpanTypeEnum spanType = parseSpanData(jSpan, spanPos, jAnnotations);
if (spanType != SpanTypeEnum.Text || spanPos[0] != 0 || spanPos[1] < 0) {
throw new IOException("The AnalyzedText span MUST have the SpanType 'text', a " + "start position of '0' and an end position (ignored, json: " + jSpan);
}
if (at.getEnd() != spanPos[1]) {
throw new IOException("The size of the local text '" + at.getEnd() + "' does not " + "match the span of the parsed AnalyzedText [" + spanPos[0] + "," + spanPos[1] + "]!");
}
parseAnnotations(at, jAnnotations);
} else {
throw new IOException("Unable to parse AnalyzedText span form JsonNode " + node + " (expected JSON object)!");
}
}
use of org.codehaus.jackson.node.ObjectNode in project stanbol by apache.
the class NerTagSupport method serialize.
@Override
public ObjectNode serialize(ObjectMapper mapper, NerTag nerTag) {
ObjectNode jNerTag = mapper.createObjectNode();
jNerTag.put("tag", nerTag.getTag());
if (nerTag.getType() != null) {
jNerTag.put("uri", nerTag.getType().getUnicodeString());
}
return jNerTag;
}
use of org.codehaus.jackson.node.ObjectNode in project stanbol by apache.
the class PhraseTagSupport method serialize.
@Override
public ObjectNode serialize(ObjectMapper mapper, PhraseTag value) {
ObjectNode jTag = mapper.createObjectNode();
jTag.put("tag", value.getTag());
if (value.getCategory() != null) {
jTag.put("lc", value.getCategory().ordinal());
}
return jTag;
}
Aggregations