if (profileName == null || profileName.length() < 1) {
profileName = "jbpm";
}
IDiagramProfile profile = _profileService.findProfile(
request, profileName);
if (profile == null) {
_logger.error("No profile with the name " + profileName
+ " was registered");
throw new IllegalArgumentException(
"No profile with the name " + profileName +
" was registered");
}
IDiagramPreprocessingUnit preprocessingUnit = null;
if (_preProcess) {
if (_logger.isInfoEnabled()) {
_logger.info(
"Performing diagram information pre-processing steps. ");
}
preprocessingUnit = _preProcessingService.findPreprocessingUnit(request, profile);
preprocessingUnit.preprocess(request, response, profile, getServletContext(), Boolean.parseBoolean(readOnly), ioService, descriptor);
}
//output env javascript files
JSONArray scriptsArray;
if (_devMode) {
scriptsArray = new JSONArray();
for (String nextScript : _envFiles) {
scriptsArray.put(designer_path + nextScript);
}
} else {
scriptsArray = new JSONArray();
scriptsArray.put(designer_path + "jsc/env_combined.js");
}
// generate script tags for plugins.
// they are located after the initialization script.
if (_pluginfiles.get(profileName) == null) {
List<IDiagramPlugin> compressed = new ArrayList<IDiagramPlugin>();
List<IDiagramPlugin> uncompressed = new ArrayList<IDiagramPlugin>();
_pluginfiles.put(profileName, compressed);
_uncompressedPlugins.put(profileName, uncompressed);
for (String pluginName : profile.getPlugins()) {
IDiagramPlugin plugin = _pluginService.findPlugin(request,
pluginName);
if (plugin == null) {
_logger.warn("Could not find the plugin " + pluginName +
" requested by the profile " + profile.getName());
continue;
}
if (plugin.isCompressable()) {
compressed.add(plugin);
} else {
uncompressed.add(plugin);
}
}
}
JSONArray pluginsArray = new JSONArray();
if (_devMode) {
for (IDiagramPlugin jsFile : _pluginfiles.get(profileName)) {
pluginsArray.put("/plugin/" + jsFile.getName() + ".js");
}
} else {
pluginsArray.put(designer_path + "jsc/plugins_" + profileName + ".js");
}
for (IDiagramPlugin uncompressed :
_uncompressedPlugins.get(profileName)) {
pluginsArray.put(designer_path + "plugin/" + uncompressed.getName() + ".js");
}
ST editorTemplate = new ST(_doc, '$', '$');
editorTemplate.add("editorprofile", profileName);
editorTemplate.add("editoruuid", uuid);
editorTemplate.add("editorid", editorID);
//editorTemplate.add("activenodes", activeNodes);
//editorTemplate.add("completednodes", completedNodes);
//editorTemplate.add("processsource", encodedProcessSource);
editorTemplate.add("readonly", readOnly);
editorTemplate.add("allscripts", scriptsArray.toString());
editorTemplate.add("allplugins", pluginsArray.toString());
editorTemplate.add("title", profile.getTitle());
editorTemplate.add("stencilset", profile.getStencilSet());
editorTemplate.add("debug", _devMode);
editorTemplate.add("preprocessing", preprocessingUnit == null ? "" : preprocessingUnit.getOutData());
editorTemplate.add("externalprotocol", RepositoryInfo.getRepositoryProtocol(profile) == null ? "" : RepositoryInfo.getRepositoryProtocol(profile));
editorTemplate.add("externalhost", RepositoryInfo.getRepositoryHost(profile));
editorTemplate.add("externalsubdomain", RepositoryInfo.getRepositorySubdomain(profile) != null ? RepositoryInfo.getRepositorySubdomain(profile).substring(0,
RepositoryInfo.getRepositorySubdomain(profile).indexOf("/")) : "");
editorTemplate.add("repositoryid", "designer");
editorTemplate.add("localhistoryenabled", profile.getLocalHistoryEnabled());
editorTemplate.add("localhistorytimeout", profile.getLocalHistoryTimeout());
editorTemplate.add("designerversion", _designerVersion);
editorTemplate.add("storesvgonsave", profile.getStoreSVGonSaveOption());
editorTemplate.add("defaultSkin", designer_path + "css/theme-default.css");
editorTemplate.add("presetperspective", System.getProperty(PRESET_PERSPECTIVE) == null ? "" : System.getProperty(PRESET_PERSPECTIVE));
String overlaySkin = "";
if (_skin != null && !_skin.equals("default")) {
overlaySkin = designer_path + "css/theme-" + _skin + ".css";
}
editorTemplate.add("overlaySkin", overlaySkin);
StringBuilder plugins = new StringBuilder();
boolean commaNeeded = false;
for (String ext : profile.getPlugins()) {
if (commaNeeded) {
plugins.append(",");
} else {
commaNeeded = true;
}
plugins.append("\"").append(ext).append("\"");
}
editorTemplate.add("profileplugins", plugins.toString());
StringBuilder ssexts = new StringBuilder();
commaNeeded = false;
for (String ext : profile.getStencilSetExtensions()) {
if (commaNeeded) {
ssexts.append(",");
} else {
commaNeeded = true;
}