Package org.elasticsearch.common.xcontent

Examples of org.elasticsearch.common.xcontent.XContentParser.mapAndClose()


    try {
      StringBuilder sb = new StringBuilder();
      sb.append("{ \"wrapit\" : ").append(new String(responseData, "UTF-8")).append("}");
      responseData = sb.toString().getBytes("UTF-8");
      parser = XContentFactory.xContent(XContentType.JSON).createParser(responseData);
      Map<String, Object> wrappedResponseParsed = parser.mapAndClose();
      return wrappedResponseParsed.get("wrapit");
    } finally {
      if (parser != null)
        parser.close();
    }
View Full Code Here


   */
  public static Map<String, Object> loadJSONFromJarPackagedFile(String filePath) throws SettingsException {
    XContentParser parser = null;
    try {
      parser = XContentFactory.xContent(XContentType.JSON).createParser(Utils.class.getResourceAsStream(filePath));
      Map<String, Object> ret = parser.mapAndClose();
      if (logger.isDebugEnabled())
        logger.debug("jar packaged JSON file {} content is: {}", filePath, ret);
      return ret;
    } catch (IOException e) {
      throw new SettingsException(e.getMessage(), e);
View Full Code Here

    try {
      StringBuilder sb = new StringBuilder();
      sb.append("{ \"wrapit\" : ").append(new String(responseData, "UTF-8")).append("}");
      responseData = sb.toString().getBytes("UTF-8");
      parser = XContentFactory.xContent(XContentType.JSON).createParser(responseData);
      Map<String, Object> wrappedResponseParsed = parser.mapAndClose();
      return wrappedResponseParsed.get("wrapit");
    } finally {
      if (parser != null)
        parser.close();
    }
View Full Code Here

    public void validateAliasStandalone(Alias alias) {
        validateAliasStandalone(alias.name(), alias.indexRouting());
        if (Strings.hasLength(alias.filter())) {
            try {
                XContentParser parser = XContentFactory.xContent(alias.filter()).createParser(alias.filter());
                parser.mapAndClose();
            } catch (Throwable e) {
                throw new ElasticsearchIllegalArgumentException("failed to parse filter for alias [" + alias.name() + "]", e);
            }
        }
    }
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.