From 85991d0de9ca7ed265db7534511ccae84c0733e3 Mon Sep 17 00:00:00 2001 From: Aled Lewis Date: Tue, 21 Jul 2015 22:50:24 +0100 Subject: [PATCH 1/5] Made it possible to install scriptrunner without prompts --- .../scriptrunner2/CommandLineOption.java | 4 ++- .../scriptrunner2/CommandLineWrapper.java | 3 ++ .../scriptrunner2/install/Installer.java | 31 ++++++++++++------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/com/fivium/scriptrunner2/CommandLineOption.java b/src/com/fivium/scriptrunner2/CommandLineOption.java index eadf22f..0366a1f 100644 --- a/src/com/fivium/scriptrunner2/CommandLineOption.java +++ b/src/com/fivium/scriptrunner2/CommandLineOption.java @@ -25,7 +25,9 @@ public enum CommandLineOption { , DB_SYSDBA("sysdba") , OUTPUT_FILE_PATH("outfile") , PROMOTION_LABEL("label") - , ADDITIONAL_PROPERTIES("props"); + , ADDITIONAL_PROPERTIES("props") + , INSTALL_PROMOTE_USER("newpromoteuser") + , INSTALL_PROMOTE_PASSWORD("newpromotepassword"); private final String mArgString; diff --git a/src/com/fivium/scriptrunner2/CommandLineWrapper.java b/src/com/fivium/scriptrunner2/CommandLineWrapper.java index 747f52c..6f78106 100644 --- a/src/com/fivium/scriptrunner2/CommandLineWrapper.java +++ b/src/com/fivium/scriptrunner2/CommandLineWrapper.java @@ -66,6 +66,9 @@ public class CommandLineWrapper { gCommandLineOptions.addOption(CommandLineOption.PROMOTE_PASSWORD.getArgString(), true, "Specify the password for the database user. If not specified this will be prompted for."); gCommandLineOptions.addOption(CommandLineOption.JDBC_CONNECT_STRING.getArgString(), true, "A full JDBC connect string for establishing a database connection."); + + gCommandLineOptions.addOption(CommandLineOption.INSTALL_PROMOTE_USER.getArgString(), true, "(install only) The new promotion user to create."); + gCommandLineOptions.addOption(CommandLineOption.INSTALL_PROMOTE_PASSWORD.getArgString(), true, "(install only) The password to use for the new promote user."); gCommandLineOptions.addOption(CommandLineOption.DB_HOST.getArgString(), true, "Database hostname."); gCommandLineOptions.addOption(CommandLineOption.DB_PORT.getArgString(), true, "Database port."); diff --git a/src/com/fivium/scriptrunner2/install/Installer.java b/src/com/fivium/scriptrunner2/install/Installer.java index f65555d..f8c9836 100644 --- a/src/com/fivium/scriptrunner2/install/Installer.java +++ b/src/com/fivium/scriptrunner2/install/Installer.java @@ -81,11 +81,17 @@ private void install() } //Prompt user for promote user name - String lPromoteUserName = CommandLineWrapper.readArg("Enter name for new promotion user (leave blank for default - " + DatabaseConnection.DEFAULT_PROMOTE_USER + ")", true); - lPromoteUserName = XFUtil.nvl(lPromoteUserName, DatabaseConnection.DEFAULT_PROMOTE_USER).toUpperCase(); + String lPromoteUserName = mCommandLineWrapper.getOption(CommandLineOption.INSTALL_PROMOTE_USER); + lPromoteUserName = XFUtil.nvl(lPromoteUserName, DatabaseConnection.DEFAULT_PROMOTE_USER).toUpperCase(); + + String lArgPassword = null; + + if (mCommandLineWrapper.hasOption(CommandLineOption.INSTALL_PROMOTE_PASSWORD)){ + lArgPassword = mCommandLineWrapper.getOption(CommandLineOption.INSTALL_PROMOTE_PASSWORD); + } //Create the new promote user - String lNewPassword = createUser(lDatabaseConnection, lPromoteUserName); + String lNewPassword = createUser(lDatabaseConnection, lPromoteUserName, lArgPassword); Logger.logAndEcho("Setting user privileges..."); @@ -151,15 +157,18 @@ private void install() * @return The password of the new user. * @throws ExInstaller If the user cannot be created. */ - private String createUser(DatabaseConnection pDatabaseConnection, String pPromoteUserName) - throws ExInstaller { - + private String createUser(DatabaseConnection pDatabaseConnection, String pPromoteUserName, String pPassword) + throws ExInstaller { + + String lPassword = pPassword; //Prompt user for password - String lPassword = CommandLineWrapper.readPassword("Enter password for new " + pPromoteUserName + " user"); - String lConfirmPassword = CommandLineWrapper.readPassword("Confirm password"); - - if(!lPassword.equals(lConfirmPassword)){ - throw new ExInstaller("Passwords did not match"); + if (null == pPassword){ + lPassword = CommandLineWrapper.readPassword("Enter password for new " + pPromoteUserName + " user"); + String lConfirmPassword = CommandLineWrapper.readPassword("Confirm password"); + + if(!lPassword.equals(lConfirmPassword)){ + throw new ExInstaller("Passwords did not match"); + } } String lCreateUserSQL; From 178985f68a826941c86d7591061447ae5c688393 Mon Sep 17 00:00:00 2001 From: Aled Lewis Date: Tue, 21 Jul 2015 22:54:53 +0100 Subject: [PATCH 2/5] Ant build correctly sets version when on case sensitive filesystems --- build/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.xml b/build/build.xml index 6990d58..b6af544 100644 --- a/build/build.xml +++ b/build/build.xml @@ -99,7 +99,7 @@ - version_number=${scriptrunner.version} + version_number=${scriptrunner.version} software_name=Fivium ScriptRunner From 4d63f2744fce3572fa13457e6d87ed8d1930da61 Mon Sep 17 00:00:00 2001 From: Aled Lewis Date: Wed, 22 Jul 2015 21:31:44 +0100 Subject: [PATCH 3/5] Code review fixes --- src/com/fivium/scriptrunner2/install/Installer.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/fivium/scriptrunner2/install/Installer.java b/src/com/fivium/scriptrunner2/install/Installer.java index f8c9836..851d6e6 100644 --- a/src/com/fivium/scriptrunner2/install/Installer.java +++ b/src/com/fivium/scriptrunner2/install/Installer.java @@ -154,6 +154,7 @@ private void install() * Creates the promotion user. * @param pDatabaseConnection Connection to use to create user (should be SYSDBA). * @param pPromoteUserName Name of new promotion user. + * @param pPassword The password passed in to the command line. If XFUtil.isNull, then it'll be prompted * @return The password of the new user. * @throws ExInstaller If the user cannot be created. */ @@ -162,13 +163,13 @@ private String createUser(DatabaseConnection pDatabaseConnection, String pPromot String lPassword = pPassword; //Prompt user for password - if (null == pPassword){ - lPassword = CommandLineWrapper.readPassword("Enter password for new " + pPromoteUserName + " user"); - String lConfirmPassword = CommandLineWrapper.readPassword("Confirm password"); + if (XFUtil.isNull(pPassword) ){ + lPassword = CommandLineWrapper.readPassword("Enter password for new " + pPromoteUserName + " user"); + String lConfirmPassword = CommandLineWrapper.readPassword("Confirm password"); - if(!lPassword.equals(lConfirmPassword)){ - throw new ExInstaller("Passwords did not match"); - } + if(!lPassword.equals(lConfirmPassword)){ + throw new ExInstaller("Passwords did not match"); + } } String lCreateUserSQL; From c7085813bb092fd6bd6a62cb12910e6aad8822d4 Mon Sep 17 00:00:00 2001 From: Aled Lewis Date: Fri, 7 Aug 2015 17:18:53 +0100 Subject: [PATCH 4/5] Squash bug related to case sensitivity of build dir in Windows When a path specified in Windows contains different caseing to the one the path is stored as, failed to build the file hash. This is due to the use of URI#relativize which cares about casing. Switching to relativising nio paths solves the issue in a filesystem agnostic way. --- src/com/fivium/scriptrunner2/builder/ManifestBuilder.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java b/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java index 1bdddfb..1464b27 100644 --- a/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java +++ b/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java @@ -17,6 +17,9 @@ import java.io.IOException; import java.io.PrintWriter; +import java.net.URI; +import java.nio.file.FileSystems; +import java.nio.file.Path; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -145,7 +148,10 @@ public File getBaseDirectory() { @Override public String relativeFilePath(File pFile){ - return ScriptRunner.normaliseFilePath(mBaseDirectory.toURI().relativize(pFile.toURI()).getPath()); + Path lBaseDirectoryPath = FileSystems.getDefault().getPath(mBaseDirectory.getAbsolutePath()); + Path lFilePath = FileSystems.getDefault().getPath(pFile.getAbsolutePath()); + Path lRelative = lBaseDirectoryPath.relativize(lFilePath); + return ScriptRunner.normaliseFilePath(lRelative.toString()); } /** From 0d98f0524468e98e246839c286f06d6e71d15d9e Mon Sep 17 00:00:00 2001 From: Aled Lewis Date: Fri, 7 Aug 2015 17:19:43 +0100 Subject: [PATCH 5/5] Clean up imports --- src/com/fivium/scriptrunner2/builder/ManifestBuilder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java b/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java index 1464b27..a5bbb6c 100644 --- a/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java +++ b/src/com/fivium/scriptrunner2/builder/ManifestBuilder.java @@ -17,7 +17,6 @@ import java.io.IOException; import java.io.PrintWriter; -import java.net.URI; import java.nio.file.FileSystems; import java.nio.file.Path; import java.text.SimpleDateFormat;