Salome HOME
<jsp:param ... > parameters are removed from the title bar
[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          * Value of the title bar property. 
32          * It can be: study, knowledge.
33          */
34         private String _titleProperty;
35         
36         /**
37          * Property that indicates whether the current open study is editable or not.
38          * On the screen it looks like pen on the status icon, pop-up menu also can be called.
39          * It is necessary for correct building the title bar.
40          */
41         private String _editDisabledProperty = "false";
42
43         /**
44          * Serial version ID.
45          */
46         private static final long   serialVersionUID = 5875058140682652964L;
47
48 //  ==============================================================================================================================
49 //  Action execution
50 //  ==============================================================================================================================
51
52         public String doInitialize () throws Exception {
53 //  -----------------------------
54 //      Session      connex  = Database.getSession();
55 //      Transaction  transax = connex.beginTransaction();                 
56           StringBuffer wappurl = request.getRequestURL();     // "http://{server}:{port}/{webapp}/", including the leading '/'
57
58       logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
59           try {
60                 ProjectSettingsService project = getProjectSettings();
61         ApplicationSettings wapp    = getApplicationSettings().init(wappurl.toString(), this.getLocale());
62         String              root    = wapp.getApplicationRootPath();
63
64 //      Database configuration
65                 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
66
67 //      Application configuration
68             System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));        
69             wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
70
71 //      Initialization of the user session
72                 Map<String, Object> session = getSession();
73
74         session.put("user.rights", new ApplicationRights(null) );      // No user connected yet
75                 session.put("study.filter",     wapp.getFilter("study"));
76                 session.put("knowledge.filter", wapp.getFilter("knowledge"));
77
78 //          transax.commit();
79             
80                 setMenuProperty("none");
81                 initializationScreenContext(_menuProperty);
82             
83             return SUCCESS;
84       }
85       catch (Exception error) {
86         logger.fatal("Reason:", error);
87         
88         setMenuProperty("study");
89         setTitleProperty("study");
90         setEditDisabledProperty("true");
91         initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
92         
93         return ERROR;
94       }
95         }
96
97 //  ==============================================================================================================================
98 //  Setter
99 //  ==============================================================================================================================
100
101         public void setServletRequest (HttpServletRequest request) {
102 //  ----------------------------------------------------------
103       this.request = request;
104         }
105     /**
106      * Get project settings.
107          * @return Project settings service
108          */
109         private ProjectSettingsService getProjectSettings() {
110                 return _projectSettingsService;
111         }
112
113         /**
114          * Set project settings service.
115          * @param projectSettingsService project settings service
116          */
117         public void setProjectSettings(
118                         ProjectSettingsService projectSettingsService) {
119                 _projectSettingsService = projectSettingsService;
120         }
121
122         /**
123          * Get the applicationSettings.
124          * @return the applicationSettings
125          */
126         public ApplicationSettings getApplicationSettings() {
127                 return _ApplicationSettings;
128         }
129
130         /**
131          * Set the applicationSettings.
132          * @param applicationSettings the applicationSettings to set
133          */
134         public void setApplicationSettings(ApplicationSettings applicationSettings) {
135                 _ApplicationSettings = applicationSettings;
136         }
137         
138         /**
139          * Get the menuProperty.
140          * @return the menuProperty
141          */
142         public String getMenuProperty() {
143                 return _menuProperty;
144         }
145
146         /**
147          * Set the menuProperty.
148          * @param menuProperty the menuProperty to set
149          */
150         public void setMenuProperty(String menuProperty) {
151                 this._menuProperty = menuProperty;
152         }
153         
154         /**
155          * Get the _titleProperty.
156          * @return the _titleProperty
157          */
158         public String getTitleProperty() {
159                 return _titleProperty;
160         }
161
162         /**
163          * Set the _titleProperty.
164          * @param _titleProperty the titleProperty to set
165          */
166         public void setTitleProperty(String titleProperty) {
167                 _titleProperty = titleProperty;
168         }
169
170         /**
171          * Get the editDisabledProperty.
172          * @return the editDisabledProperty
173          */
174         public final String getEditDisabledProperty() {
175                 return _editDisabledProperty;
176         }
177
178         /**
179          * Set the editDisabledProperty.
180          * @param editDisabledProperty the editDisabledProperty to set
181          */
182         public final void setEditDisabledProperty(String editDisabledProperty) {
183                 _editDisabledProperty = editDisabledProperty;
184         }
185
186         
187 }