1 package org.splat.simer;
5 import javax.servlet.ServletContext;
6 import javax.servlet.http.HttpServletRequest;
8 import org.apache.struts2.interceptor.ServletRequestAware;
9 import org.apache.struts2.util.ServletContextAware;
10 import org.hibernate.HibernateException;
11 import org.hibernate.Session;
12 import org.hibernate.Transaction;
13 import org.splat.som.ApplicationRights;
14 import org.splat.dal.dao.som.Database;
15 import org.splat.service.technical.ProjectSettingsService;
19 public class StartAction extends Action implements ServletRequestAware {
21 private HttpServletRequest request = null;
23 private ProjectSettingsService _projectSettingsService;
24 private ApplicationSettings _ApplicationSettings;
27 * Value of the menu property.
28 * It can be: none, create, open, study, knowledge, sysadmin, help.
30 private String _menuProperty;
33 * Value of the title bar property.
34 * It can be: study, knowledge.
36 private String _titleProperty;
39 * Property that indicates whether the current open study is editable or not.
40 * On the screen it looks like pen on the status icon, pop-up menu also can be called.
41 * It is necessary for correct building the title bar.
43 private String _editDisabledProperty = "false";
46 * Value of the tool bar property.
47 * It can be: none, standard, study, back.
49 private String _toolProperty;
52 * Value of the left menu property.
53 * It can be: open, study, knowledge, scenario.
55 private String _leftMenuProperty;
60 private static final long serialVersionUID = 5875058140682652964L;
62 // ==============================================================================================================================
64 // ==============================================================================================================================
66 public String doInitialize () throws Exception {
67 // -----------------------------
68 // Session connex = Database.getSession();
69 // Transaction transax = connex.beginTransaction();
70 StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
72 LOG.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
74 ProjectSettingsService project = getProjectSettings();
75 ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
76 String root = wapp.getApplicationRootPath();
77 LOG.debug("Application root: " + root);
79 // Database configuration
80 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
82 // Application configuration
83 System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
84 wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
86 // Initialization of the user session
87 Map<String, Object> session = getSession();
89 session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
90 session.put("study.filter", wapp.getFilter("study"));
91 session.put("knowledge.filter", wapp.getFilter("knowledge"));
95 setMenuProperty("none");
96 initializationScreenContext(_menuProperty);
100 catch (Exception error) {
101 LOG.fatal("Reason:", error);
103 setMenuProperty("study");
104 setTitleProperty("study");
105 setEditDisabledProperty("true");
106 setToolProperty("none");
107 setLeftMenuProperty("study");
108 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
114 // ==============================================================================================================================
116 // ==============================================================================================================================
118 public void setServletRequest (HttpServletRequest request) {
119 // ----------------------------------------------------------
120 this.request = request;
123 * Get project settings.
124 * @return Project settings service
126 private ProjectSettingsService getProjectSettings() {
127 return _projectSettingsService;
131 * Set project settings service.
132 * @param projectSettingsService project settings service
134 public void setProjectSettings(
135 ProjectSettingsService projectSettingsService) {
136 _projectSettingsService = projectSettingsService;
140 * Get the applicationSettings.
141 * @return the applicationSettings
143 public ApplicationSettings getApplicationSettings() {
144 return _ApplicationSettings;
148 * Set the applicationSettings.
149 * @param applicationSettings the applicationSettings to set
151 public void setApplicationSettings(ApplicationSettings applicationSettings) {
152 _ApplicationSettings = applicationSettings;
156 * Get the menuProperty.
157 * @return the menuProperty
159 public String getMenuProperty() {
160 return _menuProperty;
164 * Set the menuProperty.
165 * @param menuProperty the menuProperty to set
167 public void setMenuProperty(String menuProperty) {
168 this._menuProperty = menuProperty;
172 * Get the _titleProperty.
173 * @return the _titleProperty
175 public String getTitleProperty() {
176 return _titleProperty;
180 * Set the _titleProperty.
181 * @param _titleProperty the titleProperty to set
183 public void setTitleProperty(String titleProperty) {
184 _titleProperty = titleProperty;
188 * Get the editDisabledProperty.
189 * @return the editDisabledProperty
191 public final String getEditDisabledProperty() {
192 return _editDisabledProperty;
196 * Set the editDisabledProperty.
197 * @param editDisabledProperty the editDisabledProperty to set
199 public final void setEditDisabledProperty(String editDisabledProperty) {
200 _editDisabledProperty = editDisabledProperty;
204 * Get the toolProperty.
205 * @return the toolProperty
207 public String getToolProperty() {
208 return _toolProperty;
212 * Set the toolProperty.
213 * @param toolProperty the toolProperty to set
215 public void setToolProperty(final String toolProperty) {
216 _toolProperty = toolProperty;
220 * Get the leftMenuProperty.
221 * @return the leftMenuProperty
223 public String getLeftMenuProperty() {
224 return _leftMenuProperty;
228 * Set the leftMenuProperty.
229 * @param leftMenuProperty the leftMenuProperty to set
231 public void setLeftMenuProperty(final String leftMenuProperty) {
232 _leftMenuProperty = leftMenuProperty;