Methods Summary |
---|
protected void | doExecute(java.lang.String finalLocation, com.opensymphony.xwork2.ActionInvocation invocation)
OutputStream oOutput = null;
try {
if (inputStream == null) {
// Find the inputstream from the invocation variable stack
inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation));
}
if (inputStream == null) {
String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " +
"Check the <param name=\"inputName\"> tag specified for this action.");
log.error(msg);
throw new IllegalArgumentException(msg);
}
// Find the Response in context
HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE);
// Set the content type
oResponse.setContentType(conditionalParse(contentType, invocation));
// Set the content length
if (contentLength != null) {
String _contentLength = conditionalParse(contentLength, invocation);
int _contentLengthAsInt = -1;
try {
_contentLengthAsInt = Integer.parseInt(_contentLength);
if (_contentLengthAsInt >= 0) {
oResponse.setContentLength(_contentLengthAsInt);
}
}
catch(NumberFormatException e) {
log.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e);
}
}
// Set the content-disposition
if (contentDisposition != null) {
oResponse.addHeader("Content-disposition", conditionalParse(contentDisposition, invocation));
}
// Get the outputstream
oOutput = oResponse.getOutputStream();
if (log.isDebugEnabled()) {
log.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength +
"] content-disposition=[" + contentDisposition + "]");
}
// Copy input to output
log.debug("Streaming to output buffer +++ START +++");
byte[] oBuff = new byte[bufferSize];
int iSize;
while (-1 != (iSize = inputStream.read(oBuff))) {
oOutput.write(oBuff, 0, iSize);
}
log.debug("Streaming to output buffer +++ END +++");
// Flush
oOutput.flush();
}
finally {
if (inputStream != null) inputStream.close();
if (oOutput != null) oOutput.close();
}
|
public int | getBufferSize()
return (bufferSize);
|
public java.lang.String | getContentDisposition()
return contentDisposition;
|
public java.lang.String | getContentLength()
return contentLength;
|
public java.lang.String | getContentType()
return (contentType);
|
public java.lang.String | getInputName()
return (inputName);
|
public void | setBufferSize(int bufferSize)
this.bufferSize = bufferSize;
|
public void | setContentDisposition(java.lang.String contentDisposition)
this.contentDisposition = contentDisposition;
|
public void | setContentLength(java.lang.String contentLength)
this.contentLength = contentLength;
|
public void | setContentType(java.lang.String contentType)
this.contentType = contentType;
|
public void | setInputName(java.lang.String inputName)
this.inputName = inputName;
|