OutputParameterType[] outputPramaeters = method.getOutputParameterArray();
XmlElement parm;
for (int i = 0; i < outputPramaeters.length; i++) {
OutputParameterType type = outputPramaeters[i];
parm = builder.newFragment(type.getParameterName());
String typeStr = type.getParameterType().toString();
if (GfacUtils.isArray(typeStr)) {
Object obj = getParameterValue(type.getParameterName());
if(GFacConstants.Types.TYPE_DATAID_ARRAY.equals(typeStr)){
if(obj instanceof DataIDType[]){
for(DataIDType id:(DataIDType[])obj){
XmlElement arrayValue = builder.newFragment(VALUE);
parm.addChild(arrayValue);
id.fillData(arrayValue);
}
}else{
throw new GFacSchemaException("Parameter " + type.getParameterName()
+ "had a type " + (obj!=null?obj.getClass():null) + "instead of a DataIDType");
}
}else if (obj instanceof Object[]) {
Object[] values = (Object[]) obj;
// if (values.length == 0) {
// throw new GfacException(
// "The application execution is complete, but Service can not find a value for Parameter "
// + type.getParameterName()
// + " Please look into standard out and standard error for further information");
// }
for (int j = 0; j < values.length; j++) {
XmlElement arrayValue = builder.newFragment(VALUE);
arrayValue.addChild(String.valueOf(values[j]));
parm.addChild(arrayValue);
}
} else {
throw new GFacSchemaException(
"The application execution is complete, but Service can not find a value for Parameter "
+ type.getParameterName()
+ " Please look into standard out and standard error for further information [Parameter Map = "+ this+"]");
}
} else if (GFacConstants.Types.TYPE_DATAID.equals(typeStr)) {
Object obj = getParameterValue(type.getParameterName());
if (obj instanceof DataIDType) {
((DataIDType) obj).fillData(parm);
} else {
throw new GFacSchemaException("Parameter " + type.getParameterName()
+ "had a type " + obj.getClass() + "instead of a DataIDType");
}
} else {
String value = getStringParameterValue(type.getParameterName());
if (value == null) {
throw new GFacSchemaException("parameter " + type.getParameterName()
+ "Not found [Parameter Map = "+ this+"]");
}
parm.addChild(value);
}
bodyContent.addChild(parm);