Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2671#discussion_r185740990 --- Diff: nifi-nar-bundles/nifi-marklogic-bundle/nifi-marklogic-processors/src/main/java/com/marklogic/nifi/processor/PutMarkLogic.java --- @@ -0,0 +1,382 @@ +/* + * 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 com.marklogic.nifi.processor; + +import com.marklogic.client.datamovement.DataMovementManager; +import com.marklogic.client.datamovement.WriteBatcher; +import com.marklogic.client.datamovement.WriteEvent; +import com.marklogic.client.datamovement.impl.WriteEventImpl; +import com.marklogic.client.document.ServerTransform; +import com.marklogic.client.io.BytesHandle; +import com.marklogic.client.io.DocumentMetadataHandle; +import com.marklogic.client.io.Format; +import org.apache.nifi.annotation.behavior.TriggerWhenEmpty; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.lifecycle.OnStopped; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.flowfile.attributes.CoreAttributes; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.ProcessorInitializationContext; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.stream.io.StreamUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * The TriggerWhenEmpty annotation is used so that this processor has a chance to flush the WriteBatcher when no + * flowfiles are ready to be received. + */ +@Tags({"MarkLogic"}) +@CapabilityDescription("Write batches of FlowFiles as documents to a MarkLogic server using the " + + "MarkLogic Data Movement SDK (DMSDK)") +@TriggerWhenEmpty +public class PutMarkLogic extends AbstractMarkLogicProcessor { + + class FlowFileInfo { + FlowFile flowFile; + ProcessSession session; + FlowFileInfo(FlowFile flowFile, ProcessSession session) { + this.flowFile = flowFile; + this.session = session; + } + } + private Map<String, FlowFileInfo> URIFlowFileMap = new HashMap<>(); + public static final PropertyDescriptor COLLECTIONS = new PropertyDescriptor.Builder() + .name("Collections") + .displayName("Collections") + .description("Comma-delimited sequence of collections to add to each document") + .addValidator(NO_VALIDATION_VALIDATOR) + .build(); + + public static final PropertyDescriptor FORMAT = new PropertyDescriptor.Builder() + .name("Format") + .displayName("Format") + .description("Format for each document; if not specified, MarkLogic will determine the format" + + " based on the URI") + .allowableValues(Format.JSON.name(), Format.XML.name(), Format.TEXT.name(), Format.BINARY.name(), Format.UNKNOWN.name()) + .addValidator(NO_VALIDATION_VALIDATOR) + .build(); + + public static final PropertyDescriptor JOB_ID = new PropertyDescriptor.Builder() + .name("Job ID") + .displayName("Job ID") + .description("ID for the WriteBatcher job") + .addValidator(NO_VALIDATION_VALIDATOR) + .build(); + + public static final PropertyDescriptor JOB_NAME = new PropertyDescriptor.Builder() + .name("Job Name") + .displayName("Job Name") + .description("Name for the WriteBatcher job") + .addValidator(NO_VALIDATION_VALIDATOR) --- End diff -- Change to Validator.VALID
---