Example usage for com.fasterxml.jackson.databind JsonNode toString

List of usage examples for com.fasterxml.jackson.databind JsonNode toString

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonNode toString.

Prototype

public abstract String toString();

Source Link

Usage

From source file:com.appdynamics.analytics.processor.event.ElasticSearchEventService.java

public void multiSearchEvents(int requestVersion, String accountName, String searchRequest,
        OutputStream out)/* w  ww.  j a  va2  s .  c o m*/
/*      */ {
    /*      */ try
    /*      */ {
        /* 1188 */ accountName = AccountConfiguration.normalizeAccountName(accountName);
        /* 1189 */ JsonNode[] nodes = multilineToJson(searchRequest);
        /* 1190 */ verifyAndReplaceMultiSearchHeaders(requestVersion, accountName, nodes);
        /*      */
        /* 1192 */ Client client = this.clientProvider.getSearchClient(accountName);
        /* 1193 */ MultiSearchRequestBuilder multisearchRequestBuilder = client.prepareMultiSearch();
        /* 1194 */ for (int i = 0; i < nodes.length; i += 2) {
            /* 1195 */ JsonNode header = nodes[i];
            /* 1196 */ JsonNode search = nodes[(i + 1)];
            /*      */
            /* 1198 */ String index = find("index", header);
            /* 1199 */ String eventType = find("eventType", header);
            /*      */
            /* 1201 */ String searchType = find("search_type", header);
            /* 1202 */ SearchRequestBuilder request = client.prepareSearch(new String[] { index })
                    .setSearchType(searchType)
                    .setStats(new String[] { getUniqueQueryId(accountName, searchType) });
            /*      */
            /*      */
            /*      */
            /* 1206 */ processAndSetRequest(search.toString(), request, accountName, eventType);
            /*      */
            /* 1208 */ multisearchRequestBuilder.add(request);
            /*      */ }
        /*      */
        /*      */
        /* 1212 */ MultiSearchResponse response = (MultiSearchResponse) multisearchRequestBuilder.execute()
                .actionGet(this.callTimeout);
        /*      */
        /* 1214 */ XContentBuilder builder = XContentFactory.jsonBuilder(out);
        /* 1215 */ builder.startObject();
        /* 1216 */ response.toXContent(builder, ToXContent.EMPTY_PARAMS);
        /* 1217 */ builder.endObject();
        /* 1218 */ builder.close();
        /*      */ } catch (Exception e) {
        /* 1220 */ throw ElasticSearchServiceHelper.propagateAsException(e,
                "Failed to multi-search account [{}] on search request [{}]",
                new Object[] { accountName, searchRequest });
        /*      */ }
    /*      */ }

From source file:com.pros.jsontransform.ObjectTransformer.java

private JsonNode updateSourceFromPath(final JsonNode sourceNode, final JsonNode pathNode)
        throws ObjectTransformerException {
    // use transformNode $path or $value to find the source node
    JsonNode resultNode = sourceNode;/*from   ww w  .  j av a  2 s . c  o  m*/
    if (pathNode != null) {
        // remember current parent index
        int parentIndex = sourceNodeParents.size() - 1;

        // e.g path: items|0|items|0|items
        String regExp = "[" + PATH_SEPARATOR + "]";
        String[] pathParts = pathNode.asText().split(regExp);
        for (String part : pathParts) {
            if (!part.equalsIgnoreCase("..")) {
                // reset pointer to current parent
                parentIndex = sourceNodeParents.size() - 1;
            }

            // $i in path refers to current array index
            if (sourceArrayIndexes.size() > 0) {
                part = part.replace(EXPRESSION_$I,
                        String.valueOf(sourceArrayIndexes.get(sourceArrayIndexes.size() - 1)));
            }

            if (part.equalsIgnoreCase("..") && --parentIndex >= 0) {
                // parent object
                resultNode = sourceNodeParents.get(parentIndex);
            } else if (resultNode.isArray()) {
                try {
                    // handle array indexes in path
                    int index = Integer.parseInt(part);

                    // array element access
                    resultNode = resultNode.path(index);
                } catch (Exception e) {
                    if (part.contains("=")) {
                        // array search by fieldname=value
                        String[] searchParts = part.split("=");
                        for (JsonNode elementNode : resultNode) {
                            if (elementNode.path(searchParts[0]).asText().contains(searchParts[1])) {
                                resultNode = elementNode;
                                break;
                            }
                        }
                    }
                }
            } else if (part.isEmpty() && pathParts.length > 1) {
                // absolute path to source root
                resultNode = sourceRoot;
            } else if (resultNode.isObject()) {
                // find by field name
                resultNode = resultNode.path(part);
            } else {
                if (Boolean.valueOf(properties.getProperty("exception.on.path.resolution", "false")) == true) {
                    throw new ObjectTransformerException("Cannot resolve path " + pathNode.asText()
                            + " for source node " + sourceNode.toString());
                }
            }

            sourceNodeParents.add(resultNode);
        }

        // update path
        sourceNodePath += PATH_SEPARATOR + pathNode.asText();
    }

    return resultNode;
}

