Salome HOME
Create new scenario from existing one is improved
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / StartAction.java
index f235f6fe2b2d47441a27cc18cbc2d003150bf472..be27e295c660b845ffd8c5a9754c46eb1bebda7d 100644 (file)
@@ -2,186 +2,61 @@ package org.splat.simer;
 
 import java.util.Map;
 
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.struts2.interceptor.ServletRequestAware;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
-import org.splat.service.technical.ProjectSettingsService;
-
-
-
-public class StartAction extends Action implements ServletRequestAware {
-
-    private HttpServletRequest  request = null;
-
-       private ProjectSettingsService _projectSettingsService;
-       private ApplicationSettings _ApplicationSettings;
-       
-       /**
-        * Value of the menu property. 
-        * It can be: none, create, open, study, knowledge, sysadmin, help.
-        */
-       private String _menuProperty;
-       
-       /**
-        * Value of the title bar property. 
-        * It can be: study, knowledge.
-        */
-       private String _titleProperty;
-       
-       /**
-        * Property that indicates whether the current open study is editable or not.
-        * On the screen it looks like pen on the status icon, pop-up menu also can be called.
-        * It is necessary for correct building the title bar.
-        */
-       private String _editDisabledProperty = "false";
+import org.splat.wapp.Constants;
 
+/**
+ * Start application action. Initializes application settings.
+ */
+public class StartAction extends Action {
        /**
         * Serial version ID.
         */
-       private static final long   serialVersionUID = 5875058140682652964L;
-
-//  ==============================================================================================================================
-//  Action execution
-//  ==============================================================================================================================
+       private static final long serialVersionUID = 5875058140682652964L;
 
-       public String doInitialize () throws Exception {
-//  -----------------------------
-//      Session      connex  = Database.getSession();
-//      Transaction  transax = connex.beginTransaction();                
-         StringBuffer wappurl = request.getRequestURL();     // "http://{server}:{port}/{webapp}/", including the leading '/'
-
-      logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
-         try {
-               ProjectSettingsService project = getProjectSettings();
-        ApplicationSettings wapp    = getApplicationSettings().init(wappurl.toString(), this.getLocale());
-        String              root    = wapp.getApplicationRootPath();
-
-//      Database configuration
-               project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
-
-//      Application configuration
-           System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));        
-           wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
-
-//      Initialization of the user session
-               Map<String, Object> session = getSession();
-
-        session.put("user.rights", new ApplicationRights(null) );      // No user connected yet
-               session.put("study.filter",     wapp.getFilter("study"));
-               session.put("knowledge.filter", wapp.getFilter("knowledge"));
-
-//         transax.commit();
-           
-               setMenuProperty("none");
-               initializationScreenContext(_menuProperty);
-           
-           return SUCCESS;
-      }
-      catch (Exception error) {
-        logger.fatal("Reason:", error);
-        
-        setMenuProperty("study");
-        setTitleProperty("study");
-        setEditDisabledProperty("true");
-        initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
-        
-        return ERROR;
-      }
-       }
-
-//  ==============================================================================================================================
-//  Setter
-//  ==============================================================================================================================
-
-       public void setServletRequest (HttpServletRequest request) {
-//  ----------------------------------------------------------
-      this.request = request;
-       }
-    /**
-     * Get project settings.
-        * @return Project settings service
-        */
-       private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
-       }
+       // ==============================================================================================================================
+       // Action execution
+       // ==============================================================================================================================
 
        /**
-        * Set project settings service.
-        * @param projectSettingsService project settings service
+        * Initialize application.
+        * 
+        * @return SUCCESS if succeeded, ERROR - if exception is caught
         */
-       public void setProjectSettings(
-                       ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
-       }
+       public String doInitialize() {
+               StringBuffer wappurl = getServletRequest().getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
+               String res = SUCCESS;
 
-       /**
-        * Get the applicationSettings.
-        * @return the applicationSettings
-        */
-       public ApplicationSettings getApplicationSettings() {
-               return _ApplicationSettings;
-       }
+               LOG.info(new StringBuffer("Initializing ").append(wappurl)
+                               .append("...").toString());
+               try {
+                       ApplicationSettings wapp = getApplicationSettings();
+                       wapp.setLocale(this.getLocale());
+                       String root = ApplicationSettings.getApplicationRootPath();
+                       LOG.debug("Application root: " + root);
 
-       /**
-        * Set the applicationSettings.
-        * @param applicationSettings the applicationSettings to set
-        */
-       public void setApplicationSettings(ApplicationSettings applicationSettings) {
-               _ApplicationSettings = applicationSettings;
-       }
-       
-       /**
-        * Get the menuProperty.
-        * @return the menuProperty
-        */
-       public String getMenuProperty() {
-               return _menuProperty;
-       }
+                       // Configure menus for the current user
+                       wapp.configure();
 
-       /**
-        * Set the menuProperty.
-        * @param menuProperty the menuProperty to set
-        */
-       public void setMenuProperty(String menuProperty) {
-               this._menuProperty = menuProperty;
-       }
-       
-       /**
-        * Get the _titleProperty.
-        * @return the _titleProperty
-        */
-       public String getTitleProperty() {
-               return _titleProperty;
-       }
+                       // Initialization of the user session
+                       Map<String, Object> session = getSession();
 
-       /**
-        * Set the _titleProperty.
-        * @param _titleProperty the titleProperty to set
-        */
-       public void setTitleProperty(String titleProperty) {
-               _titleProperty = titleProperty;
-       }
+                       session.put("user.rights", new ApplicationRights(null)); // No user connected yet
+                       session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
+                       session.put("knowledge.filter", wapp
+                                       .getFilter(Constants.KNOWLEDGE_MENU));
 
-       /**
-        * Get the editDisabledProperty.
-        * @return the editDisabledProperty
-        */
-       public final String getEditDisabledProperty() {
-               return _editDisabledProperty;
-       }
+                       initializationScreenContext(Constants.NONE);
 
-       /**
-        * Set the editDisabledProperty.
-        * @param editDisabledProperty the editDisabledProperty to set
-        */
-       public final void setEditDisabledProperty(String editDisabledProperty) {
-               _editDisabledProperty = editDisabledProperty;
-       }
+               } catch (Exception error) {
+                       LOG.fatal("Reason:", error);
+
+                       initializationFullScreenContext(Constants.STUDY_MENU,
+                                       Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
+                                       Constants.STUDY_MENU);
 
-       
+                       res = ERROR;
+               }
+               return res;
+       }
 }
\ No newline at end of file