Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2113#discussion_r143334704
  
    --- Diff: 
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-5-processors/src/main/java/org/apache/nifi/processors/elasticsearch/JsonQueryElasticsearch5.java
 ---
    @@ -0,0 +1,459 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.processors.elasticsearch;
    +
    +import org.apache.commons.io.IOUtils;
    +import org.apache.http.HttpEntity;
    +import org.apache.http.HttpHost;
    +import org.apache.http.auth.AuthScope;
    +import org.apache.http.auth.UsernamePasswordCredentials;
    +import org.apache.http.client.CredentialsProvider;
    +import org.apache.http.client.config.RequestConfig;
    +import org.apache.http.entity.ContentType;
    +import org.apache.http.impl.client.BasicCredentialsProvider;
    +import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
    +import org.apache.http.nio.entity.NStringEntity;
    +import org.apache.nifi.annotation.behavior.EventDriven;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.behavior.SupportsBatching;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
    +import org.apache.nifi.components.AllowableValue;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.components.Validator;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.io.OutputStreamCallback;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.ssl.SSLContextService;
    +import org.codehaus.jackson.map.ObjectMapper;
    +import org.elasticsearch.client.Response;
    +import org.elasticsearch.client.RestClient;
    +import org.elasticsearch.client.RestClientBuilder;
    +
    +import javax.net.ssl.KeyManagerFactory;
    +import javax.net.ssl.SSLContext;
    +import javax.net.ssl.TrustManagerFactory;
    +import java.io.FileInputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.OutputStream;
    +import java.net.URL;
    +import java.security.KeyStore;
    +import java.security.SecureRandom;
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +
    +
    +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
    +@EventDriven
    +@SupportsBatching
    +@Tags({"elasticsearch", "elasticsearch 5", "fetch", "read", "get"})
    +@CapabilityDescription("Retrieves a document from Elasticsearch using the 
specified connection properties and the "
    +        + "identifier of the document to retrieve. If the cluster has been 
configured for authorization and/or secure "
    +        + "transport (SSL/TLS), and the X-Pack plugin is available, secure 
connections can be made. This processor "
    +        + "supports Elasticsearch 5.x clusters.")
    +public class JsonQueryElasticsearch5 extends AbstractProcessor {
    +
    +    private RestClient client;
    +
    +    public static final Relationship REL_SUCCESS = new 
Relationship.Builder().name("success")
    +            .description("All original flowfiles that don't cause an error 
to occur go to this relationship").build();
    +
    +    public static final Relationship REL_FAILURE = new 
Relationship.Builder().name("failure")
    +            .description("All FlowFiles that cannot be read from 
Elasticsearch are routed to this relationship").build();
    +
    +    public static final Relationship REL_HITS = new 
Relationship.Builder().name("hits")
    +            .description("Search hits are routed to this relationship.")
    +            .build();
    +
    +    public static final Relationship REL_AGGREGATIONS = new 
Relationship.Builder().name("aggregations")
    +            .description("Aggregations are routed to this relationship.")
    +            .build();
    +
    +    public static final PropertyDescriptor INDEX = new 
PropertyDescriptor.Builder()
    +            .name("el5-fetch-index")
    +            .displayName("Index")
    +            .description("The name of the index to read from")
    +            .required(true)
    +            .expressionLanguageSupported(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor TYPE = new 
PropertyDescriptor.Builder()
    +            .name("el5-type")
    +            .displayName("Type")
    +            .description("The type of this document (used by Elasticsearch 
for indexing and searching)")
    +            .defaultValue("")
    +            .required(false)
    +            .expressionLanguageSupported(true)
    +            .addValidator(Validator.VALID)
    +            .build();
    +
    +    public static final PropertyDescriptor QUERY = new 
PropertyDescriptor.Builder()
    +            .name("el5-query")
    +            .displayName("Query")
    +            .description("A query in JSON syntax, not Lucene syntax.")
    +            .required(true)
    +            .expressionLanguageSupported(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor HTTP_HOSTS = new 
PropertyDescriptor.Builder()
    +            .name("el5-http-hosts")
    +            .displayName("HTTP Hosts")
    +            .description("A comma-separated list of HTTP hosts that host 
ElasticSearch query nodes.")
    +            .required(true)
    +            .expressionLanguageSupported(false)
    --- End diff --
    
    I think other processors have allowed EL in the password, it's not very 
secure without encrypted properties/registry entries, but that might be 
acceptable for some use cases


---

Reply via email to