]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Salome HOME
Fix: document removing is fixed. Unit tests for StudyDAO and StepService.removeDocume...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ApplicationSettings.java
index cd4e68e5a05e5a35faf9b3302bd2f2c67ec8c4f1..7f9e3084c4292caf9841a0f511f1da9c1452bb41 100644 (file)
@@ -53,40 +53,40 @@ public class ApplicationSettings {
        /**
         * JNDI context for launching converters.
         */
-       private transient static final Properties _jndprops;
+       private transient static final Properties _JNDPROPS;
        /**
         * Siman web application name.
         */
-       private transient static String _wappname;
+       private transient static String wappname;
        /**
         * General properties from the application properties files.
         */
-       private transient static final Properties _wapprops = new Properties();
+       private transient static final Properties _WAPPROPS = new Properties();
        /**
         * Siman web application root path on the server.
         */
-       private transient static String _wapproot;
+       private transient static String wapproot;
        /**
         * Available template files.
         */
-       private transient static Map<String, String> _tempfile;
+       private transient static Map<String, String> tempfile;
        /**
         * List of file extensions mapped to a viewer.
         */
-       private transient static String[] _viewermap;
+       private transient static String[] viewermap;
        /**
         * Available document format converters.
         */
-       private transient static Map<String, Converter> _convertmap;
+       private transient static Map<String, Converter> convertmap;
 
        static {
-               synchronized (_wapprops) {
+               synchronized (_WAPPROPS) {
                        // Do common configuration for all users
 
-                       _jndprops = new Properties();
-                       _tempfile = new HashMap<String, String>();
-                       _viewermap = new String[0];
-                       _convertmap = new HashMap<String, Converter>();
+                       _JNDPROPS = new Properties();
+                       tempfile = new HashMap<String, String>();
+                       viewermap = new String[0];
+                       convertmap = new HashMap<String, Converter>();
 
                        ClassLoader cloader = Thread.currentThread()
                                        .getContextClassLoader();
@@ -94,15 +94,15 @@ public class ApplicationSettings {
                                        .currentRequestAttributes()).getRequest();
                        String appname = curRequest.getContextPath();
                        if (appname.startsWith("/")) {
-                               _wappname = appname.substring(1);
+                               wappname = appname.substring(1);
                        }
                        // Set local path on the server to the application root.
-                       _wapproot = curRequest.getSession().getServletContext()
-                                       .getRealPath("/");
+                       wapproot = curRequest.getSession().getServletContext().getRealPath(
+                                       "/");
 
                        try {
-                               _jndprops.load(cloader.getResourceAsStream("jndi.properties"));
-                               _wapprops.load(cloader.getResourceAsStream(_wappname
+                               _JNDPROPS.load(cloader.getResourceAsStream("jndi.properties"));
+                               _WAPPROPS.load(cloader.getResourceAsStream(wappname
                                                + ".properties"));
                        } catch (IOException e) {
                                LOG.info(
@@ -111,11 +111,11 @@ public class ApplicationSettings {
                        }
 
                        // Configure login security
-                       System.setProperty("java.security.auth.login.config", _wapproot
+                       System.setProperty("java.security.auth.login.config", wapproot
                                        + ApplicationSettings.getApplicationProperty("wapp.login"));
 
                        // Customization (must be done after above default settings)
-                       File config = new File(_wapproot
+                       File config = new File(wapproot
                                        + getApplicationProperty("wapp.customization"));
                        if (config.exists()) {
                                loadCustomization(config); // Sets default document types, installed modules and available templates
@@ -228,11 +228,15 @@ public class ApplicationSettings {
        /**
         * Rename menu item name.
         */
-       private static final String MNU_NAME_RENAME = "menu.rename";    
+       private static final String MNU_NAME_RENAME = "menu.rename";
        /**
-        * Publish menu item name.
+        * Mark as reference menu item name.
+        */
+       private static final String MNU_MARK_AS_REFERENCE = "markasreference";
+       /**
+        * Mark as reference menu item label key.
         */
-       private static final String MNU_MARK_AS_REFERENCE = "menu.markasreference";
+       private static final String MNU_NAME_MARK_AS_REFERENCE = "menu.markasreference";
        /**
         * Not yet implemented action name.
         */
@@ -289,7 +293,7 @@ public class ApplicationSettings {
                                + curRequest.getServerPort();
 
                LOG.info("Application server is set to " + _wappserver);
-               LOG.info("Application name is set to " + _wappname);
+               LOG.info("Application name is set to " + wappname);
        }
 
        /**
@@ -319,10 +323,10 @@ public class ApplicationSettings {
                                        "select?menu=create&item=new-empty");
                        addItem("new-copy", new MenuItem("menu.new.copy")
                                        .icon("image.copy.png"));
-                       /*addItem("new-instance", new MenuItem("menu.new.instance")
-                                       .icon(IMG_HOLD));
-                       addItem("new-import", new MenuItem("menu.new.import")
-                                       .icon("icon.upload.png"));*/
+                       /*
+                        * addItem("new-instance", new MenuItem("menu.new.instance") .icon(IMG_HOLD)); addItem("new-import", new
+                        * MenuItem("menu.new.import") .icon("icon.upload.png"));
+                        */
                        this.selects("new-empty");
                }
        }
@@ -344,9 +348,9 @@ public class ApplicationSettings {
                private PropertiesMenu() {
                        super("configuration");
                        addItem("prop-general", "menu.prop.general", IMG_HOLD,
-                                       "select?menu=properties&item=prop-general");
+                                       "select?menu=configuration&item=prop-general");
                        addItem("prop-scenario", "menu.prop.scenario", IMG_HOLD,
-                                       "select?menu=properties&item=prop-scenario");
+                                       "select?menu=configuration&item=prop-scenario");
                        // These menu items will not be implemented in the current version.
                        /*
                         * addItem("prop-timestamp", new MenuItem("menu.prop.timestamp") .icon("image.stamp.png")); addItem("prop-comlog", new
@@ -379,8 +383,74 @@ public class ApplicationSettings {
                }
        }
 
+       /**
+        * Menu items enumeration.
+        */
        private enum Item {
-               publish, accept, approve, promote, demote, undo, rename, attach, edit, script, version, replace, export, remove, purge
+               /**
+                * Publish the study.
+                */
+               publish,
+               /**
+                * Accept the document.
+                */
+               accept, 
+               /**
+                * Approve the document.
+                */
+               approve, 
+               /**
+                * Promote the document.
+                */
+               promote, 
+               /**
+                * Demote the docuemnt.
+                */
+               demote, 
+               /**
+                * Undo the last operation.
+                */
+               undo, 
+               /**
+                * Rename the document.
+                */
+               rename, 
+               /**
+                * Attach a file to the document.
+                */
+               attach, 
+               /**
+                * Edit the document.
+                */
+               edit, 
+               /**
+                * script
+                */
+               script, 
+               /**
+                * Version the document.
+                */
+               version, 
+               /**
+                * replace
+                */
+               replace, 
+               /**
+                * export
+                */
+               export, 
+               /**
+                * Remove the document.
+                */
+               remove, 
+               /**
+                * purge
+                */
+               purge, 
+               /**
+                * Mark the study as reference.
+                */
+               markasreference
        };
 
        // Resources relative to studies
@@ -389,31 +459,35 @@ public class ApplicationSettings {
 
                private EditableStudyPopup() {
                        super();
-                       addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_MARK_AS_REFERENCE)
-                                       .action(ACT_NOT_YET_IMPLEMENTED)
-                                       .confirmation("message.markasreference.study"));
+                       addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_NAME_MARK_AS_REFERENCE)
+                                       .action(ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                                       "message.markasreference.study"));
                        addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
                                        "image.publish.png").action("edit-study?action=publish")
                                        .confirmation("message.publish.study"));
-                       /*addItem(MNU_PROMOTE, new PopupItem("menu.archive"));*/
+                       /* addItem(MNU_PROMOTE, new PopupItem("menu.archive")); */
                        addSeparator();
                        addItem(MNU_EDIT, new PopupItem("menu.properties").icon(
                                        "icon.ed.png").action("../select?menu=properties"));
                        addSeparator();
                        addItem(MNU_SCRIPT, new PopupItem(MNU_NAME_SCRIPT)
                                        .action("add-scenario"));
-                       /*addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
-                                       IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED));*/
+                       /*
+                        * addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon( IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED));
+                        */
                        addSeparator();
-                       /*addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE)
-                                       .confirmation("message.purge.study"));
-                       addItem("export", new PopupItem("menu.export")
-                                       .icon("image.export.png")); // For future needs
-*/                     addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
-                                       .action(ACT_NOT_YET_IMPLEMENTED).confirmation(
-                                                       "message.delete.study"));
+                       /*
+                        * addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE) .confirmation("message.purge.study")); addItem("export", new
+                        * PopupItem("menu.export") .icon("image.export.png")); // For future needs
+                        */addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(
+                                       IMG_DELETE).action(ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                       "message.delete.study"));
                }
 
+               /** 
+                * {@inheritDoc}
+                * @see org.splat.wapp.ContextualMenu#isEnabled(java.lang.String)
+                */
                @Override
                public boolean isEnabled(final String name) {
                        boolean res = (_user != null);
@@ -688,7 +762,7 @@ public class ApplicationSettings {
         */
        private static class ApprovedPopup extends PopupMenu {
                private ApprovedPopup() {
-                       super(); 
+                       super();
                        addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
                                        .action(ACT_ATTACH));
                        addSeparator();
@@ -731,7 +805,7 @@ public class ApplicationSettings {
                                                break;
                                        case version:
                                                res = _user.canVersion();
-                                               break;  
+                                               break;
                                        case replace:
                                                res = _user.canReplace();
                                                break;
@@ -939,7 +1013,7 @@ public class ApplicationSettings {
                                if (dtype != null) {
                                        docname = dtype.getName();
                                }
-                               if (_tempfile.get(docname) == null) { // No available template
+                               if (tempfile.get(docname) == null) { // No available template
                                        String tool = parsed[parsed.length - 1];
                                        String icon = name[0];
                                        if ("index".equals(icon)) {
@@ -974,17 +1048,17 @@ public class ApplicationSettings {
        }
 
        public static String getApplicationProperty(final String name) {
-               return _wapprops.getProperty(name); // May be null
+               return _WAPPROPS.getProperty(name); // May be null
        }
 
        public static String getApplicationRootPath() {
                // The property is supposed including the Web application name
-               return _wapproot;
+               return wapproot;
        }
 
        public String getApplicationURL() {
                StringBuffer url = new StringBuffer("http://").append(_wappserver)
-                               .append("/").append(_wappname);
+                               .append("/").append(wappname);
                return url.toString();
        }
 
@@ -997,7 +1071,7 @@ public class ApplicationSettings {
        }
 
        static public Properties getNamingProperties() {
-               return _jndprops;
+               return _JNDPROPS;
        }
 
        // ==============================================================================================================================
@@ -1018,7 +1092,7 @@ public class ApplicationSettings {
 
        public static Converter getConverter(final DocumentType type,
                        final String format) {
-               return _convertmap.get(format + type.getName()); // May be null;
+               return convertmap.get(format + type.getName()); // May be null;
        }
 
        public DocumentType getDefaultDocumentType(final Step step,
@@ -1052,7 +1126,7 @@ public class ApplicationSettings {
        }
 
        public static Locale[] getSupportedLocales() {
-               String[] code = _wapprops.getProperty("locale.supported").split(",");
+               String[] code = _WAPPROPS.getProperty("locale.supported").split(",");
                Locale[] result = new Locale[code.length];
                for (int i = 0; i < code.length; i++) {
                        result[i] = new Locale(code[i]);
@@ -1061,7 +1135,7 @@ public class ApplicationSettings {
        }
 
        public static String[] getViewersMapping() {
-               return _viewermap;
+               return viewermap;
        }
 
        public static String getWebSiteURL() {
@@ -1123,11 +1197,11 @@ public class ApplicationSettings {
                        NamedNodeMap natr = child.getAttributes();
                        String dext = natr.getNamedItem("extension").getNodeValue();
                        String exec = natr.getNamedItem("executable").getNodeValue();
-                       _wapprops.put("executable." + dext, exec);
+                       _WAPPROPS.put("executable." + dext, exec);
                }
                // Viewer mappings tag
                child = children.get("viewers");
-               _viewermap = child.getAttributes().getNamedItem("extension")
+               viewermap = child.getAttributes().getNamedItem("extension")
                                .getNodeValue().split(",");
        }
 
@@ -1148,7 +1222,7 @@ public class ApplicationSettings {
                                String from = natr.getNamedItem("from").getNodeValue();
                                String to = natr.getNamedItem("to").getNodeValue();
                                String exec = natr.getNamedItem("executable").getNodeValue();
-                               _convertmap.put(from + "geometry", new Converter("geometry",
+                               convertmap.put(from + "geometry", new Converter("geometry",
                                                from, to, exec));
                        }
                }
@@ -1172,7 +1246,7 @@ public class ApplicationSettings {
                        NamedNodeMap natr = child.getAttributes();
                        String type = natr.getNamedItem("type").getNodeValue();
                        String file = natr.getNamedItem("file").getNodeValue();
-                       _tempfile.put(type, file);
+                       tempfile.put(type, file);
                }
        }