Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Fivium/ScriptRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
switchtrue committed Mar 9, 2016
2 parents 17dcc6e + e392d6e commit aea841b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</fileset>
</copy>
<input message="Please enter ScriptRunner version, e.g. 2.X.Y (default=DEV):" addproperty="scriptrunner.version" defaultvalue="DEV"/>
<echo file="${output.dir}/classes/com/fivium/ScriptRunner2/util/version.properties">version_number=${scriptrunner.version}
<echo file="${output.dir}/classes/com/fivium/scriptrunner2/util/version.properties">version_number=${scriptrunner.version}
software_name=Fivium ScriptRunner</echo>
</target>
<target name="build-jar">
Expand Down
10 changes: 6 additions & 4 deletions src/com/fivium/scriptrunner2/CommandLineOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ public enum CommandLineOption {
, OUTPUT_FILE_PATH("outfile")
, PROMOTION_LABEL("label")
, ADDITIONAL_PROPERTIES("props")
, INSTALL_PROMOTE_USER("newpromoteuser")
, INSTALL_PROMOTE_PASSWORD("newpromotepassword")
, NO_UNIMPLICATED_FILES("nounimplicatedfiles");

private final String mArgString;

private CommandLineOption(String pArgString){
mArgString = pArgString;
}

/**
* Gets the command line argument string which this enum represents.
* @return Argument string.
*/
public String getArgString(){
return mArgString;
}

}
3 changes: 3 additions & 0 deletions src/com/fivium/scriptrunner2/CommandLineWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
7 changes: 6 additions & 1 deletion src/com/fivium/scriptrunner2/builder/ManifestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.io.IOException;
import java.io.PrintWriter;

import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.text.SimpleDateFormat;

import java.util.ArrayList;
Expand Down Expand Up @@ -145,7 +147,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());
}

/**
Expand Down
32 changes: 21 additions & 11 deletions src/com/fivium/scriptrunner2/install/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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...");

Expand Down Expand Up @@ -148,18 +154,22 @@ 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.
*/
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 (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");
}
}

String lCreateUserSQL;
Expand Down

0 comments on commit aea841b

Please sign in to comment.