dan-s1 commented on code in PR #9611:
URL: https://github.com/apache/nifi/pull/9611#discussion_r1915378100
##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGImport.java:
##########
@@ -85,6 +93,35 @@ public StringResult doExecute(final NiFiClient client, final
Properties properti
final boolean posXExists = StringUtils.isNotBlank(posXStr);
final boolean posYExists = StringUtils.isNotBlank(posYStr);
+ final File input = new File(inputSource);
+
+ if (StringUtils.isBlank(inputSource)) {
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("Input path is not
specified so Bucket ID must be specified");
+ }
+ if (StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("Input path is not
specified so Flow ID must be specified");
+ }
+ if (StringUtils.isBlank(flowVersion)) {
+ throw new IllegalArgumentException("Input path is not
specified so Flow Version must be specified");
+ }
+ } else {
+ if (!input.exists() || !input.isFile() || !input.canRead()) {
+ throw new IllegalArgumentException("Specified input is not a
local readable file: " + inputSource);
+ }
+ if (!StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("Input path is specified so
Bucket ID should not be specified");
+ }
+ if (!StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("Input path is specified so
Flow ID should not be specified");
+ }
+ if (!StringUtils.isBlank(flowVersion)) {
+ throw new IllegalArgumentException("Input path is specified so
Flow Version should not be specified");
+ }
+ if (!StringUtils.isBlank(flowBranch)) {
+ throw new IllegalArgumentException("Input path is specified so
Flow Branch should not be specified");
+ }
Review Comment:
Instead of `!StringUtils.isBlank` use Apache Commons `StringUtils
isNotBlank` as you did on line 188. This may be a preference but I believe the
use of this conveys a clearer intention.
##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGImport.java:
##########
@@ -43,6 +46,8 @@
*/
public class PGImport extends AbstractNiFiCommand<StringResult> {
+ private final static ObjectMapper objectMapper = new ObjectMapper();
Review Comment:
Java standard is to have private static final variables with upper case
names.
```suggestion
private final static ObjectMapper OBJECT_MAPPER = new ObjectMapper();
```
##########
nifi-toolkit/nifi-toolkit-client/src/main/java/org/apache/nifi/toolkit/client/impl/JerseyProcessGroupClient.java:
##########
@@ -378,4 +381,35 @@ public PasteResponseEntity paste(String processGroupId,
PasteRequestEntity paste
PasteResponseEntity.class);
});
}
+
+ @Override
+ public ProcessGroupEntity upload(String parentPgId, File file, String
pgName, Double posX, Double posY) throws NiFiClientException, IOException {
+ if (StringUtils.isBlank(parentPgId)) {
+ throw new IllegalArgumentException("Parent process group id cannot
be null or blank");
+ }
+ if (file == null) {
+ throw new IllegalArgumentException("File cannot be null");
+ }
+ if (!file.exists() || !file.canRead()) {
+ throw new IllegalArgumentException("File does not exist: " +
file.getAbsolutePath());
Review Comment:
This message is misleading if the issue is `!file.canRead()` as the file may
exist yet there are no read permissions.
--
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]