[ https://issues.apache.org/jira/browse/NIFI-4345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16155970#comment-16155970
]
ASF GitHub Bot commented on NIFI-4345:
--------------------------------------
Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2123#discussion_r137376343
--- Diff: nifi-nar-bundles/nifi-standard-services/nifi-mongodb-services-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/AbstractMongoDBControllerService.java
---
@@ -0,0 +1,223 @@
+/*
+ * 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.mongodb;
+
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientOptions;
+import com.mongodb.MongoClientOptions.Builder;
+import com.mongodb.MongoClientURI;
+import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.authentication.exception.ProviderCreationException;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.security.util.SslContextFactory;
+import org.apache.nifi.ssl.SSLContextService;
+import org.bson.Document;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AbstractMongoDBControllerService extends AbstractControllerService {
+ static final String WRITE_CONCERN_ACKNOWLEDGED = "ACKNOWLEDGED";
+ static final String WRITE_CONCERN_UNACKNOWLEDGED = "UNACKNOWLEDGED";
+ static final String WRITE_CONCERN_FSYNCED = "FSYNCED";
+ static final String WRITE_CONCERN_JOURNALED = "JOURNALED";
+ static final String WRITE_CONCERN_REPLICA_ACKNOWLEDGED = "REPLICA_ACKNOWLEDGED";
+ static final String WRITE_CONCERN_MAJORITY = "MAJORITY";
+
+ protected static final PropertyDescriptor URI = new PropertyDescriptor.Builder()
+ .name("Mongo URI")
+ .description("MongoURI, typically of the form: mongodb://host1[:port1][,host2[:port2],...]")
+ .required(true)
+ .expressionLanguageSupported(true)
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
--- End diff --
If you'd like more validation here, you could write a custom Validator that uses [MongoClientURI](http://mongodb.github.io/mongo-java-driver/3.5/javadoc/com/mongodb/MongoClientURI.html)
to check if the URI is valid (I believe it throws an IllegalArgumentException if the URI is
not valid). Just a suggestion though, up to you :)
> Add a controller service and a lookup service for MongoDB
> ---------------------------------------------------------
>
> Key: NIFI-4345
> URL: https://issues.apache.org/jira/browse/NIFI-4345
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Mike Thomsen
>
> - Create a Controller Service that wraps the functionality of the Mongo driver.
> - Create a lookup service that can return elements based on a query.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
|