From source file:com.delphix.delphix.DelphixEngine.java

/**
 * Provision a VDB either a semantic point or a snapshot with the name of the new VDB being optional
 *//*from  w  ww  .j  av a 2s . c  o m*/
@SuppressWarnings("unchecked")
public String provisionVDB(String containerRef, String snapshotRef, String containerName, String repositoryRef,
        String mountBase) throws IOException, DelphixEngineException {
    String defaultParams = "";
    if (snapshotRef.equals(CONTENT_LATEST_POINT) || snapshotRef.equals(CONTENT_LATEST_SNAPSHOT)) {
        defaultParams = getProvisionDefaultsContainer(containerRef, snapshotRef);
    } else {
        defaultParams = getProvisionDefaultsSnapshot(snapshotRef);
    }
    // Strip out null values from provision parameters
    defaultParams = defaultParams.replaceAll("(\"[^\"]+\":null,?|,?\"[^\"]+\":null)", "");
    JsonNode params = MAPPER.readTree(defaultParams);

    // Set new VDB name if it is passed
    if (!containerName.isEmpty()) {
        ObjectNode containerNode = (ObjectNode) params.get("container");
        containerNode.put("name", containerName);
        ObjectNode sourceConfigNode = (ObjectNode) params.get("sourceConfig");
        sourceConfigNode.put("databaseName", containerName);
        sourceConfigNode.put("uniqueName", containerName);
        ObjectNode instanceNode = (ObjectNode) sourceConfigNode.get("instance");
        instanceNode.put("instanceName", containerName);
    }

    // Set target repository
    if (!repositoryRef.isEmpty() && !repositoryRef.equals("default")) {
        ObjectNode sourceConfig = (ObjectNode) params.get("sourceConfig");
        sourceConfig.put("repository", repositoryRef);
        DelphixRepository repository = getRepository(repositoryRef);
        // Handle provisioning to RAC
        if (repository.getRAC()) {
            sourceConfig.put("type", "OracleRACConfig");
            if (sourceConfig.has("instance")) {
                sourceConfig.remove("instance");
            }
            ArrayNode instances = sourceConfig.putArray("instances");
            ArrayList<DelphixClusterNode> clusterNodes = listClusterNodes();
            int i = 1;
            for (DelphixClusterNode node : clusterNodes) {
                ObjectNode instance = MAPPER.createObjectNode();
                instance.put("type", "OracleRACInstance");
                instance.put("instanceNumber", i);
                ObjectNode containerNode = (ObjectNode) params.get("container");
                instance.put("instanceName", containerNode.get("name").asText() + i);
                instance.put("node", node.getReference());
                instances.add(instance);
                i++;
            }
        }
    }

    // Set the base mount point
    if (!mountBase.isEmpty()) {
        ObjectNode sourceConfig = (ObjectNode) params.get("source");
        sourceConfig.put("mountBase", mountBase);

    }
    JsonNode result;
    ObjectNode sourceNode = (ObjectNode) params.get("source");

    // Hack for RAC support
    if (sourceNode.has("redoLogSizeInMB")) {
        sourceNode.remove("redoLogSizeInMB");
    }
    try {
        result = enginePOST(PATH_PROVISION, params.toString());
    } catch (DelphixEngineException e) {
        // Handle the case where some of the fields in the defaults are read
        // only by removing those fields
        if (e.getMessage().contains("This field is read-only")) {
            JsonNode errors = MAPPER.readTree(e.getMessage());
            List<String> list1 = IteratorUtils.toList(errors.fieldNames());
            for (String field1 : list1) {
                List<String> list2 = IteratorUtils.toList(errors.get(field1).fieldNames());
                for (String field2 : list2) {
                    // Field1 is the outer field and field2 is the inner
                    // field
                    ObjectNode node = (ObjectNode) params.get(field1);
                    // Remove the inner field
                    node.remove(field2);
                }
            }
            result = enginePOST(PATH_PROVISION, params.toString());
        } else {
            throw e;
        }
    }
    return result.get(FIELD_JOB).asText();

}

