{
final ResourceResponse resourceResponse = new ResourceResponse();
if (resourceResponse.dataNeedsToBeWritten(attributes))
{
final WebExternalResourceStream webExternalResourceStream = new WebExternalResourceStream(
path);
resourceResponse.setContentType(webExternalResourceStream.getContentType());
resourceResponse.setLastModified(webExternalResourceStream.lastModifiedTime().toDate());
resourceResponse.setFileName(path);
resourceResponse.setWriteCallback(new WriteCallback()
{
@Override
public void writeData(final Attributes attributes)
{
InputStream inputStream = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try
{
inputStream = webExternalResourceStream.getInputStream();
Streams.copy(inputStream, baos);
attributes.getResponse().write(baos.toByteArray());
}
catch (ResourceStreamNotFoundException rsnfx)
{