final Map<String, Resolvable> wrappedObjectsToDeploy,
final OutputStream stream,
final IResponseTypeSetter responsetypesetter,
final Object requestObject,
boolean debug) {
CRResolvableBean crBean = null;
CRRequest req;
try {
req = request;
// DEPLOY OBJECTS TO REQUEST
for (Iterator<Map.Entry<String, Resolvable>>
i = wrappedObjectsToDeploy.entrySet()
.iterator(); i.hasNext();) {
Map.Entry<String, Resolvable> entry
= (Entry<String, Resolvable>) i.next();
req.addObjectForFilterDeployment(
(String) entry.getKey(), entry.getValue());
}
if (this.crConf.usesContentidUrl()) {
if (req.getContentid() == null) {
Object obj = requestObject;
if (obj != null && obj instanceof HttpServletRequest) {
String[] reqURI = ((HttpServletRequest) obj)
.getRequestURI().split("/");
ArrayList<String> reqList
= new ArrayList<String>(Arrays.asList(reqURI));
int index = reqList.indexOf(
((HttpServletRequest) obj).getServletPath()
.replaceAll("/", ""));
if (reqList.size() >= index + 1) {
req.setRequestFilter(
"object.contentid=="
+ reqList.get(index + 1).toString());
}
}
}
}
req.setAttributeArray(new String[] { "mimetype" });
// load by url if no contentid
if (req.isUrlRequest()) {
crBean = rp.getContentByUrl(req);
} else {
crBean = rp.getContent(req);
}
if (crBean != null) {
String mimetype = crBean.getMimetype();
if (mimetype == null) {
CRConfigUtil rpConf = crConf.getRequestProcessorConfig(1);
if (crBean.getObj_type().equals(rpConf.getPageType())) {
mimetype = "text/html; charset=" + this.responseEncoding;
log.info("Responding with mimetype: text/html");
} else {
log.info("Mimetype has not been set, using " + "standard instead. (" + crBean.getObj_type()
+ "!=" + rpConf.getPageType() + ")");
}
} else {
// Charset should only be set if content is not a binary
mimetype = crBean.getMimetype(); //+ "; charset=" + this.responseEncoding;
log.info("Responding with mimetype: " + crBean.getMimetype());
}
responsetypesetter.setContentType(mimetype);
responsetypesetter.setResponseCode(HTTPRequest.HTTP_OK);
// output data.
if (crBean.isBinary()) {
log.debug("Size of content: " + crBean.getBinaryContent().length);
stream.write(crBean.getBinaryContent());
} else {
OutputStreamWriter wr = new OutputStreamWriter(stream, this.responseEncoding);
String content = crBean.getContent(this.responseEncoding);
if (Boolean.parseBoolean((String) crConf.get(LIVEEDITORXHTML_KEY))) {
// Gentics Content.Node Liveeditor produces non XHTML
// brakes.
// Therefore we must replace them before we return the
// code