-
Notifications
You must be signed in to change notification settings - Fork 726
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
[BISERVER-14935] import-export.bat/.sh does not work on Pentaho 9.3 or higher if requestParameterAuthenticationEnabled=true #5417
Conversation
This comment has been minimized.
This comment has been minimized.
String backupURL = contextURL + API_REPO_FILES_BACKUP; | ||
|
||
// BISERVER-14935: In case "requestParameterAuthenticationEnabled" is set to 'true' | ||
backupURL += ( "?userid=" + getUsername() + "&password=" + Encr.encryptPassword( |
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.
Here you are creating a string on line 736 and then creating a new one. Why not create the string with all data instead of reassigning a new value or use a StringBuilder.
...ns/src/main/java/org/pentaho/platform/plugin/services/importexport/CommandLineProcessor.java
Show resolved
Hide resolved
@@ -346,10 +362,10 @@ private void performREST() throws ParseException, KettleException, URISyntaxExce | |||
Messages.getInstance().getString( "CommandLineProcessor.INFO_REST_RESPONSE_STATUS", response.getStatus() ); | |||
message += "\n"; | |||
|
|||
if ( logFile != null && !"".equals( logFile ) ) { | |||
if ( logFile != null && !logFile.isEmpty() ) { |
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.
Why not StringUtils.isEmpty( logFile )?
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.
Done.
if ( logFile != null && !"".equals( logFile ) ) { | ||
writeFile( message.toString(), logFile ); | ||
System.out.println( message ); | ||
if ( logFile != null && !logFile.isEmpty() ) { |
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.
Why not StringUtils.isEmpty( logFile )?
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.
Done.
message += Messages.getInstance().getString( "CommandLineProcessor.INFO_EXPORT_WRITTEN_TO", filename ); | ||
if ( logFile != null && !"".equals( logFile ) ) { | ||
message += Messages.getInstance().getString( "CommandLineProcessor.INFO_EXPORT_WRITTEN_TO", outputFile ); | ||
if ( logFile != null && !logFile.isEmpty() ) { |
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.
Why not StringUtils.isEmpty( logFile )?
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.
Done.
message += Messages.getInstance().getString( "CommandLineProcessor.INFO_EXPORT_WRITTEN_TO", filename ); | ||
if ( logFile != null && !"".equals( logFile ) ) { | ||
message += Messages.getInstance().getString( "CommandLineProcessor.INFO_EXPORT_WRITTEN_TO", outputFile ); | ||
if ( logFile != null && !logFile.isEmpty() ) { |
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.
Why not StringUtils.isEmpty( logFile )?
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.
Done.
} | ||
} | ||
|
||
if ( !isValid && logFile != null && !"".equals( logFile ) ) { | ||
writeFile( "Invalid file-path:" + filePath, logFile ); | ||
if ( !isValid && logFile != null && !logFile.isEmpty() ) { |
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.
Why not StringUtils.isEmpty( logFile )?
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.
Done.
if ( StringUtils.isEmpty( value ) ) { | ||
// Is it required? | ||
if ( required ) { | ||
throw new ParseException( Messages.getInstance().getErrorString( "CommandLineProcessor.ERROR_0001_MISSING_ARG", |
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.
You are returning the same message and same exception. Could you rewrite it in a OR format?
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.
Bruno has a point. We can join the two inner if's
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.
Done.
if ( StringUtils.isEmpty( value ) ) { | ||
// Is it required? | ||
if ( required ) { | ||
throw new ParseException( Messages.getInstance().getErrorString( "CommandLineProcessor.ERROR_0001_MISSING_ARG", |
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.
Bruno has a point. We can join the two inner if's
…r higher if requestParameterAuthenticationEnabled=true
…r higher if requestParameterAuthenticationEnabled=true Cleanup: - use of constants - extract methods - use of try-resource - remove old unused methods - clean exceptions - refactor code to write to file
…r higher if requestParameterAuthenticationEnabled=true Address the comments on the PR review
ab1a2c8
to
7116ba7
Compare
✅ Build finished in 42m 37sBuild command: mvn clean verify -B -e -Daudit -amd -pl extensions 👌 All tests passed! Tests run: 1693, Failures: 0, Skipped: 1 Test Results ℹ️ This is an automatic message |
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.
Looks good!
Two commits on this PR: the first is the actual fix for this issue's problem; the second is a refactoring of the class to fix some sonar issues and some architectural problems found during the test and development of the first.
@bcostahitachivantara @renato-s @andreramos89