if (tmlLib == null) {
throw new DeployerException("Tried to deploy tml module \"null\". Maybe a tml module is not accessible");
}
DesignReference ref;
try {
ref = WGADesignManager.createDesignReference(tmlLib);
}
catch (WGAPIException e1) {
throw new DeployerException("Error retrieving design reference for " + tmlLib.getDocumentKey(), e1);
}
String databaseKey = (String) tmlLib.getDatabase().getDbReference();
String layoutKey = ref.toString();
String mediaKey = null;
String resourceName = null;
try {
if (tmlLib.isVariant()) {
layoutKey = layoutKey + "//" + databaseKey;
}
mediaKey = tmlLib.getMediaKey().toLowerCase();
if (_core.isMediaKeyDefined(mediaKey) == false) {
_core.addMediaMapping(new MediaKey(mediaKey, "text/html", false, false), false);
}
// Build complete code
StringBuffer tmlCode = new StringBuffer();
tmlCode.append("<%@ taglib uri=\"http://www.innovationgate.de/wgpublisher/webtml/2.2\" prefix=\"tml\" %>");
tmlCode.append("<%@ page ");
// F000037B2
if (_core.getCharacterEncoding() != null) {
tmlCode.append(" pageEncoding=\"" + _core.getCharacterEncoding() + "\" ");
}
tmlCode.append(" buffer=\"" + _core.tmlBuffer + "kb\" autoFlush=\"true\" isThreadSafe=\"true\" session=\"true\" errorPage=\"../error.jsp\" %>");
tmlCode.append("<%@ page import=\"de.innovationgate.wgpublisher.jsputils.*\"%>");
tmlCode.append(_core.tmlHeader);
tmlCode.append("<tml:root ref=\"" + layoutKey + "\" resource=\"" + tmlLib.getName() + " (" + tmlLib.getMediaKey() + ")\" modulename=\"" + tmlLib.getName() + "\" modulemediakey=\""
+ tmlLib.getMediaKey() + "\">");
tmlCode.append(preprocessCode(tmlLib));
tmlCode.append("</tml:root>");
DeployedLayout layout = _layoutMappings.get(layoutKey);
if (layout != null) {
// use existing layout obj
layout.init(tmlLib, layoutKey, _resourcesFolder, _core.getCharacterEncoding());
}
else {
// create new
layout = new DeployedLayout(tmlLib, layoutKey, _resourcesFolder, _core.getCharacterEncoding());
}
// deploy
resourceName = tmlLib.getName().toLowerCase();
LOG.info("Deploying tml " + mediaKey + "/" + resourceName + " (" + ref.getDesignProviderReference().toString() + ")");
layout.deploy(tmlCode.toString());
// Map deployed layout
_layoutMappings.put(layoutKey, layout);
_layoutsByFileName.put(layout.getFile().getName(), layout);