// Fetch the TML module to include
WGTMLModule tmllib;
if (type.equals(TYPE_INNERLAYOUT)) {
WGContent currentContent = this.getTMLContext().content();
if (currentContent.isDummy() || !currentContent.hasCompleteRelationships()) {
throw new TMLException("The inner layout of this content cannot be determined, bc. it is either a dummy document, or it doesnt have complete document relationships.");
}
tmllib = currentContent.getStructEntry().getInnerLayout(mediaKey);
designDBKey = currentContent.getDatabase().getDbReference();
if (tmllib == null || tmllib.isDummy()) {
throw new TMLException("Cannot find inner layout for doctype " + this.getTMLContext().content().getStructEntry().getContentType().getName());
}
}
else {
WGDatabase designdb = database;
if (designDBKey != null) {
try {
designdb = this.openContentDB(designDBKey);
}
catch (WGUnavailableException e1) {
}
catch (WGException e) {
throw new TMLException(e.getMessage(), true);
}
if (designdb == null || !designdb.isSessionOpen()) {
throw new TMLException("Cannot open design db: " + designDBKey, true);
}
}
tmllib = (WGTMLModule) designdb.getDesignObject(WGDocument.TYPE_TML, status.ref, mediaKey);
if (tmllib == null) {
throw new TMLException("Cannot find requested tml module: " + status.ref + " (" + mediaKey + ")");
}
}
// Locate the resource
try {
tmlResource = this.getDeployer().locateTmlResource(tmllib);
}
catch (DeployerException e1) {
throw new TMLException("Error deploying WebTML resource", e1, true);
}
if (tmlResource == null) {
throw new TMLException("Cannot locate requested tml module: " + tmllib.getName() + " (" + tmllib.getMediaKey() + ")");
}
// Do the include
this.pageContext.setAttribute(ATTRIB_INCLUDEPARENT, status, PageContext.REQUEST_SCOPE);
String oldDesignDB = (String) getOption(Base.OPTION_DESIGNDB);
status.setOption(Base.OPTION_DESIGNDB, designDBKey, null);
try {
this.pageContext.include(tmlResource);
}
catch (Exception e) {
throw new TMLException("Error executing tml module \"" + tmllib.getName() + "/" + tmllib.getMediaKey() + "\"", e, false);
}
finally {
this.pageContext.setAttribute(ATTRIB_INCLUDEPARENT, null, PageContext.REQUEST_SCOPE);
status.setOption(Base.OPTION_DESIGNDB, oldDesignDB, null);
}
// Transfer result from included root to this tag
if (status.rootTag != null) {
this.setResult(status.rootTag.result);
status.rootTag.result = null;
} else {
throw new TMLException("Could not retrieve result of included resource: " + tmlResource);
}
if (getTMLContext().getwgacore().isProfilingEnabled()) {
HttpServletRequest request = getTMLContext().getrequest();
if (request != null) {