// //By default 4 Megs allowed - already set.
// }
log.debug("Starting request parse...");
DynaActionForm df = (DynaActionForm) form;
DynaClass dc = df.getDynaClass();
if (dc == null)
{
throw new ClientException("Null dynaclass from the DynaActionForm - can't read properties");
}
DynaProperty[] props = dc.getDynaProperties();
DynaProperty oneProp = null;
if (log.isDebugEnabled())
{
// They are not available in Struts Dynaform objects.
for (final Enumeration enumeration = this.hreq.getParameterNames(); enumeration
.hasMoreElements();)
{
// get parameter name
// Get paramater values...
// See if present in form.
final String name = (String) enumeration.nextElement();
try
{
for (int idx = 0;; idx++)
{
final Object value = df.get(name, idx);
log.debug("Array Access Parameter/Value/Index: " + name + '/' + value + '/' + idx);
}
}
catch (Exception e)
{
log.debug("Exception: " + e);
log.debug("No more values for: " + name);
}
}
for (final Enumeration enumeration = hreq.getParameterNames(); enumeration.hasMoreElements();)
{
final String name = (String) enumeration.nextElement();
final String[] values = hreq.getParameterValues(name);
log.debug("Servlet Parameter name: " + name);
log.debug("Number of values: " + values.length);
for (int idx = 0; idx < values.length; idx++)
{
log.debug("Idx/Value: " + idx + '/' + values[idx]);
}
}
log.debug("# of properties: " + props.length);
}
for (int i = 0; i < props.length; i++)
{
oneProp = props[i];
String oneName = oneProp.getName();
final Object value = df.get(oneName);
log.debug("Getting parameter/value/type:" + oneName + '/' + value + '/'
+ (value == null ? "null" : value.getClass().getName()));
// TODO: Handle mapped and indexed properties here
// getName(), getType, isIndexed(), isMapped()
if (df.get(oneName) != null && df.get(oneName) instanceof FormFile)
{
log.debug("Formfile");
FormFile fileInfo = (FormFile) df.get(oneName);
if (fileInfo != null && fileInfo.getFileSize() > 0)
{
BufferedInputStream inStream = null;
try
{
inStream = new BufferedInputStream(fileInfo.getInputStream(), BUFFER_SIZE);
}
catch (IOException e)
{
throw new ClientException(e.getMessage(), e);
}
// Problem - DefaultFileItem is not comprised
// completely of serializable components.
// final FileItem fileItem =
// DFIF.createItem(oneName,
// fileInfo.getContentType(), false,
// fileInfo.getFileName());
// So we use BinaryWrapper instead, which is
// completely serializable
// TODO: Reset First parameter with Context Name
// so that this will work over distributed
// environments(I could not find the call to get
// it - SPD)
final BinaryWrapper fileWrapper = new BinaryWrapper(null, hreq.getContentType(),
fileInfo.getFileName(), BUFFER_SIZE, null);
try
{
final long written = fileWrapper.writeFrom(inStream);
if (this.log.isDebugEnabled())
{
log.debug("Read/Wrote " + written + "bytes.");
}
}
catch (IOException e)
{
throw new ClientException(e.getMessage(), e);
}
finally
{
if (inStream != null)
{
try
{
inStream.close();
}
// Done Anyways, so just print for log
// (hopefully) and carry on.
catch (IOException e)
{
e.printStackTrace();
}
} // end if(inStream
try
{
fileWrapper.close();
}
// Done Anyways, so just print for log
// (hopefully) and carry on.
catch (IOException e)
{
e.printStackTrace();
}
} // end finally
if (log.isDebugEnabled())
{
log.debug("Setting FormFile parameter/value:" + oneName + '/'
+ fileWrapper.getName());
}
kreq.setParameter(oneName, fileWrapper);
} // end if (fileInfo!= null..
} // end if(df.get(oneName)!=null
else if (df.get(oneName) != null && df.get(oneName) instanceof java.io.Serializable)
{
if (log.isDebugEnabled())
{
log.debug("Setting FormField parameter/value:" + oneName + '/' + df.get(oneName));
}
// TODO: Fix this.
// BUG # 880906 Need to get value(s) directly from
// request.
final String[] values = hreq.getParameterValues(oneName);
if (values.length < 1)
{
log.debug("No values, so setting value=null");
kreq.setParameter(oneName, null);
}
else if (values.length == 1)
{
log.debug("One value, saving as string");
kreq.setParameter(oneName, values[1]);
}
else
{
// More than one value in this list, so send the
// entire array
log.debug("Many values, saving as array");
kreq.setParameter(oneName, values);
}
} // end else if(df.get(oneName)!=null...instanceof
// Serializable
log.debug("Name/Value written to request: " + oneName);
} // end for
}
else
{
// isMultipart == false - Just a regular dynaform
log.debug("Standard Dyna Form...");
// Populate the model parameters from the form
DynaActionForm df = (DynaActionForm) form;
DynaClass dc = df.getDynaClass();
if (dc == null)
{
throw new ClientException("Null dynaclass from the DynaActionForm - can't read properties");
}
DynaProperty[] props = dc.getDynaProperties();
DynaProperty oneProp = null;
for (int i = 0; i < props.length; i++)
{
oneProp = props[i];