From source file:com.appdynamics.analytics.processor.event.ElasticSearchEventService.java

public void publishEvents(int requestVersion, String accountName, String eventType,
        final byte[] payloads, final int payloadOffset, final int payloadLength, final String requestId)
/*      */ {/*w w  w  . j  a  va 2 s .  co m*/
    /*  863 */ for (int i = 0; i < 2; i++) {
        /*      */ try {
            /*  865 */ final String eventTypeFinal = this.indexNameResolver.resolveEventType(eventType);
            /*  866 */ final String accountNameFinal = AccountConfiguration.normalizeAccountName(accountName);
            /*  867 */ verifyEventTypeRepairingIndicesIfNecessary(requestVersion, accountName, eventTypeFinal);
            /*      */
            /*  869 */ final String docType = this.indexNameResolver.getDocType(accountNameFinal,
                    eventTypeFinal);
            /*  870 */ Callable<BulkRequestBuilder> builderCallable = new Callable()
            /*      */ {
                /*      */ public BulkRequestBuilder call() throws Exception {
                    /*  873 */ String indexName = ElasticSearchEventService.this.indexNameResolver
                            .resolveInsertAlias(accountNameFinal, eventTypeFinal);
                    /*  874 */ ObjectListParser parser = ElasticSearchEventService.this.objListParserFactory
                            .make(payloads, payloadOffset, payloadLength);
                    /*      */
                    /*  876 */ Client client = ElasticSearchEventService.this.clientProvider
                            .getInsertClient(accountNameFinal);
                    /*  877 */ BulkRequestBuilder builder = client.prepareBulk();
                    /*      */
                    /*  879 */ int itemId = 0;
                    /*  880 */ JsonNode json;
                    while ((json = parser.nextObject()) != null) {
                        /*  881 */ if (ElasticSearchEventService.log.isDebugEnabled()) {
                            /*  882 */ ElasticSearchEventService.log.debug(
                                    "Adding to bulk publish operation: [{}]",
                                    new String(payloads, parser.getRootObjectOffset(),
                                            parser.getRootObjectLength(), Charsets.UTF_8));
                            /*      */ }
                        /*      */
                        /*      */
                        /*      */
                        /*      */
                        /*  888 */ json = ElasticSearchEventService.this.ensurePickupTimestamp(json);
                        /*  889 */ json = ElasticSearchEventService.this.ensureEventTimestamp(json);
                        /*  890 */ IndexRequestBuilder irb = client.prepareIndex(indexName, docType)
                                .setSource(json.toString());
                        /*      */
                        /*      */
                        /*  893 */ if (requestId != null) {
                            /*  894 */ irb.setId(requestId + "-" + itemId++);
                            /*      */ }
                        /*  896 */ IndexRequest indexRequest = (IndexRequest) irb.request();
                        /*  897 */ builder.add(indexRequest);
                        /*      */ }
                    /*      */
                    /*  900 */ return builder;
                    /*      */ }
                /*  902 */ };
            /*  903 */ handleBulkRequest(accountNameFinal, eventTypeFinal, payloads, payloadOffset,
                    payloadLength, builderCallable);
            /*      */
            /*  905 */ return;
            /*      */ }
        /*      */ catch (BulkFailureException e) {
            /*  908 */ if (i == 0) {
                /*  909 */ for (BulkFailure bulkFailure : e.getFailures())
                /*      */ {
                    /*      */
                    /*  912 */ if (bulkFailure.getMessage().contains("TypeMissingException")) {
                        /*  913 */ this.eventTypeCache.invalidateEventTypeMetaData(accountName, eventType);
                        /*  914 */ break;
                        /*      */ }
                    /*      */
                    /*      */ }
                /*      */ } else
                /*  919 */ throw ElasticSearchServiceHelper.propagateAsException(e);
            /*      */ } catch (Exception e) {
            /*  921 */ throw ElasticSearchServiceHelper.propagateAsException(e);
            /*      */ }
        /*      */ }
    /*      */ }

From source file:com.infinities.keystone4j.admin.v3.auth.AuthResourceTest.java

