Search in sources :

Example 76 with ObjectNode

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;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode)

Example 77 with ObjectNode

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"));
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 78 with ObjectNode

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;
    }
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) JsonFactory(org.codehaus.jackson.JsonFactory) IOException(java.io.IOException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JsonParser(org.codehaus.jackson.JsonParser)

Example 79 with ObjectNode

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();
}
Also used : ServerSpec(com.netflix.exhibitor.core.state.ServerSpec) ObjectNode(org.codehaus.jackson.node.ObjectNode) IntConfigs(com.netflix.exhibitor.core.config.IntConfigs) Response(javax.ws.rs.core.Response) InstanceConfig(com.netflix.exhibitor.core.config.InstanceConfig) EncodedConfigParser(com.netflix.exhibitor.core.config.EncodedConfigParser) FourLetterWord(com.netflix.exhibitor.core.state.FourLetterWord) BackupConfigSpec(com.netflix.exhibitor.core.backup.BackupConfigSpec) ServerList(com.netflix.exhibitor.core.state.ServerList) EntityTag(javax.ws.rs.core.EntityTag) StringConfigs(com.netflix.exhibitor.core.config.StringConfigs) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 80 with ObjectNode

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();
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) CachedSearch(com.netflix.exhibitor.core.index.CachedSearch) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) LogSearch(com.netflix.exhibitor.core.index.LogSearch) ArrayNode(org.codehaus.jackson.node.ArrayNode) SimpleDateFormat(java.text.SimpleDateFormat) SearchItem(com.netflix.exhibitor.core.index.SearchItem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ObjectNode (org.codehaus.jackson.node.ObjectNode)97 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)29 ArrayNode (org.codehaus.jackson.node.ArrayNode)29 JsonNode (org.codehaus.jackson.JsonNode)22 GET (javax.ws.rs.GET)21 Path (javax.ws.rs.Path)18 Test (org.junit.Test)16 Produces (javax.ws.rs.Produces)12 Map (java.util.Map)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 IOException (java.io.IOException)8 StringWriter (java.io.StringWriter)5 JsonFactory (org.codehaus.jackson.JsonFactory)5 HelixDataAccessor (org.apache.helix.HelixDataAccessor)4 Span (org.apache.stanbol.enhancer.nlp.model.Span)4 DatasetImpl (org.eol.globi.service.DatasetImpl)4 Date (java.util.Date)3 TaskDriver (org.apache.helix.task.TaskDriver)3 WorkflowConfig (org.apache.helix.task.WorkflowConfig)3