jrsteinebrey commented on code in PR #8992: URL: https://github.com/apache/nifi/pull/8992#discussion_r1710460018
########## nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/GetS3ObjectMetadata.java: ########## @@ -0,0 +1,196 @@ +/* + * 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.aws.s3; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.model.AmazonS3Exception; +import com.amazonaws.services.s3.model.ObjectMetadata; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +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.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.util.StandardValidators; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.apache.nifi.processors.aws.util.RegionUtilV1.S3_REGION; + +@Tags({"Amazon", "S3", "AWS", "Archive", "Exists"}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@CapabilityDescription("Check for the existence of a file in S3 without attempting to download it. This processor can be " + + "used as a router for work flows that need to check on a file in S3 before proceeding with data processing") +@SeeAlso({PutS3Object.class, DeleteS3Object.class, ListS3.class, TagS3Object.class, DeleteS3Object.class, FetchS3Object.class}) +public class GetS3ObjectMetadata extends AbstractS3Processor { + public static final AllowableValue MODE_FETCH_METADATA = new AllowableValue("fetch", "Fetch Metadata", + "This is the default mode. It will fetch the metadata and write it to either the FlowFile content or an " + + "attribute"); + public static final AllowableValue MODE_ROUTER = new AllowableValue("router", "Router", "When selected," + + "this mode will skip writing the metadata and just send the FlowFile to the found or not-found relationship. It should be used " + + "when the goal is to just route FlowFiles based on whether or not a key is present in S3."); + public static final PropertyDescriptor MODE = new PropertyDescriptor.Builder() + .name("Mode") + .allowableValues(MODE_FETCH_METADATA, MODE_ROUTER) + .defaultValue(MODE_FETCH_METADATA.getValue()) + .required(true) + .description("Configure the mode of operation for this processor") + .addValidator(Validator.VALID) + .build(); + + public static final AllowableValue TARGET_ATTRIBUTE = new AllowableValue("attribute", "Attribute", "When " + + "selected, the metadata will be written to a user-supplied attribute"); + public static final AllowableValue TARGET_FLOWFILE_BODY = new AllowableValue("flowfile-content", "FlowFile Body", "Write " + Review Comment: @MikeThomsen Thanks so much for those latest separate attributes change. My previous comment might have been unclear, but I was/am asking for these changes also on this line: TARGET_FLOWFILE_BODY change to TARGET_FLOWFILE_CONTENT "FlowFile Body" change to "FlowFile Content" ########## nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/GetS3ObjectMetadata.java: ########## @@ -0,0 +1,196 @@ +/* + * 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.aws.s3; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.model.AmazonS3Exception; +import com.amazonaws.services.s3.model.ObjectMetadata; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +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.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.util.StandardValidators; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.apache.nifi.processors.aws.util.RegionUtilV1.S3_REGION; + +@Tags({"Amazon", "S3", "AWS", "Archive", "Exists"}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@CapabilityDescription("Check for the existence of a file in S3 without attempting to download it. This processor can be " + + "used as a router for work flows that need to check on a file in S3 before proceeding with data processing") +@SeeAlso({PutS3Object.class, DeleteS3Object.class, ListS3.class, TagS3Object.class, DeleteS3Object.class, FetchS3Object.class}) +public class GetS3ObjectMetadata extends AbstractS3Processor { + public static final AllowableValue MODE_FETCH_METADATA = new AllowableValue("fetch", "Fetch Metadata", + "This is the default mode. It will fetch the metadata and write it to either the FlowFile content or an " + + "attribute"); + public static final AllowableValue MODE_ROUTER = new AllowableValue("router", "Router", "When selected," + + "this mode will skip writing the metadata and just send the FlowFile to the found or not-found relationship. It should be used " + + "when the goal is to just route FlowFiles based on whether or not a key is present in S3."); + public static final PropertyDescriptor MODE = new PropertyDescriptor.Builder() + .name("Mode") + .allowableValues(MODE_FETCH_METADATA, MODE_ROUTER) + .defaultValue(MODE_FETCH_METADATA.getValue()) + .required(true) + .description("Configure the mode of operation for this processor") + .addValidator(Validator.VALID) + .build(); + + public static final AllowableValue TARGET_ATTRIBUTE = new AllowableValue("attribute", "Attribute", "When " + + "selected, the metadata will be written to a user-supplied attribute"); Review Comment: @MikeThomsen Thanks again for all your work on these. Could you please make these plural attributes because that will communicate it more clearly. TARGET_ATTRIBUTE change to TARGET_ATTRIBUTES AllowableValue("attribute", "Attribute", change to AllowableValue("attributes", "Attributes", OLD: metadata will be written to a user-supplied attribute would be clearer to change to NEW: metadata will be written to attributes beginning with the user-supplied prefix ########## nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/GetS3ObjectMetadata.java: ########## @@ -0,0 +1,196 @@ +/* + * 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.aws.s3; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.model.AmazonS3Exception; +import com.amazonaws.services.s3.model.ObjectMetadata; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +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.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.util.StandardValidators; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.apache.nifi.processors.aws.util.RegionUtilV1.S3_REGION; + +@Tags({"Amazon", "S3", "AWS", "Archive", "Exists"}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@CapabilityDescription("Check for the existence of a file in S3 without attempting to download it. This processor can be " + + "used as a router for work flows that need to check on a file in S3 before proceeding with data processing") +@SeeAlso({PutS3Object.class, DeleteS3Object.class, ListS3.class, TagS3Object.class, DeleteS3Object.class, FetchS3Object.class}) +public class GetS3ObjectMetadata extends AbstractS3Processor { + public static final AllowableValue MODE_FETCH_METADATA = new AllowableValue("fetch", "Fetch Metadata", + "This is the default mode. It will fetch the metadata and write it to either the FlowFile content or an " + + "attribute"); + public static final AllowableValue MODE_ROUTER = new AllowableValue("router", "Router", "When selected," + + "this mode will skip writing the metadata and just send the FlowFile to the found or not-found relationship. It should be used " + + "when the goal is to just route FlowFiles based on whether or not a key is present in S3."); + public static final PropertyDescriptor MODE = new PropertyDescriptor.Builder() + .name("Mode") + .allowableValues(MODE_FETCH_METADATA, MODE_ROUTER) + .defaultValue(MODE_FETCH_METADATA.getValue()) + .required(true) + .description("Configure the mode of operation for this processor") + .addValidator(Validator.VALID) + .build(); + + public static final AllowableValue TARGET_ATTRIBUTE = new AllowableValue("attribute", "Attribute", "When " + + "selected, the metadata will be written to a user-supplied attribute"); Review Comment: @MikeThomsen That is fine is ACL is not returned in that version of AWS Java SDK. That was just the sample I found. Could you post in here an example of the Metadata you do get back from that AWS Java SDK? Also could you post the separate FF attributes names and values that would be created for the sample given how the code is implemented now? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