@Test
public void testAuthenticateForTokenAndCheckAndValidateAndRevokeAndCheck()
        throws JsonGenerationException, JsonMappingException, IOException {
    domain = new Domain();
    domain.setId("default");
    AuthV3 auth = new AuthV3();
    auth.setIdentity(identity);//from   www .  j ava 2s.  com
    AuthV3Wrapper wrapper = new AuthV3Wrapper(auth);
    String json = JsonUtils.toJson(wrapper);
    JsonNode node = JsonUtils.convertToJsonNode(json);
    JsonNode authJson = node.get("auth");
    assertNotNull(authJson);
    JsonNode identityJson = authJson.get("identity");
    assertNotNull(identityJson);
    JsonNode methodsJson = identityJson.get("methods");
    assertEquals(1, methodsJson.size());
    assertEquals("password", methodsJson.get(0).asText());
    JsonNode passwordJson = identityJson.get("password");
    assertNotNull(passwordJson);
    JsonNode userJson = passwordJson.get("user");
    assertNotNull(userJson);
    assertEquals("e7912c2225e84ac5905d8cf0b5040a6d", userJson.get("id").asText());
    assertEquals("f00@bar", userJson.get("password").asText());

    // authenticate
    Response response = target("/v3").path("auth").path("tokens").register(JacksonFeature.class).request()
            .post(Entity.entity(wrapper, MediaType.APPLICATION_JSON_TYPE));

    assertEquals(201, response.getStatus());
    String tokenid = response.getHeaderString("X-Subject-Token");

    assertNotNull(tokenid);

    node = JsonUtils.convertToJsonNode(response.readEntity(String.class));
    System.err.println(node);
    JsonNode tokenJ = node.get("token");
    assertNotNull(tokenJ);
    assertNotNull(tokenJ.get("expires_at").asText());
    assertNotNull(tokenJ.get("issued_at").asText());
    assertEquals("password", tokenJ.get("methods").get(0).asText());

    JsonNode userJ = tokenJ.get("user");
    assertEquals(user.getId(), userJ.get("id").asText());
    assertEquals(domain.getId(), userJ.get("domain").get("id").asText());

    // check
    response = target("/v3").path("auth").path("tokens").register(JacksonFeature.class)
            .register(ObjectMapperResolver.class).request()
            .header("X-Auth-Token", Config.Instance.getOpt(Config.Type.DEFAULT, "admin_token").asText())
            .header("X-Subject-Token", tokenid).head();
    assertEquals(200, response.getStatus());

    // validate
    response = target("/v3/auth/tokens").register(JacksonFeature.class).register(ObjectMapperResolver.class)
            .request()
            .header("X-Auth-Token", Config.Instance.getOpt(Config.Type.DEFAULT, "admin_token").asText())
            .header("X-Subject-Token", tokenid).get();
    assertEquals(200, response.getStatus());
    assertEquals(tokenid, response.getHeaderString("X-Subject-Token"));

    node = JsonUtils.convertToJsonNode(response.readEntity(String.class));
    tokenJ = node.get("token");
    assertNotNull(tokenJ);
    assertNotNull(tokenJ.get("expires_at").asText());
    assertNotNull(tokenJ.get("issued_at").asText());
    assertEquals("password", tokenJ.get("methods").get(0).asText());

    userJ = tokenJ.get("user");
    assertEquals(user.getId(), userJ.get("id").asText());
    assertEquals(domain.getId(), userJ.get("domain").get("id").asText());
    System.err.println(node.toString());

    // revoke
    response = target("/v3/auth/tokens").register(JacksonFeature.class).register(ObjectMapperResolver.class)
            .request()
            .header("X-Auth-Token", Config.Instance.getOpt(Config.Type.DEFAULT, "admin_token").asText())
            .header("X-Subject-Token", tokenid).delete();
    assertEquals(204, response.getStatus());

    response = target("/v3").path("auth").path("tokens").register(JacksonFeature.class)
            .register(ObjectMapperResolver.class).request()
            .header("X-Auth-Token", Config.Instance.getOpt(Config.Type.DEFAULT, "admin_token").asText())
            .header("X-Subject-Token", tokenid).head();
    assertEquals(404, response.getStatus());
}

From source file:com.redhat.lightblue.metadata.rdbms.parser.RDBMSPropertyParserImplTest.java

