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;
54 private static final long serialVersionUID = 5875058140682652964L;
56 // ==============================================================================================================================
58 // ==============================================================================================================================
60 public String doInitialize () throws Exception {
61 // -----------------------------
62 // Session connex = Database.getSession();
63 // Transaction transax = connex.beginTransaction();
64 StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
66 logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
68 ProjectSettingsService project = getProjectSettings();
69 ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
70 String root = wapp.getApplicationRootPath();
71 logger.debug("Application root: " + root);
73 // Database configuration
74 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
76 // Application configuration
77 System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
78 wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
80 // Initialization of the user session
81 Map<String, Object> session = getSession();
83 session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
84 session.put("study.filter", wapp.getFilter("study"));
85 session.put("knowledge.filter", wapp.getFilter("knowledge"));
89 setMenuProperty("none");
90 initializationScreenContext(_menuProperty);
94 catch (Exception error) {
95 logger.fatal("Reason:", error);
97 setMenuProperty("study");
98 setTitleProperty("study");
99 setEditDisabledProperty("true");
100 setToolProperty("none");
101 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
107 // ==============================================================================================================================
109 // ==============================================================================================================================
111 public void setServletRequest (HttpServletRequest request) {
112 // ----------------------------------------------------------
113 this.request = request;
116 * Get project settings.
117 * @return Project settings service
119 private ProjectSettingsService getProjectSettings() {
120 return _projectSettingsService;
124 * Set project settings service.
125 * @param projectSettingsService project settings service
127 public void setProjectSettings(
128 ProjectSettingsService projectSettingsService) {
129 _projectSettingsService = projectSettingsService;
133 * Get the applicationSettings.
134 * @return the applicationSettings
136 public ApplicationSettings getApplicationSettings() {
137 return _ApplicationSettings;
141 * Set the applicationSettings.
142 * @param applicationSettings the applicationSettings to set
144 public void setApplicationSettings(ApplicationSettings applicationSettings) {
145 _ApplicationSettings = applicationSettings;
149 * Get the menuProperty.
150 * @return the menuProperty
152 public String getMenuProperty() {
153 return _menuProperty;
157 * Set the menuProperty.
158 * @param menuProperty the menuProperty to set
160 public void setMenuProperty(String menuProperty) {
161 this._menuProperty = menuProperty;
165 * Get the _titleProperty.
166 * @return the _titleProperty
168 public String getTitleProperty() {
169 return _titleProperty;
173 * Set the _titleProperty.
174 * @param _titleProperty the titleProperty to set
176 public void setTitleProperty(String titleProperty) {
177 _titleProperty = titleProperty;
181 * Get the editDisabledProperty.
182 * @return the editDisabledProperty
184 public final String getEditDisabledProperty() {
185 return _editDisabledProperty;
189 * Set the editDisabledProperty.
190 * @param editDisabledProperty the editDisabledProperty to set
192 public final void setEditDisabledProperty(String editDisabledProperty) {
193 _editDisabledProperty = editDisabledProperty;
197 * Get the toolProperty.
198 * @return the toolProperty
200 public String getToolProperty() {
201 return _toolProperty;
205 * Set the toolProperty.
206 * @param toolProperty the toolProperty to set
208 public void setToolProperty(final String toolProperty) {
209 _toolProperty = toolProperty;