dataResourceId = content.getString("dataResourceId");
Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
} else {
GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
if (contentRevisionItem == null) {
throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + rootContentId
+ ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
}
Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
Debug.logInfo("SCVH(2)-contentId=" + rootContentId
+ ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
dataResourceId = contentRevisionItem.getString("newDataResourceId");
Debug.logInfo("SCVH(3)- dataResourceId:" + dataResourceId, module);
}
}
GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResourceId, https, webSiteId, locale, rootDir);
ByteArrayInputStream bais = new ByteArrayInputStream(byteWrapper.getBytes());
// hack for IE and mime types
//String userAgent = request.getHeader("User-Agent");
//if (userAgent.indexOf("MSIE") > -1) {
// Debug.log("Found MSIE changing mime type from - " + mimeTypeId, module);
// mimeTypeId = "application/octet-stream";
//}
// setup chararcter encoding and content type
String charset = dataResource.getString("characterSetId");
mimeTypeId = dataResource.getString("mimeTypeId");
if (UtilValidate.isEmpty(charset)) {
charset = servletContext.getInitParameter("charset");
}
if (UtilValidate.isEmpty(charset)) {
charset = "ISO-8859-1";
}
// setup content type
String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" +charset : contentType;
UtilHttp.streamContentToBrowser(response, bais, byteWrapper.getLength(), contentType2);
} catch(GenericEntityException e) {
throw new ViewHandlerException(e.getMessage());
} catch(IOException e) {
throw new ViewHandlerException(e.getMessage());
} catch(GeneralException e) {
throw new ViewHandlerException(e.getMessage());
}
}