@Test
public void convertAndParseStatement() throws IOException {
    String json = "{\"rdbms\":{\"dialect\":\"oracle\",\"SQLMapping\": {\"columnToFieldMap\":[{\"table\":\"t\",\"column\":\"c\",\"field\":\"f\"}], \"joins\" :[{\"tables\":[{\"name\":\"n\",\"alias\":\"a\"}],\"joinTablesStatement\" : \"x\", \"projectionMappings\": [{\"column\":\"c\",\"field\":\"f\",\"sort\":\"s\"}]}]},\"delete\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"fetch\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"insert\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"save\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"update\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]}}}";

    JsonNode rJSON = p.newNode();
    RDBMS r = new RDBMS();
    r.setDialect("oracle");
    r.setSQLMapping(new SQLMapping());
    r.getSQLMapping().setJoins(new ArrayList<Join>());
    r.getSQLMapping().getJoins().add(new Join());
    r.getSQLMapping().getJoins().get(0).setJoinTablesStatement("x");
    r.getSQLMapping().getJoins().get(0).setProjectionMappings(new ArrayList<ProjectionMapping>());
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().add(new ProjectionMapping());
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().get(0).setColumn("c");
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().get(0).setField("f");
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().get(0).setSort("s");
    r.getSQLMapping().getJoins().get(0).setTables(new ArrayList<Table>());
    r.getSQLMapping().getJoins().get(0).getTables().add(new Table());
    r.getSQLMapping().getJoins().get(0).getTables().get(0).setAlias("a");
    r.getSQLMapping().getJoins().get(0).getTables().get(0).setName("n");
    r.getSQLMapping().setColumnToFieldMap(new ArrayList<ColumnToField>());
    r.getSQLMapping().getColumnToFieldMap().add(new ColumnToField());
    r.getSQLMapping().getColumnToFieldMap().get(0).setColumn("c");
    r.getSQLMapping().getColumnToFieldMap().get(0).setField("f");
    r.getSQLMapping().getColumnToFieldMap().get(0).setTable("t");
    Operation o = new Operation();
    ArrayList<Expression> expressionList = new ArrayList<Expression>();
    Statement e1 = new Statement();
    e1.setSQL("REQ EXPRESSION");
    e1.setType("select");
    expressionList.add(e1);//from  w w  w  . ja  v a  2 s .  c  o  m
    o.setExpressionList(expressionList);
    r.setDelete(duplicate("delete", o));
    r.setFetch(duplicate("fetch", o));
    r.setInsert(duplicate("insert", o));
    r.setSave(duplicate("save", o));
    r.setUpdate(duplicate("update", o));
    cut.convert(p, rJSON, r);
    assertEqualJson(json, rJSON.toString());

    Object ro = cut.parse("rdbms", p, JsonUtils.json(json).get("rdbms"));
    JsonNode roJSON = p.newNode();
    cut.convert(p, roJSON, ro);
    assertEqualJson(json, roJSON.toString());
    assertEqualJson(roJSON.toString(), rJSON.toString());
}

From source file:com.redhat.lightblue.metadata.rdbms.parser.RDBMSPropertyParserImplTest.java

@Test
public void convertAndParseBindingsNone() throws IOException {
    String json = "{\"rdbms\":{\"dialect\":\"oracle\",\"SQLMapping\": {\"columnToFieldMap\":[{\"table\":\"t\",\"column\":\"c\",\"field\":\"f\"}], \"joins\" :[{\"tables\":[{\"name\":\"n\",\"alias\":\"a\"}],\"joinTablesStatement\" : \"x\", \"projectionMappings\": [{\"column\":\"c\",\"field\":\"f\",\"sort\":\"s\"}]}]},\"delete\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"fetch\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"insert\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"save\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]},\"update\":{\"expressions\":[{\"statement\":{\"sql\":\"REQ EXPRESSION\",\"type\":\"select\"}}]}}}";

    JsonNode rJSON = p.newNode();
    RDBMS r = new RDBMS();
    r.setDialect("oracle");
    r.setSQLMapping(new SQLMapping());
    r.getSQLMapping().setJoins(new ArrayList<Join>());
    r.getSQLMapping().getJoins().add(new Join());
    r.getSQLMapping().getJoins().get(0).setJoinTablesStatement("x");
    r.getSQLMapping().getJoins().get(0).setProjectionMappings(new ArrayList<ProjectionMapping>());
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().add(new ProjectionMapping());
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().get(0).setColumn("c");
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().get(0).setField("f");
    r.getSQLMapping().getJoins().get(0).getProjectionMappings().get(0).setSort("s");
    r.getSQLMapping().getJoins().get(0).setTables(new ArrayList<Table>());
    r.getSQLMapping().getJoins().get(0).getTables().add(new Table());
    r.getSQLMapping().getJoins().get(0).getTables().get(0).setAlias("a");
    r.getSQLMapping().getJoins().get(0).getTables().get(0).setName("n");
    r.getSQLMapping().setColumnToFieldMap(new ArrayList<ColumnToField>());
    r.getSQLMapping().getColumnToFieldMap().add(new ColumnToField());
    r.getSQLMapping().getColumnToFieldMap().get(0).setColumn("c");
    r.getSQLMapping().getColumnToFieldMap().get(0).setField("f");
    r.getSQLMapping().getColumnToFieldMap().get(0).setTable("t");
    Operation o = new Operation();

    //No  bindings
    Bindings b = null;/*  w  w w  .  jav a 2s . com*/

    o.setBindings(b);
    ArrayList<Expression> expressionList = new ArrayList<Expression>();
    Statement e1 = new Statement();
    e1.setSQL("REQ EXPRESSION");
    e1.setType("select");
    expressionList.add(e1);
    o.setExpressionList(expressionList);
    r.setDelete(duplicate("delete", o));
    r.setFetch(duplicate("fetch", o));
    r.setInsert(duplicate("insert", o));
    r.setSave(duplicate("save", o));
    r.setUpdate(duplicate("update", o));
    cut.convert(p, rJSON, r);
    assertEqualJson(json, rJSON.toString());

    Object ro = cut.parse("rdbms", p, JsonUtils.json(json).get("rdbms"));
    JsonNode roJSON = p.newNode();
    cut.convert(p, roJSON, ro);
    assertEqualJson(json, roJSON.toString());
    assertEqualJson(roJSON.toString(), rJSON.toString());
}

