@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
WSRP2Producer producer = ProducerHolder.getProducer();
GetResource getResource = ResourceServingUtil.decode(req);
try
{
ResourceResponse resource = producer.getResource(getResource);
ResourceContext resourceContext = resource.getResourceContext();
byte[] itemBinary = resourceContext.getItemBinary();
String itemString = resourceContext.getItemString();
final String mimeType = resourceContext.getMimeType();
if (!ParameterValidation.isNullOrEmpty(mimeType))
{
resp.setContentType(mimeType);
}
if (itemBinary != null && itemBinary.length > 0)
{
resp.getOutputStream().write(itemBinary);
}
if (!ParameterValidation.isNullOrEmpty(itemString))
{
resp.getWriter().write(itemString);
}
}
catch (Exception exception)
{
throw new ServletException("Couldn't get resource " + getResource.getResourceParams().getResourceID()
+ " for portlet " + getResource.getPortletContext(), exception);
}
}