1 package org.splat.simer;
4 import java.io.IOException;
5 import java.util.HashMap;
6 import java.util.HashSet;
7 import java.util.Iterator;
8 import java.util.LinkedHashMap;
10 import java.util.Locale;
12 import java.util.Properties;
14 import java.util.Vector;
16 import javax.xml.parsers.DocumentBuilder;
17 import javax.xml.parsers.DocumentBuilderFactory;
18 import org.w3c.dom.Node;
19 import org.w3c.dom.NodeList;
20 import org.w3c.dom.NamedNodeMap;
22 import org.apache.log4j.Logger;
23 import org.splat.kernel.User;
24 import org.splat.manox.XDOM;
25 import org.splat.som.Document;
26 import org.splat.som.DocumentRights;
27 import org.splat.som.DocumentType;
28 import org.splat.som.KnowledgeElement;
29 import org.splat.som.ProgressState;
30 import org.splat.som.ProjectSettings;
31 import org.splat.som.SimulationContext;
32 import org.splat.som.Step;
33 import org.splat.som.StudyRights;
34 import org.splat.wapp.MenuItem;
35 import org.splat.wapp.PopupMenu;
36 import org.splat.wapp.PopupItem;
37 import org.splat.wapp.SimpleMenu;
38 import org.splat.wapp.ToolBar;
41 public class ApplicationSettings {
43 private String wappserver;
44 private String wappname;
45 private Properties wapprops; // General properties from the application properties files
46 private Locale locale; // Current user locale
47 private Map<String,SimpleMenu> menus = null; // Application menus
48 private Map<Integer,ToolBar> bars = null; // Study module-bars structured by steps
49 private Map<String,PopupMenu> popups = null;
50 private Map<String,Map<String,Object>> filter = null; // Named search filters
51 private Map<String,DocumentType> defdoctype = null; // Default document types structured by step.formats
52 private Map<String,String> tempfile = null; // Available template files
53 private String[] viewermap = null; // List of file extensions mapped to a viewer
54 private Map<String,Converter> convertmap = null; // Available document format converters
55 private Properties jndprops = null; // JNDI context for launching converters
57 private static ApplicationSettings my = null; // Singleton instance
58 protected final static Logger logger = Logger.getLogger(ApplicationSettings.class);
61 private static class NewMenu extends SimpleMenu {
62 // -----------------------------------------------------------------
66 addItem("new-empty", "menu.new.empty", "image.empty.png", "select?menu=create&item=new-empty");
67 addItem("new-copy", new MenuItem("menu.new.copy").icon("image.copy.png") );
68 addItem("new-instance", new MenuItem("menu.new.instance").icon("image.hold.gif") );
69 addItem("new-import", new MenuItem("menu.new.import").icon("icon.upload.png") );
70 this.selects("new-empty");
73 private static class SearchMenu extends SimpleMenu {
74 // -----------------------------------------------------------------
78 addItem("search-study", "menu.search.study", "image.study.png", "select?menu=search&item=search-study");
79 addItem("search-knowledge", "menu.search.idea", "image.idea.png", "select?menu=search&item=search-knowledge");
80 addItem("search-document", new MenuItem("menu.search.document").icon("icon.any.png") );
81 this.selects("search-study");
84 private static class PropertiesMenu extends SimpleMenu {
85 // -----------------------------------------------------------------
86 private PropertiesMenu ()
88 super("configuration");
89 addItem("prop-general", "menu.prop.general", "image.hold.gif", "select?menu=properties&item=prop-general");
90 addItem("prop-scenario", "menu.prop.scenario", "image.hold.gif", "select?menu=properties&item=prop-scenario");
91 addItem("prop-timestamp", new MenuItem("menu.prop.timestamp").icon("image.stamp.png") );
92 addItem("prop-comlog", new MenuItem("menu.prop.comlog").icon("image.hold.gif") );
93 addItem("prop-version", new MenuItem("menu.prop.version").icon("image.dirclosed.png") );
96 private static class DatadminMenu extends SimpleMenu {
97 // -----------------------------------------------------------------
98 private DatadminMenu ()
101 addItem("admin-scontext", "menu.admin.context", "image.hold.gif", "select?menu=datadmin&item=admin-scontext");
102 addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png", "select?menu=datadmin&item=admin-knowelm");
103 addItem("admin-study", new MenuItem("menu.admin.study").icon("image.study.png") );
106 private static class SysadminMenu extends SimpleMenu {
107 // -----------------------------------------------------------------
108 private SysadminMenu ()
111 addItem("admin-indexing", "menu.admin.indexing", "image.index.png", "select?menu=sysadmin&item=admin-indexing");
112 addItem("admin-importuser", "menu.admin.importuser", "image.group.png", "select?menu=sysadmin&item=admin-importuser");
115 private enum Item { publish, accept, approve, promote, demote, undo, rename, attach, edit, script, version, replace, export, remove, purge };
116 // Resources relative to studies
117 private static class EditableStudyPopup extends PopupMenu {
118 // ----------------------------------------------------------------
119 private StudyRights user = null;
121 private EditableStudyPopup ()
123 addItem("publish", new PopupItem("menu.publish").icon("image.publish.png").action("edit-study?action=publish").confirmation("message.publish.study"));
124 addItem("promote", new PopupItem("menu.archive"));
126 addItem("edit", new PopupItem("menu.properties").icon("icon.ed.png").action("../select?menu=properties"));
128 addItem("script", new PopupItem("menu.newscenario").action("add-scenario"));
129 addItem("version", new PopupItem("menu.version").icon("image.version.png").action("notyetimplemented"));
131 addItem("purge", new PopupItem("menu.purge").confirmation("message.purge.study"));
132 addItem("export", new PopupItem("menu.export").icon("image.export.png")); // For future needs
133 addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("notyetimplemented").confirmation("message.delete.study"));
135 public boolean isEnabled (String name)
137 if (user == null) return false; // Should not happen
138 Item item = Item.valueOf(name);
139 if (item == Item.publish) return user.canPublish();
140 if (item == Item.edit) return user.canEditProperties();
141 if (item == Item.script) return user.canAddScenario();
142 if (item == Item.version) return user.canVersion();
143 if (item == Item.remove) return user.canRemove();
144 if (item == Item.purge) return user.canPurge();
147 public void setContext (String name, Object context)
149 if (context instanceof StudyRights) {
150 user = (StudyRights)context; // Just for optimizing
151 boolean history = user.getOperand().isVersioned();
152 PopupItem item = this.item("remove");
153 if (history) item.rename("menu.remove.version");
154 else item.rename("menu.remove.study");
158 // Resources relative to documents
159 private static class EditableDocumentPopup extends PopupMenu { // Popup of In-Work documents
160 // ----------------------------------------------------------------
161 private DocumentRights user = null;
163 private EditableDocumentPopup ()
165 addItem("accept", new PopupItem("menu.accept").icon("image.accept.png").action("setDocument?action=accept").confirmation("message.accept.document"));
166 addItem("promote", new PopupItem("menu.promote").icon("image.publish.png").action("setDocument?action=promote").confirmation("message.promote.document"));
168 addItem("rename", new PopupItem("menu.rename").action("edit-document?action=renameDocument"));
169 addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
171 addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
172 addItem("replace", new PopupItem("menu.replace").icon("image.replace.png").action("select-file?nextAction=replace"));
174 addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
175 addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
177 public boolean isEnabled (String name)
179 if (user == null) return false; // Should not happen
180 Item item = Item.valueOf(name);
181 if (item == Item.accept) return user.canAccept();
182 if (item == Item.promote) return user.canPromote();
183 if (item == Item.rename) return user.canRename();
184 if (item == Item.attach) return user.canAttach();
185 if (item == Item.version) return user.canVersion();
186 if (item == Item.replace) return user.canReplace();
187 if (item == Item.purge) return user.canPurge();
188 if (item == Item.remove) return user.canRemove();
191 public void setContext (String name, Object context)
193 if (context instanceof DocumentRights) {
194 user = (DocumentRights)context; // Just for optimizing
195 Document downer = user.getOperand();
196 PopupItem item = this.item("remove");
197 if (downer.isVersioned()) item.rename("menu.remove.version");
198 else item.rename("menu.remove.document");
202 private static class ReviewableDocumentPopup extends PopupMenu { // Popup of In-Draft documents
203 // ----------------------------------------------------------------
204 private DocumentRights user = null;
206 private ReviewableDocumentPopup ()
208 addItem("demote", new PopupItem("menu.demote").icon("image.demote.png").action("setDocument?action=demote").confirmation("message.demote.document"));
209 addItem("promote", new PopupItem("menu.review").icon("image.review.png").action("setDocument?action=review").confirmation("message.review.document"));
211 addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
213 addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
215 addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
217 public boolean isEnabled (String name)
219 if (user == null) return false; // Should not happen
220 Item item = Item.valueOf(name);
221 if (item == Item.demote) return user.canDemote();
222 if (item == Item.promote) return user.canReview();
223 if (item == Item.attach) return user.canAttach();
224 if (item == Item.version) return user.canVersion();
225 if (item == Item.purge) return user.canPurge();
228 public void setContext (String name, Object context)
230 if (context instanceof DocumentRights) {
231 user = (DocumentRights)context; // Just for optimizing
235 private static class NotResultDocumentPopup extends PopupMenu {
236 // ----------------------------------------------------------------
237 private DocumentRights user = null;
239 private NotResultDocumentPopup ()
241 addItem("demote", new PopupItem("menu.demote").icon("image.demote.png").action("setDocument?action=demote").confirmation("message.demote.document"));
243 addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
245 addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
247 addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
248 addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
251 private static class ApprovableDocumentPopup extends PopupMenu { // Popup of In-Check documents
252 // ----------------------------------------------------------------
253 private DocumentRights user = null;
255 private ApprovableDocumentPopup ()
257 addItem("undo", new PopupItem("menu.demote").icon("image.invalidate.png").action("setDocument?action=invalidate").confirmation("message.demote.document"));
258 addItem("demote", new PopupItem("menu.disapprove").icon("image.demote.png").action("setDocument?action=disapprove").confirmation("message.disapprove.document"));
259 addItem("approve", new PopupItem("menu.approve").icon("icon.APPROVED.png").action("setDocument?action=approve").confirmation("message.approve.document"));
261 public boolean isEnabled (String name)
263 if (user == null) return false; // Should not happen
264 Item item = Item.valueOf(name);
265 if (item == Item.undo) return user.canInvalidate();
266 if (item == Item.demote) return user.canDemote();
267 if (item == Item.approve) return user.canApprove();
270 public void setContext (String name, Object context)
272 if (context instanceof DocumentRights) {
273 user = (DocumentRights)context; // Just for optimizing
277 private static class ApprovedPopup extends PopupMenu { // Popup of Approved documents
278 // ----------------------------------------------------------------
279 private ApprovedPopup ()
281 addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
283 addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
286 private static class ExternPopup extends PopupMenu { // Popup of Extern documents
287 // ----------------------------------------------------------------
288 private DocumentRights user = null;
290 private ExternPopup ()
292 addItem("rename", new PopupItem("menu.rename").action("edit-document?action=renameDocument"));
293 addItem("replace", new PopupItem("menu.replace").icon("image.replace.png").action("select-file?nextAction=replace"));
295 addItem("remove", new PopupItem("menu.remove.document").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
297 public boolean isEnabled (String name)
299 if (user == null) return false; // Should not happen
300 Item item = Item.valueOf(name);
301 if (item == Item.rename) return user.canRename();
302 if (item == Item.replace) return user.canReplace();
303 if (item == Item.remove) return user.canRemove();
306 public void setContext (String name, Object context)
308 if (context instanceof DocumentRights) {
309 user = (DocumentRights)context; // Just for optimizing
313 // Resources relative to simulation contexts
314 private static class ScontextPopup extends PopupMenu {
315 // --------------------------------------------------------
316 private SimulationContextFacade owner = null;
318 private ScontextPopup ()
320 addItem("rename", new PopupItem("menu.rename").action("edit-context?action=renameContext"));
321 addItem("edit", new PopupItem("menu.edit").action("edit-context?action=editContext"));
323 addItem("remove", new PopupItem("menu.remove").icon("icon.delete.png").action("remove-context").confirmation("message.delete.context"));
325 public boolean isEnabled (String name)
327 Item item = Item.valueOf(name);
329 if (item == Item.rename) {
332 if (item == Item.edit) {
333 // if (!owner.isEditable())
338 public void setContext (String name, Object context)
340 if (context instanceof SimulationContextFacade) {
341 owner = (SimulationContextFacade)context; // Just for optimizing
344 super.setContext(name, context);
348 // Resources relative to knowledge
349 private static class FeedbexPopup extends PopupMenu {
350 // --------------------------------------------------------
351 private KnowledgeElement owner = null;
353 private FeedbexPopup ()
355 addItem("promote", new PopupItem("menu.promote").icon("image.review.png").action("promote-knowledge").confirmation("message.promote.knowledge"));
356 addItem("demote", new PopupItem("menu.demote").icon("image.invalidate.png").action("demote-knowledge").confirmation("message.demote.knowledge"));
358 addItem("rename", new PopupItem("menu.rename").action("edit-knowledge?action=renameKnowledge"));
359 addItem("edit", new PopupItem("menu.edit").action("edit-knowledge?action=editKnowledge"));
361 addItem("remove", new PopupItem("menu.remove").icon("icon.delete.png").action("remove-knowledge").confirmation("message.delete.knowledge"));
363 public boolean isEnabled (String name)
365 Item item = Item.valueOf(name);
367 if (item == Item.promote) {
368 if (owner.getProgressState() != ProgressState.inDRAFT) return false;
370 if (item == Item.demote) {
371 if (owner.getProgressState() != ProgressState.inCHECK) return false;
375 public void setContext (String name, Object context)
377 if (context instanceof KnowledgeElement) owner = (KnowledgeElement)context; // Just for optimizing
379 super.setContext(name, context);
384 // ==============================================================================================================================
386 // ==============================================================================================================================
388 public static ApplicationSettings getMe () {
389 // ------------------------------------------
390 return my; // The application is supposed being previously created below
392 protected ApplicationSettings (String wappurl, Locale lang) throws IOException {
393 // -----------------------------------------------------------
394 ClassLoader cloader = getClass().getClassLoader();
395 String[] wurl = wappurl.split("/"); // [0]="http:", [1]="", [2]="{server}:{port}", [3]="name"
398 wappserver = wurl[2];
400 wapprops = new Properties();
401 jndprops = new Properties();
402 wapprops.load(cloader.getResourceAsStream(wappname + ".properties"));
403 jndprops.load(cloader.getResourceAsStream("jndi.properties"));
405 logger.info("Application root set to " + wapprops.getProperty("wapp.root"));
409 // ==============================================================================================================================
410 // Public member functions
411 // ==============================================================================================================================
413 public void configure (String filename) {
414 // ---------------------------------------
415 // Non customizable settings
416 menus = new HashMap<String, SimpleMenu>();
417 SimpleMenu menu = new NewMenu();
418 menus.put( menu.getName(), menu );
419 menu = new SearchMenu();
420 menus.put( menu.getName(), menu );
421 menu = new DatadminMenu();
422 menus.put( menu.getName(), menu );
423 menu = new SysadminMenu();
424 menus.put( menu.getName(), menu );
425 menu = new PropertiesMenu();
426 menus.put( menu.getName(), menu );
428 popups = new HashMap<String, PopupMenu>();
429 popups.put("steditable", new EditableStudyPopup());
430 popups.put("editable", new EditableDocumentPopup());
431 popups.put("notresult", new NotResultDocumentPopup());
432 popups.put("reviewable", new ReviewableDocumentPopup());
433 popups.put("approvable", new ApprovableDocumentPopup());
434 popups.put("approved", new ApprovedPopup());
435 popups.put("extern", new ExternPopup());
436 popups.put("scontext", new ScontextPopup());
437 popups.put("feedbex", new FeedbexPopup());
439 // Default customizable mandatory settings
440 Map<String, Object> fprop = new HashMap<String, Object>();
441 fprop.put("visibility", "PRIVATE");
442 fprop.put("matchamong", "all");
443 fprop.put("matcontext", "all");
444 fprop.put("state", "END");
445 fprop.put("author", "0");
446 fprop.put("reference", "");
447 fprop.put("title", "");
448 fprop.put("context", new Vector<SimulationContext>());
450 Map<String, Object> gprop = new HashMap<String, Object>();
451 gprop.put("visibility", "PUBLIC");
452 gprop.put("matchamong", "all");
453 gprop.put("matcontext", "all");
454 gprop.put("type", "2"); //TODO: Get the index from the type name
455 gprop.put("author", "0");
456 gprop.put("reference", "");
457 gprop.put("title", "");
458 gprop.put("context", new Vector<SimulationContext>());
460 defdoctype = new LinkedHashMap<String, DocumentType>();
461 tempfile = new HashMap<String, String>();
462 viewermap = new String[0];
463 convertmap = new HashMap<String, Converter>();
464 filter = new HashMap<String, Map<String, Object>>();
465 filter.put("study", fprop);
466 filter.put("knowledge", gprop);
468 // Customization (must be done after above default settings)
469 File config = new File(filename);
470 if (config.exists()) {
471 loadCustomization(config); // Sets default document types, installed modules and available templates
473 logger.info("Could not find the application configuration file \"" + config.getAbsolutePath() + "\", using default settings");
475 // Settings based on the customization
476 bars = new HashMap<Integer, ToolBar>(); // May be empty if no module installed
478 List<ProjectSettings.Step> steps = ProjectSettings.getAllSteps();
479 for (Iterator<ProjectSettings.Step> i=steps.iterator(); i.hasNext();) {
480 ProjectSettings.Step step = i.next();
481 List<String> formats = getDefaultFormats(step);
482 if (formats.size() == 0) continue;
484 ToolBar bar = new ToolBar(24); // Height of the module-bar
485 HashSet<String> module = new HashSet<String>(); // For not duplicating modules
486 for (Iterator<String> j=formats.iterator(); j.hasNext();) {
487 String format = j.next();
488 String command = getApplicationProperty("executable." + format);
489 if (command == null) continue; // Module not installed
490 if (module.contains(command)) continue;
492 String[] parsed = command.split("/");
493 String[] name = parsed[parsed.length-1].split("\\x2E");
494 String docname = my.defdoctype.get(step.getNumber() + "." + format).getName();
495 if (tempfile.get(docname) == null) { // No available template
496 String tool = parsed[parsed.length-1];
497 String icon = name[0];
498 if (icon.equals("index")) {
499 tool = parsed[parsed.length-2];
500 icon = "tool." + tool.toLowerCase() + ".png";
503 icon = "tool." + icon.toLowerCase() + ".png";
505 File image = new File(ApplicationSettings.getApplicationSkinPath() + icon);
506 if (!image.exists()) icon = "tool.any.png";
507 bar.addTool(tool, icon, command);
509 docname = "/jsp/newDocument.jsp?type=" + docname;
510 String icon = "tool." + name[0].toLowerCase() + ".png";
511 File image = new File(ApplicationSettings.getApplicationSkinPath() + icon);
512 if (!image.exists()) icon = "tool.any.png";
513 bar.addTool(name[0], icon, command, docname);
516 if (!bar.isEmpty()) bars.put(step.getNumber(), bar);
520 public String getApplicationProperty (String name) {
521 // --------------------------------------------------
522 return wapprops.getProperty(name); // May be null
525 public String getApplicationRootPath () {
526 // ---------------------------------------
527 return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
530 public String getApplicationURL () {
531 // ----------------------------------
532 StringBuffer url = new StringBuffer("http://").append(my.wappserver).append("/").append(wappname);
533 return url.toString();
536 public Map<String, Object> getFilter (String name) {
537 // --------------------------------------------------
538 return filter.get(name);
541 public ToolBar getModuleBar (Step step) {
542 // -----------------------------------------
543 return bars.get(step.getNumber());
546 public Properties getNamingProperties () {
547 // ----------------------------------------
551 // ==============================================================================================================================
553 // ==============================================================================================================================
555 public static String getApplicationPluginPath () {
556 // ------------------------------------------------
557 return my.getApplicationRootPath() + "plugin/";
559 public static String getApplicationResourcePath () {
560 // --------------------------------------------------
561 return my.getApplicationRootPath() + "WEB-INF/classes/";
563 public static String getApplicationSkinPath () {
564 // ----------------------------------------------
565 return my.getApplicationRootPath() + "skin/";
567 public static Converter getConverter (DocumentType type, String format) {
568 // -----------------------------------------------------------------------
569 return my.convertmap.get(format + type.getName()); // May be null;
571 public static DocumentType getDefaultDocumentType (Step step, String format) {
572 // ----------------------------------------------------------------------------
573 String[] table = format.split("\\x2E");
574 return my.defdoctype.get(step.getNumber() + "." + table[table.length-1]); // May be null
576 public static String getDownloadURL (User user) {
577 // --------------------------------------------------
578 StringBuffer url = new StringBuffer("http://").append(my.wappserver).append("/download/").append(user.getUsername()).append("/");
579 return url.toString(); // The download Tomcat context is supposed being defined
581 public static Locale getCurrentLocale () {
582 // ----------------------------------------
585 public static SimpleMenu getMenu (String name) {
586 // ----------------------------------------------
587 return my.menus.get(name);
589 public static PopupMenu getPopupMenu (String name) {
590 // --------------------------------------------------
591 return my.popups.get(name);
593 public static String getRepositoryURL () {
594 // ----------------------------------------
595 StringBuffer url = new StringBuffer("http://").append(my.wappserver).append("/repository/");
596 return url.toString(); // The repository Tomcat context is supposed being defined
598 public static Locale[] getSupportedLocales () {
599 // ---------------------------------------------
600 String[] code = my.wapprops.getProperty("locale.supported").split(",");
601 Locale[] result = new Locale[code.length];
602 for (int i=0; i<code.length; i++) result[i] = new Locale(code[i]);
605 public static String[] getViewersMapping () {
606 // -------------------------------------------
609 public static String getWebSiteURL () {
610 // -------------------------------------
611 return my.getApplicationProperty("wapp.website");
613 public static String getHelpURL () {
614 // ----------------------------------
615 return my.getApplicationProperty("wapp.onlinehelp");
617 // ==============================================================================================================================
619 // ==============================================================================================================================
621 private List<String> getDefaultFormats (ProjectSettings.Step step) {
622 // ------------------------------------------------------------------
623 Set<String> keys = defdoctype.keySet();
624 int number = step.getNumber();
625 Vector<String> result = new Vector<String>();
627 for (Iterator<String> i=keys.iterator(); i.hasNext();) {
628 String[] key = i.next().split("\\x2E");
629 if (Integer.valueOf(key[0]) != number) continue;
630 if (key[1].equals("pdf")) continue; // PDF is not an authoring format
631 result.add(key[1]); // Formats are unique
636 private void loadCustomization (File config) {
637 // --------------------------------------------
639 DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
640 DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
642 org.w3c.dom.Document conf = dBuilder.parse(config.getPath());
643 HashMap<String, Node> children = XDOM.getNamedChildNodes(conf.getDocumentElement());
645 // Default document types tag
646 Node child = children.get("default-doctypes");
647 NodeList nlist = child.getChildNodes();
649 List<DocumentType> listype = Document.selectAllTypes();
650 HashMap<String,DocumentType> maptype = new HashMap<String,DocumentType>();
651 for (Iterator<DocumentType> i=listype.iterator(); i.hasNext();) {
652 DocumentType type = i.next();
653 maptype.put(type.getName(), type);
655 for (int i=0; i<nlist.getLength(); i++) {
656 child = nlist.item(i);
657 if (!child.getNodeName().equals("step")) continue;
659 String nstep = child.getAttributes().getNamedItem("number").getNodeValue();
660 NodeList map = child.getChildNodes();
661 for (int j=0; j<map.getLength(); j++) {
663 if (!child.getNodeName().equals("mapping")) continue;
664 NamedNodeMap natr = child.getAttributes();
665 String dext = natr.getNamedItem("extension").getNodeValue();
666 String type = natr.getNamedItem("type").getNodeValue();
667 defdoctype.put(nstep + "." + dext, maptype.get(type));
671 child = children.get("modules");
672 nlist = child.getChildNodes();
673 for (int i=0; i<nlist.getLength(); i++) {
674 child = nlist.item(i);
675 if (!child.getNodeName().equals("mapping")) continue;
677 NamedNodeMap natr = child.getAttributes();
678 String dext = natr.getNamedItem("extension").getNodeValue();
679 String exec = natr.getNamedItem("executable").getNodeValue();
680 wapprops.put("executable." + dext, exec);
682 // Viewer mappings tag
683 child = children.get("viewers");
684 viewermap = child.getAttributes().getNamedItem("extension").getNodeValue().split(",");
687 child = children.get("converters");
688 nlist = child.getChildNodes();
689 for (int i=0; i<nlist.getLength(); i++) {
690 child = nlist.item(i);
692 if (child.getNodeName().equals("geometry")) {
693 NamedNodeMap natr = child.getAttributes();
694 String from = natr.getNamedItem("from").getNodeValue();
695 String to = natr.getNamedItem("to").getNodeValue();
696 String exec = natr.getNamedItem("executable").getNodeValue();
697 convertmap.put(from + "geometry", new Converter("geometry", from, to, exec));
702 child = children.get("templates");
703 nlist = child.getChildNodes();
704 for (int i=0; i<nlist.getLength(); i++) {
705 child = nlist.item(i);
706 if (!child.getNodeName().equals("document")) continue;
708 NamedNodeMap natr = child.getAttributes();
709 String type = natr.getNamedItem("type").getNodeValue();
710 String file = natr.getNamedItem("file").getNodeValue();
711 tempfile.put(type, file);
714 catch (Exception error) {
715 logger.info("Error in customization", error);