*/
private static String hostXMLRequest(HostBean host,
HostDescriptionDocument template) throws GfacException {
try {
HostDescriptionDocument hostDescDoc = template;
HostDescriptionType hostDesc;
if (hostDescDoc == null) {
hostDescDoc = HostDescriptionDocument.Factory.newInstance();
hostDesc = hostDescDoc.addNewHostDescription();
} else {
hostDesc = hostDescDoc.getHostDescription();
}
hostDesc.setHostName(host.getHostName().trim());
HostConfigurationType hostConf = hostDesc.getHostConfiguration();
if (hostConf == null) {
hostConf = hostDesc.addNewHostConfiguration();
}
// Added to support extra fields
if(!host.getGateKeeperendPointReference().isEmpty()){
GlobusGatekeeperType gatekeeperType;
if (hostConf.sizeOfGlobusGatekeeperArray() == 0) {
gatekeeperType = hostConf.addNewGlobusGatekeeper();
} else {
gatekeeperType = hostConf.getGlobusGatekeeperArray(0);
}
gatekeeperType.setEndPointReference(host
.getGateKeeperendPointReference());
gatekeeperType.setWsGram(host.isWsGram());
gatekeeperType.setName(host.getGateKeeperName());
if (host.getGateKeeperJobManager() != null) {
String jobmanager = host.getGateKeeperJobManager();
if (jobmanager.equals(GlobusJobManagerType.CONDOR.toString())) {
gatekeeperType
.setJobmanagertype(GlobusJobManagerType.CONDOR);
} else if (jobmanager.equals(GlobusJobManagerType.FORK
.toString())) {
gatekeeperType.setJobmanagertype(GlobusJobManagerType.FORK);
} else if (jobmanager.equals(GlobusJobManagerType.LOADLEVELER
.toString())) {
gatekeeperType
.setJobmanagertype(GlobusJobManagerType.LOADLEVELER);
} else if (jobmanager.equals(GlobusJobManagerType.LSF
.toString())) {
gatekeeperType.setJobmanagertype(GlobusJobManagerType.LSF);
} else if (jobmanager.equals(GlobusJobManagerType.MULTI
.toString())) {
gatekeeperType
.setJobmanagertype(GlobusJobManagerType.MULTI);
} else if (jobmanager.equals(GlobusJobManagerType.PBS
.toString())) {
gatekeeperType.setJobmanagertype(GlobusJobManagerType.PBS);
} else if (jobmanager.equals(GlobusJobManagerType.SPRUCE
.toString())) {
gatekeeperType
.setJobmanagertype(GlobusJobManagerType.SPRUCE);
}
}
}
if(!host.getGridFtpendPointReference().isEmpty()){
GridFTPType gridFTPType;
if (hostConf.sizeOfGridFTPArray() == 0) {
gridFTPType = hostConf.addNewGridFTP();
} else {
gridFTPType = hostConf.getGridFTPArray(0);
}
gridFTPType
.setEndPointReference(host.getGridFtpendPointReference());
gridFTPType.setName(host.getGridFtpName());
}
hostConf.setGFacPath(host.getGFacPath());
hostConf.setTmpDir(host.getTmpDir());
PortRangeType portRangeType = hostConf.getPortRange();
if (portRangeType == null) {
portRangeType = hostConf.addNewPortRange();
}
if (host.getPortRangeStart() > 0 && host.getPortRangeEnd() > 0) {
portRangeType.setStart(Integer
.valueOf(host.getPortRangeStart()));
portRangeType.setEnd(Integer.valueOf(host.getPortRangeEnd()));
}
PackageType javaInstallation;
if (hostConf.getJavaArray() != null
&& hostConf.getJavaArray().length > 0) {
javaInstallation = hostConf.getJavaArray(0);
} else {
javaInstallation = hostConf.addNewJava();
}
String jdkName = host.getJdkName();
javaInstallation.setName(jdkName);
javaInstallation.setHome(host.getJdkPath());
//FIXME: this should not be needed
javaInstallation.setVersion(jdkName.replaceAll("java", ""));
if (host.getHostEnv() != null) {
HashMap<String, NameValuePairType> envMap = new HashMap<String, NameValuePairType>();
if (hostConf.getHostEnvArray() != null) {
for (NameValuePairType pair : hostConf.getHostEnvArray()) {
envMap.put(pair.getName(), pair);
}
}
StringTokenizer tokernizer = new StringTokenizer(host
.getHostEnv(), ";");
while (tokernizer.hasMoreTokens()) {
String nameVal = tokernizer.nextToken();
int index = nameVal.indexOf('=');
if (index <= 0) {
throw new GfacException("Illegal Name value Pairs "
+ host.getHostEnv() + " at parsing " + nameVal,
FaultCode.InvaliedLocalArgumnet);
}
String name = nameVal.substring(0, index);
NameValuePairType nmPair = envMap.get(name);
if (nmPair == null) {
nmPair = hostConf.addNewHostEnv();
}
nmPair.setName(name);
nmPair.setValue(nameVal.substring(index + 1));
}
}
if(host.isSshEnabled()){
hostDesc.getHostConfiguration().setSshEnabled(true);
}
// Validates correctness of XML message
try {
SchemaValidator validator = new SchemaValidator(hostDesc);
validator.validate();