From source file:com.appdynamics.analytics.processor.event.ElasticSearchEventService.java

private boolean updateExistingAliases(Client client, IndicesAliasesRequestBuilder rb,
        String accountSearchAlias, EventTypeMetaData metaData)
/*      */ {/*from  w  ww .  ja  va2 s  .  co m*/
    /* 1833 */ GetAliasesResponse aliasesResponse = (GetAliasesResponse) client.admin().indices()
            .prepareGetAliases(new String[] { accountSearchAlias }).execute().actionGet();
    /*      */
    /* 1835 */ UnmodifiableIterator<String> keysIt = aliasesResponse.getAliases().keysIt();
    /* 1836 */ boolean addedAlias = false;
    /* 1837 */ String key;
    while (keysIt.hasNext()) {
        /* 1838 */ key = (String) keysIt.next();
        /* 1839 */ List<AliasMetaData> aliasMetaDatas = (List) aliasesResponse.getAliases().get(key);
        /* 1840 */ for (AliasMetaData aliasMetaData : aliasMetaDatas) {
            /* 1841 */ if (aliasMetaData.filteringRequired()) {
                /*      */ try {
                    /* 1843 */ String filter = aliasMetaData.getFilter().string();
                    /* 1844 */ JsonNode filterNode = Reader.DEFAULT_JSON_MAPPER.readTree(filter);
                    /* 1845 */ if ((filterNode.get("bool") != null)
                            && (filterNode.get("bool").get("must") != null))
                    /*      */ {
                        /* 1847 */ ObjectNode pickupTimestampNode = null;
                        /* 1848 */ if (filterNode.get("bool").get("must").isArray()) {
                            /* 1849 */ for (JsonNode node : filterNode.get("bool").get("must")) {
                                /* 1850 */ if (node.has("range")) {
                                    /* 1851 */ pickupTimestampNode = (ObjectNode) node.get("range")
                                            .get("pickupTimestamp");
                                    /*      */ }
                                /*      */ }
                            /* 1854 */ } else if (filterNode.get("bool").get("must").get("range") != null) {
                            /* 1855 */ pickupTimestampNode = (ObjectNode) filterNode.get("bool").get("must")
                                    .get("range").get("pickupTimestamp");
                            /*      */ }
                        /*      */
                        /* 1858 */ if (pickupTimestampNode != null) {
                            /* 1859 */ pickupTimestampNode.put("from", buildHotLifespanFilter(metaData));
                            /* 1860 */ pickupTimestampNode.put("include_upper",
                                    metaData.getHotLifespanInDays().intValue() > 0);
                            /*      */ }
                        /*      */ }
                    /* 1863 */ rb.addAlias(key, aliasMetaData.alias(), filterNode.toString());
                    /* 1864 */ addedAlias = true;
                    /*      */ } catch (IOException e) {
                    /* 1866 */ throw Throwables.propagate(e);
                    /*      */ }
                /*      */ }
            /*      */ }
        /*      */ }
    /*      */
    /* 1872 */ return addedAlias;
    /*      */ }