use of org.codehaus.jackson.node.ObjectNode in project ovirt-engine by oVirt.
the class GwtDynamicHostPageServlet method getUserInfoObject.
protected ObjectNode getUserInfoObject(DbUser loggedInUser, String ssoToken) {
ObjectNode obj = createObjectNode();
// $NON-NLS-1$
obj.put("id", loggedInUser.getId().toString());
// $NON-NLS-1$
obj.put("userName", loggedInUser.getLoginName());
// $NON-NLS-1$
obj.put("domain", loggedInUser.getDomain());
// $NON-NLS-1$
obj.put("isAdmin", loggedInUser.isAdmin());
// $NON-NLS-1$
obj.put("ssoToken", ssoToken);
return obj;
}
use of org.codehaus.jackson.node.ObjectNode in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationEnabled.
@Test
public void createStudyDOIlookupCitationEnabled() throws NodeFactoryException {
StudyImpl title = new StudyImpl("title", "some source", null, "some citation");
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, true);
originatingDataset.setConfig(objectNode);
title.setOriginatingDataset(originatingDataset);
StudyNode study = getNodeFactory().getOrCreateStudy(title);
new LinkerDOI(getGraphDb()).linkStudy(new TestDOIResolver(), study);
assertThat(study.getSource(), is("some source"));
assertThat(study.getDOI(), is("doi:some citation"));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
}
use of org.codehaus.jackson.node.ObjectNode in project incubator-gobblin by apache.
the class FieldAttributeBasedDeltaFieldsProvider method getDeltaPropValue.
private ObjectNode getDeltaPropValue(String json) {
try {
JsonFactory jf = new JsonFactory();
JsonParser jp = jf.createJsonParser(json);
ObjectMapper objMap = new ObjectMapper(jf);
jp.setCodec(objMap);
return (ObjectNode) jp.readValueAsTree();
} catch (IOException e) {
return null;
}
}
use of org.codehaus.jackson.node.ObjectNode in project exhibitor by soabase.
the class ConfigResource method getSystemState.
@Path("get-state")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getSystemState(@Context Request request) throws Exception {
InstanceConfig config = context.getExhibitor().getConfigManager().getConfig();
String response = new FourLetterWord(FourLetterWord.Word.RUOK, config, context.getExhibitor().getConnectionTimeOutMs()).getResponse();
ServerList serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC));
ServerSpec us = UsState.findUs(context.getExhibitor(), serverList.getSpecs());
ObjectNode mainNode = JsonNodeFactory.instance.objectNode();
ObjectNode configNode = JsonNodeFactory.instance.objectNode();
ObjectNode controlPanelNode = JsonNodeFactory.instance.objectNode();
mainNode.put("version", context.getExhibitor().getVersion());
mainNode.put("running", "imok".equals(response));
mainNode.put("backupActive", context.getExhibitor().getBackupManager().isActive());
mainNode.put("standaloneMode", context.getExhibitor().getConfigManager().isStandaloneMode());
mainNode.put("extraHeadingText", context.getExhibitor().getExtraHeadingText());
mainNode.put("nodeMutationsAllowed", context.getExhibitor().nodeMutationsAllowed());
configNode.put("rollInProgress", context.getExhibitor().getConfigManager().isRolling());
configNode.put("rollStatus", context.getExhibitor().getConfigManager().getRollingConfigState().getRollingStatus());
configNode.put("rollPercentDone", context.getExhibitor().getConfigManager().getRollingConfigState().getRollingPercentDone());
configNode.put("hostname", context.getExhibitor().getThisJVMHostname());
configNode.put("serverId", (us != null) ? us.getServerId() : -1);
for (StringConfigs c : StringConfigs.values()) {
configNode.put(fixName(c), config.getString(c));
}
for (IntConfigs c : IntConfigs.values()) {
String fixedName = fixName(c);
int value = config.getInt(c);
configNode.put(fixedName, value);
}
EncodedConfigParser zooCfgParser = new EncodedConfigParser(config.getString(StringConfigs.ZOO_CFG_EXTRA));
ObjectNode zooCfgNode = JsonNodeFactory.instance.objectNode();
for (EncodedConfigParser.FieldValue fv : zooCfgParser.getFieldValues()) {
zooCfgNode.put(fv.getField(), fv.getValue());
}
configNode.put("zooCfgExtra", zooCfgNode);
if (context.getExhibitor().getBackupManager().isActive()) {
ObjectNode backupExtraNode = JsonNodeFactory.instance.objectNode();
EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser();
List<BackupConfigSpec> configs = context.getExhibitor().getBackupManager().getConfigSpecs();
for (BackupConfigSpec c : configs) {
String value = parser.getValue(c.getKey());
backupExtraNode.put(c.getKey(), (value != null) ? value : "");
}
configNode.put("backupExtra", backupExtraNode);
}
configNode.put("controlPanel", controlPanelNode);
mainNode.put("config", configNode);
String json = JsonUtil.writeValueAsString(mainNode);
EntityTag tag = new EntityTag(Hashing.sha1().hashString(json, Charsets.UTF_8).toString());
Response.ResponseBuilder builder = request.evaluatePreconditions(tag);
if (builder == null) {
builder = Response.ok(json).tag(tag);
}
return builder.build();
}
use of org.codehaus.jackson.node.ObjectNode in project exhibitor by soabase.
the class IndexResource method getDataTableData.
@Path("dataTable/{index-name}/{search-handle}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getDataTableData(@PathParam("index-name") String indexName, @PathParam("search-handle") String searchHandle, @QueryParam("iDisplayStart") int iDisplayStart, @QueryParam("iDisplayLength") int iDisplayLength, @QueryParam("sEcho") String sEcho) throws Exception {
LogSearch logSearch = getLogSearch(indexName);
if (logSearch == null) {
return "{}";
}
ObjectNode node;
try {
CachedSearch cachedSearch = logSearch.getCachedSearch(searchHandle);
DateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT_STR);
ArrayNode dataTab = JsonNodeFactory.instance.arrayNode();
for (int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i) {
if (i < cachedSearch.getTotalHits()) {
ObjectNode data = JsonNodeFactory.instance.objectNode();
int docId = cachedSearch.getNthDocId(i);
SearchItem item = logSearch.toResult(docId);
data.put("DT_RowId", "index-query-result-" + docId);
data.put("0", getTypeName(EntryTypes.getFromId(item.getType())));
data.put("1", dateFormatter.format(item.getDate()));
data.put("2", trimPath(item.getPath()));
dataTab.add(data);
}
}
node = JsonNodeFactory.instance.objectNode();
node.put("sEcho", sEcho);
node.put("iTotalRecords", logSearch.getDocQty());
node.put("iTotalDisplayRecords", cachedSearch.getTotalHits());
node.put("aaData", dataTab);
} finally {
context.getExhibitor().getIndexCache().releaseLogSearch(logSearch.getFile());
}
return node.toString();
}
Aggregations