}
catch (IOException e)
{
e.printStackTrace();
log.error("Exception during file read/write:", e);
throw new ClientException("Exception during file read/write", e);
}
finally
{
// Flush all streams, and close input streams
try
{
data.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
try
{
buffOut.flush();
}
catch (IOException e2)
{
e2.printStackTrace();
}
// Do NOT close the Output stream here, as the
// underlying output stream is/should be closed later.
}
}
else
{
outputs.add(reAsBean);
}
}
else if (re instanceof Command)
{
commands.add(reAsBean);
}
}
wreq.setAttribute("inputs", inputs);
wreq.setAttribute("outputs", outputs);
wreq.setAttribute("commands", commands);
int inputCount = 0;
DynaProperty[] dps = new DynaProperty[inputs.size()];
ResponseElementDynaBean oneInput = null;
for (Iterator ii = inputs.iterator(); ii.hasNext();)
{
oneInput = (ResponseElementDynaBean) ii.next();
Object defValue = oneInput.get("defaultValue");
DynaProperty dp = null;
if (defValue != null)
{
dp = new DynaProperty((String) oneInput.get("name"), oneInput.get("defaultValue").getClass());
}
else
{
try
{
dp = new DynaProperty((String) oneInput.get("name"), Class.forName("java.lang.String"));
}
catch (ClassNotFoundException e)
{
throw new ClientException("Cannot create String dynaproperty", e);
}
}
dps[inputCount++] = dp;
}
BasicDynaClass bd;
try
{
bd = new BasicDynaClass(modelName, Class.forName("org.apache.commons.beanutils.BasicDynaBean"), dps);
BasicDynaBean newForm = (BasicDynaBean) bd.newInstance();
// Now populate the newForm's properties
for (Iterator i2 = inputs.iterator(); i2.hasNext();)
{
oneInput = (ResponseElementDynaBean) i2.next();
newForm.set((String) oneInput.get("name"), oneInput.get("defaultValue"));
}
wreq.setAttribute("default", newForm);
}
catch (ClassNotFoundException e)
{
throw new ClientException(e);
}
catch (IllegalAccessException e)
{
throw new ClientException(e);
}
catch (InstantiationException e)
{
throw new ClientException(e);
}
}