Methods Summary |
---|
private java.lang.String | getName(java.lang.String typeDir, java.lang.StringBuilder absolutePath)Retrieves the domain/nodeagent name from the given directory
String path = "";
try
{
//Already checked for the valid directory in validateOptions()
final File f = new File(typeDir);
String name = f.getName();
absolutePath.append(f.getAbsolutePath());
final String nameFromOption = getOption(NAME);
if (nameFromOption != null)
name = nameFromOption;
CLILogger.getInstance().printDebugMessage("service name = " + name);
return ( name );
}
catch (Exception e)
{
throw new CommandException(e.getLocalizedMessage());
}
|
private void | printSuccess(com.sun.enterprise.admin.servermgmt.Service service)
final String[] params = new String[] {service.getName(), service.getType().toString(), service.getLocation(), service.getManifestFilePath()};
final String msg = getLocalizedString("ServiceCreated", params);
CLILogger.getInstance().printMessage(msg);
|
public void | runCommand()Method that Executes the command
try {
validateOptions();
validateType();
String passwordFile = getOption(PASSWORDFILE);
String type = getOption(TYPE);
String typeDir = (String) getOperands().get(0);
final Service service = ServiceFactory.getService();
//configure service
service.setDate(new Date().toString());
final StringBuilder ap = new StringBuilder();
service.setName(getName(typeDir, ap));
service.setLocation(ap.toString());
service.setType(type.equals("das") ?
AppserverServiceType.Domain
: AppserverServiceType.NodeAgent);
service.setFQSN();
service.setOSUser();
service.setAsadminPath(SystemPropertyConstants.getAsAdminScriptLocation());
service.setPasswordFilePath(passwordFile);
service.setServiceProperties(getOption(SERVICE_PROPERTIES));
service.isConfigValid();
service.setTrace(CLILogger.isDebug());
service.createService(service.tokensAndValues());
printSuccess(service);
CLILogger.getInstance().printDetailMessage(getLocalizedString(
"CommandSuccessful",
new Object[] {name}));
}
catch (Exception e) {
displayExceptionMessage(e);
}
|
protected void | validateNodeAgent(java.io.File typeDir)
throw new CommandException(getLocalizedString( "TypeNotSupported"));
|
public boolean | validateOptions()A method that validates the options/operands
super.validateOptions();
String passwordFile = getOption(PASSWORDFILE);
//check final the passwordfile is valid
if (! new File(passwordFile).exists())
{
final String msg = getLocalizedString("FileDoesNotExist",
new Object[] {passwordFile});
throw new CommandValidationException(msg);
}
String typedirOperand = (String) getOperands().get(0);
File typeDir = new File(typedirOperand);
String type = getOption(TYPE);
if (!type.matches(VALID_TYPES))
{
throw new CommandValidationException(
getLocalizedString("InvalideServiceType"));
}
if (!typeDir.exists() || !typeDir.canWrite() || !typeDir.isDirectory())
{
final String msg = getLocalizedString("InvalidDirectory",
new Object[] {typeDir});
throw new CommandValidationException(msg);
}
return true;
|
protected void | validateType()
String typedirOperand = (String) getOperands().get(0);
File typeDir = new File(typedirOperand);
String type = getOption(TYPE);
//Validate the domain directory
if (type.equals(DAS_TYPE))
{
String domainName = typeDir.getName();
String domainRoot = typeDir.getParent();
try {
DomainConfig dc = new DomainConfig(domainName, domainRoot);
RepositoryManager rm = new RepositoryManager();
rm.checkRepository(dc, true);
}catch (RepositoryException re){
throw new CommandException(re.getLocalizedMessage());
}
}
else // validate the node-agent directory
{
validateNodeAgent(typeDir);
}
|