Skip to content

Commit

Permalink
[BISERVER-14935] import-export.bat/.sh does not work on Pentaho 9.3 o…
Browse files Browse the repository at this point in the history
…r higher if requestParameterAuthenticationEnabled=true
  • Loading branch information
smmribeiro committed Nov 1, 2023
1 parent 8e91ffc commit c7b3f56
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class CommandLineProcessor {
private static final String ANALYSIS_DATASOURCE_IMPORT = "/plugin/data-access/api/mondrian/postAnalysis";

private static final String METADATA_DATASOURCE_IMPORT = "/plugin/data-access/api/metadata/postimport";
private static final String API_REPO_FILES_BACKUP = "/api/repo/files/backup";

private static final String METADATA_DATASOURCE_EXT = "xmi";

Expand Down Expand Up @@ -719,7 +720,6 @@ private void performBackup()
throws ParseException, IOException, KettleException, URISyntaxException {
String contextURL = getOptionValue( INFO_OPTION_URL_NAME, true, false );
String logFile = getOptionValue( INFO_OPTION_LOGFILE_NAME, false, true );
String backupURL = contextURL + "/api/repo/files/backup";

initRestService( contextURL );

Expand All @@ -731,10 +731,18 @@ private void performBackup()
if ( !authResponse.equals( "true" ) ) {
System.err.println( Messages.getInstance().getString( "CommandLineProcessor.ERROR_0006_NON_ADMIN_CREDENTIALS" ) );
}

// Build the complete URL to use
String backupURL = contextURL + API_REPO_FILES_BACKUP;

// BISERVER-14935: In case "requestParameterAuthenticationEnabled" is set to 'true'
backupURL += ( "?userid=" + getUsername() + "&password=" + Encr.encryptPassword(
Encr.decryptPasswordOptionallyEncrypted( getPassword() ) ) );

WebResource resource = client.resource( backupURL );

// Response response
Builder builder = resource.type( MediaType.MULTIPART_FORM_DATA ).accept( MediaType.TEXT_HTML_TYPE );
Builder builder = resource.type( MediaType.APPLICATION_FORM_URLENCODED ).accept( MediaType.TEXT_HTML_TYPE );
ClientResponse response = builder.get( ClientResponse.class );
if ( response != null && response.getStatus() == 200 ) {
String filename = getOptionValue( INFO_OPTION_FILEPATH_NAME, true, false );
Expand Down

0 comments on commit c7b3f56

Please sign in to comment.