[GitHub] [nifi] turcsanyip commented on a diff in pull request #6892: NIFI-11059 PutBoxFile processor
turcsanyip commented on code in PR #6892: URL: https://github.com/apache/nifi/pull/6892#discussion_r1094353463 ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/BoxFileAttributes.java: ## @@ -0,0 +1,44 @@ +/* + * 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.box; + +import org.apache.nifi.flowfile.attributes.CoreAttributes; + +public class BoxFileAttributes { + +public static final String ID = "box.id"; +public static final String ID_DESC = "The id of the file"; + +public static final String FILENAME = CoreAttributes.FILENAME.key(); +public static final String FILENAME_DESC = "The name of the file"; + +public static final String PATH = CoreAttributes.PATH.key(); +public static final String PATH_DESC = "The folder path where the file is located"; Review Comment: It seems a better option to introduce special annotations for core attributes in a separate jira. Closing this thread. -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi] turcsanyip commented on a diff in pull request #6892: NIFI-11059 PutBoxFile processor
turcsanyip commented on code in PR #6892: URL: https://github.com/apache/nifi/pull/6892#discussion_r1093774027 ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/PutBoxFileTest.java: ## @@ -0,0 +1,206 @@ +/* + * 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.box; + +import static java.lang.String.format; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.box.sdk.BoxFile; +import com.box.sdk.BoxFolder; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.nifi.flowfile.attributes.CoreAttributes; +import org.apache.nifi.provenance.ProvenanceEventType; +import org.apache.nifi.util.MockFlowFile; +import org.apache.nifi.util.TestRunners; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class PutBoxFileTest extends AbstractBoxFileTest { + +public static final String SUBFOLDER1_ID = ""; +public static final String SUBFOLDER2_ID = ""; +@Mock +protected BoxFolder.Info mockSubfolder1Info; + +@Mock +protected BoxFolder.Info mockSubfolder2Info; + +@Mock +protected BoxFolder mockSubfolder1; + +@Mock +protected BoxFolder mockSubfolder2; + +@BeforeEach +void setUp() throws Exception { +final PutBoxFile testSubject = new PutBoxFile() { + +@Override +BoxFolder getFolder(String folderId) { +if (folderId.equals(SUBFOLDER1_ID)) { +return mockSubfolder1; +} else if (folderId.equals(SUBFOLDER2_ID)) { +return mockSubfolder2; +} +return mockBoxFolder; Review Comment: Minor: It would be nicer to create a lookup map with these items and simply get the folder by `folderId` in the method. I guess `mockBoxFolder` also has an id too. ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java: ## @@ -0,0 +1,431 @@ +/* + * 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.box; + +import static java.lang.String.format; +import static java.lang.String.valueOf; +import static java.util.Arrays.asList; +import static org.apache.nifi.processor.util.StandardValidators.createRegexMatchingValidator; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.FILENAME_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID_DESC; +im
[GitHub] [nifi] turcsanyip commented on a diff in pull request #6892: NIFI-11059 PutBoxFile processor
turcsanyip commented on code in PR #6892: URL: https://github.com/apache/nifi/pull/6892#discussion_r1090685097 ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/main/resources/docs/org.apache.nifi.processors.box.PutBoxFile/additionalDetails.html: ## @@ -0,0 +1,45 @@ + +http://www.w3.org/1999/html";> + + + + +PutBoxFile + + + + +Upload files to Box from NiFi + + +Find Folder ID + +Navigate to the folder in Box and enter it. The URL in your browser will include the ID at the end of +the URL. +For example, if the URL were https://app.box.com/folder/191632099757, the +Folder ID would be 191632099757 + + + +Set Folder ID in 'Folder ID' property + + + + + + + + Review Comment: These tags are duplicated at the end of the HTML file. Could you please remove them? Also on the List processor's page. ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java: ## @@ -0,0 +1,407 @@ +/* + * 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.box; + +import static java.lang.String.format; +import static java.lang.String.valueOf; +import static java.util.Arrays.asList; +import static org.apache.nifi.processor.util.StandardValidators.createRegexMatchingValidator; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.FILENAME_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.PATH_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.SIZE; +import static org.apache.nifi.processors.box.BoxFileAttributes.SIZE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.TIMESTAMP; +import static org.apache.nifi.processors.box.BoxFileAttributes.TIMESTAMP_DESC; +import static org.apache.nifi.processors.box.BoxFileUtils.BOX_URL; +import static org.apache.nifi.processors.conflict.resolution.ConflictResolutionStrategy.IGNORE; +import static org.apache.nifi.processors.conflict.resolution.ConflictResolutionStrategy.REPLACE; + +import com.box.sdk.BoxAPIConnection; +import com.box.sdk.BoxAPIException; +import com.box.sdk.BoxAPIResponseException; +import com.box.sdk.BoxFile; +import com.box.sdk.BoxFolder; +import com.box.sdk.BoxFolder.Info; +import com.box.sdk.BoxItem; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; +import java.util.stream.StreamSupport; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.ReadsAttribute; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +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.annotation.lifecycle.OnScheduled; +import org.apache.nifi.box.controllerservices.BoxClientService; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.DataUnit; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apa
[GitHub] [nifi] turcsanyip commented on a diff in pull request #6892: NIFI-11059 PutBoxFile processor
turcsanyip commented on code in PR #6892: URL: https://github.com/apache/nifi/pull/6892#discussion_r1088387924 ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java: ## @@ -0,0 +1,366 @@ +/* + * 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.box; + +import static java.lang.String.format; +import static java.lang.String.valueOf; +import static java.util.Arrays.asList; +import static org.apache.nifi.processor.util.StandardValidators.createRegexMatchingValidator; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.FILENAME_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.PATH_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.SIZE; +import static org.apache.nifi.processors.box.BoxFileAttributes.SIZE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.TIMESTAMP; +import static org.apache.nifi.processors.box.BoxFileAttributes.TIMESTAMP_DESC; +import static org.apache.nifi.processors.box.BoxFileUtils.BOX_URL; + +import com.box.sdk.BoxAPIConnection; +import com.box.sdk.BoxAPIException; +import com.box.sdk.BoxAPIResponseException; +import com.box.sdk.BoxFile; +import com.box.sdk.BoxFolder; +import java.io.InputStream; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; +import java.util.stream.StreamSupport; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.ReadsAttribute; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +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.annotation.lifecycle.OnScheduled; +import org.apache.nifi.box.controllerservices.BoxClientService; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.DataUnit; +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; + + +@SeeAlso({ListBoxFile.class, FetchBoxFile.class}) +@InputRequirement(Requirement.INPUT_REQUIRED) +@Tags({"box", "storage", "put"}) +@CapabilityDescription("Puts content to a Box folder.") +@ReadsAttribute(attribute = "filename", description = "Uses the FlowFile's filename as the filename for the Box object.") +@WritesAttributes({ +@WritesAttribute(attribute = ID, description = ID_DESC), +@WritesAttribute(attribute = "filename", description = FILENAME_DESC), +@WritesAttribute(attribute = "path", description = PATH_DESC), +@WritesAttribute(attribute = SIZE, description = SIZE_DESC), +@WritesAttribute(attribute = TIMESTAMP, description = TIMESTAMP_DESC), +@WritesAttribute(attribute = ERROR_CODE, description = ERROR_CODE_DESC), +@WritesAttribute(attribute = ERROR_MESSAGE, description = ERROR_MESSAGE_DESC)}) +public class PutBoxFile extends AbstractProcessor { +public static final int CHUNKED_UPLOAD_LOWER_LIMIT_IN_BYTES = 20 * 1024 * 1024; +public stati
[GitHub] [nifi] turcsanyip commented on a diff in pull request #6892: NIFI-11059 PutBoxFile processor
turcsanyip commented on code in PR #6892: URL: https://github.com/apache/nifi/pull/6892#discussion_r1088117506 ## nifi-nar-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java: ## @@ -0,0 +1,366 @@ +/* + * 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.box; + +import static java.lang.String.format; +import static java.lang.String.valueOf; +import static java.util.Arrays.asList; +import static org.apache.nifi.processor.util.StandardValidators.createRegexMatchingValidator; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_CODE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE; +import static org.apache.nifi.processors.box.BoxFileAttributes.ERROR_MESSAGE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.FILENAME_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID; +import static org.apache.nifi.processors.box.BoxFileAttributes.ID_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.PATH_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.SIZE; +import static org.apache.nifi.processors.box.BoxFileAttributes.SIZE_DESC; +import static org.apache.nifi.processors.box.BoxFileAttributes.TIMESTAMP; +import static org.apache.nifi.processors.box.BoxFileAttributes.TIMESTAMP_DESC; +import static org.apache.nifi.processors.box.BoxFileUtils.BOX_URL; + +import com.box.sdk.BoxAPIConnection; +import com.box.sdk.BoxAPIException; +import com.box.sdk.BoxAPIResponseException; +import com.box.sdk.BoxFile; +import com.box.sdk.BoxFolder; +import java.io.InputStream; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; +import java.util.stream.StreamSupport; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; +import org.apache.nifi.annotation.behavior.ReadsAttribute; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +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.annotation.lifecycle.OnScheduled; +import org.apache.nifi.box.controllerservices.BoxClientService; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.DataUnit; +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; + + +@SeeAlso({ListBoxFile.class, FetchBoxFile.class}) +@InputRequirement(Requirement.INPUT_REQUIRED) +@Tags({"box", "storage", "put"}) +@CapabilityDescription("Puts content to a Box folder.") +@ReadsAttribute(attribute = "filename", description = "Uses the FlowFile's filename as the filename for the Box object.") +@WritesAttributes({ +@WritesAttribute(attribute = ID, description = ID_DESC), +@WritesAttribute(attribute = "filename", description = FILENAME_DESC), +@WritesAttribute(attribute = "path", description = PATH_DESC), +@WritesAttribute(attribute = SIZE, description = SIZE_DESC), +@WritesAttribute(attribute = TIMESTAMP, description = TIMESTAMP_DESC), +@WritesAttribute(attribute = ERROR_CODE, description = ERROR_CODE_DESC), +@WritesAttribute(attribute = ERROR_MESSAGE, description = ERROR_MESSAGE_DESC)}) +public class PutBoxFile extends AbstractProcessor { +public static final int CHUNKED_UPLOAD_LOWER_LIMIT_IN_BYTES = 20 * 1024 * 1024; +public stati