-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIFI-11059 PutBoxFile processor #6892
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this new Processor @krisztina-zsihovszki! I will defer to others for a more thorough code and functionality review, but I noted a handful of minor stylistic recommendations.
final BoxFile.Info fetchedFileInfo = createFileInfo(TEST_PATH, MODIFIED_TIME); | ||
doReturn(fetchedFileInfo).when(mockBoxFile).getInfo(); | ||
|
||
// WHEN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of WHEN
and THEN
comments should be avoided.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend avoiding reproducing the FILENAME
and PATH
attributes and using the CoreAttributes
enum directly.
} | ||
|
||
public static Map<String, String> createAttributeMap(Info fileInfo) { | ||
final Map<String, String> attributes = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend using LinkedHashMap
instead of HashMap
for deterministic ordering of attributes added.
outFlowFile = session.putAttribute(outFlowFile, ERROR_MESSAGE_ATTRIBUTE, e.getMessage()); | ||
|
||
session.transfer(outFlowFile, REL_FAILURE); | ||
flowFile = session.putAttribute(flowFile, ERROR_CODE, "" + e.getResponseCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good opportunity to adjust this approach. String.valueOf(e.getResponseCode())
should be used instead of concatenating an empty string to the response code.
REL_FAILURE | ||
))); | ||
|
||
public static final int CONFLICT_RESPONSE_CODE = 409; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this variable be protected
or private
?
getLogger().error("Exception occurred while uploading file '{}' to Box folder '{}'", filename, fullPath, e); | ||
handleExpectedError(session, flowFile, e); | ||
} catch (Exception e) { | ||
getLogger().error("Unexpected exception occurred while uploading file '{}' to Box folder '{}'", filename, fullPath, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getLogger().error("Unexpected exception occurred while uploading file '{}' to Box folder '{}'", filename, fullPath, e); | |
getLogger().error("Upload failed: File [{}] folder [{}]", filename, fullPath, e); |
} | ||
|
||
if (createFolder) { | ||
getLogger().debug("Create folder " + folderName + " parent id: " + parentFolderId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log statements should use placeholders:
getLogger().debug("Create folder " + folderName + " parent id: " + parentFolderId); | |
getLogger().debug("Creating Folder [{}] Parent [{}]", folderName, parentFolderId); |
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
getLogger().info("File with the same name '{}' already exists in '%s'. Remote file is not modified due to {} being set to '{}'.", | ||
filename, path, CONFLICT_RESOLUTION.getDisplayName(), conflictResolution); | ||
} else if (FAIL_RESOLUTION.equals(conflictResolution)) { | ||
throw new ProcessException(format("File with the same name '%s' already exists in '%s'.", filename, path), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend avoiding periods at the end of messages:
throw new ProcessException(format("File with the same name '%s' already exists in '%s'.", filename, path), e); | |
throw new ProcessException(format("File with the same name [%s] already exists in [%s]", filename, path), e); |
final String path = BoxFileUtils.getPath(folder.getInfo()); | ||
|
||
if (IGNORE_RESOLUTION.equals(conflictResolution)) { | ||
getLogger().info("File with the same name '{}' already exists in '%s'. Remote file is not modified due to {} being set to '{}'.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getLogger().info("File with the same name '{}' already exists in '%s'. Remote file is not modified due to {} being set to '{}'.", | |
getLogger().info("File with the same name [{}] already exists in [%s] Remote file is not modified due to [{}] being set to [{}]", |
public static final String IGNORE_RESOLUTION = "ignore"; | ||
public static final String REPLACE_RESOLUTION = "replace"; | ||
public static final String FAIL_RESOLUTION = "fail"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your work for NIFI-11068 in PR #6861, it looks like these variables can be replaced with the new ConflictResolutionStrategy
.
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...s/src/main/resources/docs/org.apache.nifi.processors.box.FetchBoxFile/additionalDetails.html
Outdated
Show resolved
Hide resolved
...s/src/main/resources/docs/org.apache.nifi.processors.box.FetchBoxFile/additionalDetails.html
Outdated
Show resolved
Hide resolved
...ors/src/main/resources/docs/org.apache.nifi.processors.box.PutBoxFile/additionalDetails.html
Outdated
Show resolved
Hide resolved
...ox-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/FetchBoxFile.java
Outdated
Show resolved
Hide resolved
...ox-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/FetchBoxFile.java
Outdated
Show resolved
Hide resolved
...ndle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/BoxFileAttributes.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
ebca5e4
to
0867d0a
Compare
...ox-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/FetchBoxFile.java
Outdated
Show resolved
Hide resolved
...ors/src/main/resources/docs/org.apache.nifi.processors.box.PutBoxFile/additionalDetails.html
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krisztina-zsihovszki Thanks for the latest changes!
I found only some minor issues / improvements. Pls. see my comments below.
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/PutBoxFile.java
Outdated
Show resolved
Hide resolved
...-bundle/nifi-box-processors/src/test/java/org/apache/nifi/processors/box/PutBoxFileTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @krisztina-zsihovszki!
+1 LGTM
@exceptionfactory Do you have any further comments or can we merge it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @krisztina-zsihovszki, looks good! No further comments @turcsanyip, feel free to merge!
@exceptionfactory Thanks for your review! |
Summary
NIFI-11059
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-11059
NIFI-11059
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation