Examples of XContentBuilder


Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @return JSON builder with comment document for index
   * @throws Exception
   */
  protected XContentBuilder prepareCommentIndexedDocument(String spaceKey, String documentId,
      Map<String, Object> comment) throws Exception {
    XContentBuilder out = jsonBuilder().startObject();
    addValueToTheIndexField(out, indexFieldForRiverName, riverName);
    addValueToTheIndexField(out, indexFieldForSpaceKey, spaceKey);
    addValueToTheIndexField(out, indexFieldForRemoteDocumentId, documentId);
    addCommonFieldsToCommentIndexedDocument(out, documentId, comment);
    return out.endObject();
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @param message to be placed in document
   * @return document with message
   * @throws IOException
   */
  public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
    XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
    builder.startObject();
    builder.field("message", message);
    builder.endObject();
    return builder;
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

                if (node.getRiverNames() != null) {
                  allRivers.addAll(node.getRiverNames());
                }
              }

              XContentBuilder builder = restChannel.newBuilder();
              builder.startObject();
              builder.field("river_names", allRivers);
              builder.endObject();
              restChannel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
            } catch (Exception e) {
              onFailure(e);
            }
          }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @throws Exception
   */
  @Override
  public String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception {

    XContentBuilder builder = jsonBuilder().prettyPrint();
    builder.startObject();
    builder.field("river_name", riverName().getName());
    builder.field("info_date", currentDate);
    builder.startObject("indexing");
    builder.field("state", closed ? "stopped" : "running");
    if (!closed)
      builder.field("last_restart", lastRestartDate);
    else if (permanentStopDate != null)
      builder.field("stopped_permanently", permanentStopDate);
    builder.endObject();
    if (esNode != null) {
      builder.startObject("node");
      builder.field("id", esNode.getId());
      builder.field("name", esNode.getName());
      builder.endObject();
    }
    if (coordinatorInstance != null) {
      List<ProjectIndexingInfo> currProjectIndexingInfo = coordinatorInstance.getCurrentProjectIndexingInfo();
      if (currProjectIndexingInfo != null) {
        builder.startArray("current_indexing");
        for (ProjectIndexingInfo pi : currProjectIndexingInfo) {
          pi.buildDocument(builder, true, false);
        }
        builder.endArray();
      }
    }
    List<String> pkeys = getAllIndexedProjectsKeys();
    if (pkeys != null) {
      builder.startArray("indexed_jira_projects");
      for (String projectKey : pkeys) {
        builder.startObject();
        builder.field("project_key", projectKey);
        ProjectIndexingInfo lastIndexing = getLastProjectIndexingInfo(projectKey);
        if (lastIndexing != null) {
          builder.field("last_indexing");
          lastIndexing.buildDocument(builder, false, true);
        }
        builder.endObject();
      }
      builder.endArray();
    }
    builder.endObject();
    return builder.string();
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @see #storeDatetimeValue(String, String, Date, BulkRequestBuilder)
   * @see #readDatetimeValue(String, String)
   */
  protected XContentBuilder storeDatetimeValueBuildDocument(String projectKey, String propertyName, Date datetime)
      throws IOException {
    XContentBuilder builder = jsonBuilder().startObject();
    if (projectKey != null)
      builder.field("projectKey", projectKey);
    builder.field("propertyName", propertyName).field(STORE_FIELD_VALUE, DateTimeUtils.formatISODateTime(datetime));
    builder.endObject();
    return builder;
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   */
  protected XContentBuilder prepareIssueIndexedDocument(String jiraProjectKey, Map<String, Object> issue)
      throws Exception {
    String issueKey = extractIssueKey(issue);

    XContentBuilder out = jsonBuilder().startObject();
    addValueToTheIndexField(out, indexFieldForRiverName, riverName);
    addValueToTheIndexField(out, indexFieldForProjectKey, jiraProjectKey);
    addValueToTheIndexField(out, indexFieldForIssueKey, issueKey);
    addValueToTheIndexField(out, indexFieldForJiraURL, prepareJIRAGUIUrl(issueKey, null));

    for (String indexFieldName : fieldsConfig.keySet()) {
      Map<String, String> fieldConfig = fieldsConfig.get(indexFieldName);
      addValueToTheIndex(out, indexFieldName, fieldConfig.get(CONFIG_FIELDS_JIRAFIELD), issue,
          fieldConfig.get(CONFIG_FIELDS_VALUEFILTER));
    }

    if (commentIndexingMode == IssueCommentIndexingMode.EMBEDDED) {
      List<Map<String, Object>> comments = extractIssueComments(issue);
      if (comments != null && !comments.isEmpty()) {
        out.startArray(indexFieldForComments);
        for (Map<String, Object> comment : comments) {
          out.startObject();
          addCommonFieldsToCommentIndexedDocument(out, issueKey, comment);
          out.endObject();
        }
        out.endArray();
      }
    }
    if (changelogIndexingMode == IssueCommentIndexingMode.EMBEDDED) {
      List<Map<String, Object>> changelogs = extractIssueChangelogs(issue);
      if (changelogs != null && !changelogs.isEmpty()) {
        out.startArray(indexFieldForChangelogs);
        for (Map<String, Object> changelog : changelogs) {
          out.startObject();
          addCommonFieldsToChangelogIndexedDocument(out, issueKey, changelog);
          out.endObject();
        }
        out.endArray();
      }
    }
    return out.endObject();
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @return JSON builder with comment document for index
   * @throws Exception
   */
  protected XContentBuilder prepareCommentIndexedDocument(String projectKey, String issueKey,
      Map<String, Object> comment) throws Exception {
    XContentBuilder out = jsonBuilder().startObject();
    addValueToTheIndexField(out, indexFieldForRiverName, riverName);
    addValueToTheIndexField(out, indexFieldForProjectKey, projectKey);
    addValueToTheIndexField(out, indexFieldForIssueKey, issueKey);
    addCommonFieldsToCommentIndexedDocument(out, issueKey, comment);
    return out.endObject();
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @return JSON builder with changelog document for index
   * @throws Exception
   */
  protected XContentBuilder prepareChangelogIndexedDocument(String projectKey, String issueKey,
      Map<String, Object> changelog) throws Exception {
    XContentBuilder out = jsonBuilder().startObject();
    addValueToTheIndexField(out, indexFieldForRiverName, riverName);
    addValueToTheIndexField(out, indexFieldForProjectKey, projectKey);
    addValueToTheIndexField(out, indexFieldForIssueKey, issueKey);
    addCommonFieldsToChangelogIndexedDocument(out, issueKey, changelog);
    return out.endObject();
  }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

                if (node.jiraRiverNames != null) {
                  allRivers.addAll(node.jiraRiverNames);
                }
              }

              XContentBuilder builder = restChannel.newBuilder();
              builder.startObject();
              builder.field("jira_river_names", allRivers);
              builder.endObject();
              restChannel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
            } catch (Exception e) {
              onFailure(e);
            }
          }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder

   * @param message to be placed in document
   * @return document with message
   * @throws IOException
   */
  public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
    XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
    builder.startObject();
    builder.field("message", message);
    builder.endObject();
    return builder;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.