Commandspublic class Commands extends Object
Fields Summary |
---|
private static com.sun.enterprise.util.i18n.StringManager | stringManager |
Constructors Summary |
---|
public Commands()Creates a new instance of Commands
|
Methods Summary |
---|
public static boolean | deploy(java.lang.String modulePath, CommonInfoModel commonInfo, java.util.ArrayList parameters)
String currentDomain = commonInfo.getCurrentDomain();
String adminPort = DomainsProcessor.getTargetDomainPort(currentDomain, commonInfo);
String adminSecurity = DomainsProcessor.getTargetDomainSecurity(currentDomain, commonInfo);
//Admin credential changes. Added for CR 6454007
//Commented for CR 6486068
/*java.util.Hashtable domainMapping = commonInfo.getDomainMapping();
DomainInfo dInfo = (DomainInfo)domainMapping.get(currentDomain);
String adminUser;
if(commonInfo.getSourceVersion().equals(UpgradeConstants.VERSION_7X)) {
adminUser = dInfo.getDomainAdminUser();
} else {
adminUser = commonInfo.getAdminUserName();
}*/
//End - comment
//Added - end
// START CR 6396995
ArrayList deployList = new ArrayList();
deployList.add("deploy");
deployList.add("--user");
//Admin credential changes. Added for CR 6454007
//Edited - CR 6486068
//deployList.add(adminUser);
deployList.add(commonInfo.getAdminUserName());
deployList.add("--passwordfile");
//Admin credential changes. Added for CR 6454007
//Edited - CR 6486068
//deployList.add("\"" + commonInfo.getPasswordFile(currentDomain)+ "\"");
deployList.add("\"" + commonInfo.getPasswordFile()+ "\"");
deployList.add("--port");
deployList.add(adminPort);
deployList.add("--secure=" + adminSecurity);
if(parameters != null) {
for(int i=0; i< parameters.size(); i++){
deployList.add(parameters.get(i));
}
}
deployList.add("\"" + modulePath + "\"");
String[] deployArray = new String[1];
if(!(UpgradeConstants.EDITION_PE.equals(commonInfo.getSourceEdition()))){
String targetName = commonInfo.getCurrentCluster();
if(targetName == null){
targetName = commonInfo.getCurrentSourceInstance();
}
if((targetName != null) && (!("".equals(targetName)))){
deployList.add(deployList.size()-1,"--target");
deployList.add(deployList.size()-1,targetName);
}
}
String[] deploy = (String[])deployList.toArray(deployArray);
// END CR 6396995
try {
return executeCommand(deploy);
} catch (CommandException ce) {
Throwable t = ce.getCause();
CommonInfoModel.getDefaultLogger().warning(stringManager.getString("upgrade.common.general_exception") + " " + (t==null?ce.getMessage():t.getMessage()));
}
CommonInfoModel.getDefaultLogger().warning(stringManager.getString("commands.errorDeployingMsg") + modulePath);
return false;
| public static boolean | executeCommand(java.lang.String[] commandStrings)
try {
StringBuffer commandOneString = new StringBuffer();
for(int i = 0; i < commandStrings.length; i++) {
commandOneString.append(commandStrings[i]).append(" ");
}
InputsAndOutputs io = InputsAndOutputs.getInstance();
PipedOutputStream pos = new PipedOutputStream();
io.setErrorOutput(pos);
io.setUserOutput(pos);
CommandOutputReader cor = new CommandOutputReader(pos);
((Thread)cor).start();
CommonInfoModel.getDefaultLogger().info(stringManager.
getString("commands.executingCommandMsg") + commandOneString);
CLIMain.invokeCLI(commandOneString.toString(), io);
pos.flush();
return true;
}
catch(CommandException ce) {
throw ce;
}
catch(Exception e) {
Throwable t = e.getCause();
CommonInfoModel.getDefaultLogger().warning(stringManager.getString("upgrade.common.general_exception") + (t==null?e.getMessage():t.getMessage()));
}
return false;
| public static boolean | startDomain(java.lang.String domainName, CommonInfoModel commonInfo)
String adminUser = commonInfo.getAdminUserName();
String command[] = {
"start-domain",
"--domaindir", "\"" + commonInfo.getTargetDomainRoot() + "\"",
"--user", adminUser,
"--passwordfile ", "\"" + commonInfo.getPasswordFile() +"\"",
domainName
};
try {
boolean b = executeCommand(command);
return b;
} catch (CommandException ce) {
Throwable t = ce.getCause();
CommonInfoModel.getDefaultLogger().severe(stringManager.
getString("upgrade.common.general_exception") + ce.getMessage());
if (t != null) {
String message = t.getMessage();
if(message != null){
CommonInfoModel.getDefaultLogger().severe(stringManager.
getString("upgrade.common.general_exception") + message);
if ( message.indexOf(stringManager.
getString("commands.DomainRunningFragment")) != -1 ||
(stringManager.getString("commands.DomainRunningFragment").
equalsIgnoreCase("No local string defined") &&
message.indexOf("running") != -1 )) {
CommonInfoModel.getDefaultLogger().severe(stringManager.
getString("commands.DomainRunningMsg", domainName));
}
}
}
}
return false;
| public static boolean | stopDomain(java.lang.String domainName, CommonInfoModel commonInfo)
String command[] = {
"stop-domain", "--domaindir", "\"" + commonInfo.getTargetDomainRoot() +"\"", domainName
};
try {
boolean b = executeCommand(command);
return b;
} catch (CommandException ce) {
Throwable t = ce.getCause();
if (t != null && t.getMessage().indexOf("is not running") != -1) {
return true;
}
CommonInfoModel.getDefaultLogger().warning(stringManager.getString("upgrade.common.general_exception") + ce.getMessage());
}
return false;
|
|