]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/StartAction.java
Salome HOME
Menus are improved
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / StartAction.java
1 package org.splat.simer;
2
3 import java.util.Map;
4
5 import javax.servlet.http.HttpServletRequest;
6
7 import org.apache.struts2.interceptor.ServletRequestAware;
8 import org.hibernate.HibernateException;
9 import org.hibernate.Session;
10 import org.hibernate.Transaction;
11 import org.splat.som.ApplicationRights;
12 import org.splat.dal.dao.som.Database;
13 import org.splat.service.technical.ProjectSettingsService;
14
15
16
17 public class StartAction extends Action implements ServletRequestAware {
18
19     private HttpServletRequest  request = null;
20
21         private ProjectSettingsService _projectSettingsService;
22         private ApplicationSettings _ApplicationSettings;
23         
24         /**
25          * Value of the menu property. 
26          * It can be: none, create, open, study, knowledge, sysadmin, help.
27          */
28         private String _menuProperty;
29
30         /**
31          * Serial version ID.
32          */
33         private static final long   serialVersionUID = 5875058140682652964L;
34
35 //  ==============================================================================================================================
36 //  Action execution
37 //  ==============================================================================================================================
38
39         public String doInitialize () throws Exception {
40 //  -----------------------------
41 //      Session      connex  = Database.getSession();
42 //      Transaction  transax = connex.beginTransaction();                 
43           StringBuffer wappurl = request.getRequestURL();     // "http://{server}:{port}/{webapp}/", including the leading '/'
44
45       logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
46           try {
47                 ProjectSettingsService project = getProjectSettings();
48         ApplicationSettings wapp    = getApplicationSettings().init(wappurl.toString(), this.getLocale());
49         String              root    = wapp.getApplicationRootPath();
50
51 //      Database configuration
52                 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
53
54 //      Application configuration
55             System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));        
56             wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
57
58 //      Initialization of the user session
59                 Map<String, Object> session = getSession();
60
61         session.put("user.rights", new ApplicationRights(null) );      // No user connected yet
62                 session.put("study.filter",     wapp.getFilter("study"));
63                 session.put("knowledge.filter", wapp.getFilter("knowledge"));
64
65 //          transax.commit();
66             
67                 setMenuProperty("none");
68                 initializationScreenContext(_menuProperty);
69             
70             return SUCCESS;
71       }
72       catch (Exception error) {
73         logger.fatal("Reason:", error);
74         
75         setMenuProperty("study");
76                 initializationScreenContext(_menuProperty);
77         
78         return ERROR;
79       }
80         }
81
82 //  ==============================================================================================================================
83 //  Setter
84 //  ==============================================================================================================================
85
86         public void setServletRequest (HttpServletRequest request) {
87 //  ----------------------------------------------------------
88       this.request = request;
89         }
90     /**
91      * Get project settings.
92          * @return Project settings service
93          */
94         private ProjectSettingsService getProjectSettings() {
95                 return _projectSettingsService;
96         }
97
98         /**
99          * Set project settings service.
100          * @param projectSettingsService project settings service
101          */
102         public void setProjectSettings(
103                         ProjectSettingsService projectSettingsService) {
104                 _projectSettingsService = projectSettingsService;
105         }
106
107         /**
108          * Get the applicationSettings.
109          * @return the applicationSettings
110          */
111         public ApplicationSettings getApplicationSettings() {
112                 return _ApplicationSettings;
113         }
114
115         /**
116          * Set the applicationSettings.
117          * @param applicationSettings the applicationSettings to set
118          */
119         public void setApplicationSettings(ApplicationSettings applicationSettings) {
120                 _ApplicationSettings = applicationSettings;
121         }
122         
123         /**
124          * Get the menuProperty.
125          * @return the menuProperty
126          */
127         public String getMenuProperty() {
128                 return _menuProperty;
129         }
130
131         /**
132          * Set the menuProperty.
133          * @param menuProperty the menuProperty to set
134          */
135         public void setMenuProperty(String menuProperty) {
136                 this._menuProperty = menuProperty;
137         }
138 }