Author: kohsuke
Date: 2009-06-17 19:39:49 -0500 (Wed, 17 Jun 2009)
New Revision: 43
Modified:
glassfish/src/main/java/org/codehaus/cargo/container/glassfish/GlassFishStandaloneLocalConfiguration.java
Log:
It's possible for someone to just use Deployer to deploy artifacts without starting/stopping it via Cargo, so the password file needs to be filled on demand.
Modified: glassfish/src/main/java/org/codehaus/cargo/container/glassfish/GlassFishStandaloneLocalConfiguration.java
===================================================================
--- glassfish/src/main/java/org/codehaus/cargo/container/glassfish/GlassFishStandaloneLocalConfiguration.java 2009-06-17 22:48:21 UTC (rev 42)
+++ glassfish/src/main/java/org/codehaus/cargo/container/glassfish/GlassFishStandaloneLocalConfiguration.java 2009-06-18 00:39:49 UTC (rev 43)
@@ -31,6 +31,7 @@
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
/**
* @author Kohsuke Kawaguchi
@@ -71,7 +72,24 @@
* Returns the password file that contains admin's password.
*/
File getPasswordFile() {
- return new File(getHome(), "password.properties");
+ String password = getPropertyValue(RemotePropertySet.PASSWORD);
+ if(password.length()<8)
+ throw new CargoException("password needs to be 8 characters or longer");
+
+ try {
+ File f = new File(getHome(), "password.properties");
+ if(!f.exists()) {
+ getFileHandler().mkdirs(getHome());
+ FileWriter w = new FileWriter(f);
+ // somehow glassfish uses both. Brain-dead.
+ w.write("AS_ADMIN_PASSWORD="+password+"\n");
+ w.write("AS_ADMIN_ADMINPASSWORD="+password+"\n");
+ w.close();
+ }
+ return f;
+ } catch (IOException e) {
+ throw new CargoException("Failed to create a password file",e);
+ }
}
/**
@@ -81,19 +99,6 @@
DefaultFileHandler fileHandler = new DefaultFileHandler();
fileHandler.delete(getHome());
-
- String password = getPropertyValue(RemotePropertySet.PASSWORD);
- if(password.length()<8)
- throw new CargoException("password needs to be 8 characters or longer");
-
- getFileHandler().mkdirs(getHome());
- FileWriter w = new FileWriter(getPasswordFile());
- // somehow glassfish uses both. Brain-dead.
- w.write("AS_ADMIN_PASSWORD="+password+"\n");
- w.write("AS_ADMIN_ADMINPASSWORD="+password+"\n");
- w.close();
-
-
((GlassFishInstalledLocalContainer)container).invokeAsAdmin( false, new String[]{
"create-domain",
"--interactive=false",
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email