1 package org.splat.simer;
5 import javax.servlet.http.HttpServletRequest;
7 import org.apache.struts2.interceptor.ServletRequestAware;
8 import org.splat.service.technical.ProjectSettingsService;
9 import org.splat.som.ApplicationRights;
10 import org.splat.wapp.Constants;
13 * Start application action.
15 public class StartAction extends Action implements ServletRequestAware {
19 private static final long serialVersionUID = 5875058140682652964L;
24 private transient HttpServletRequest _request = null;
27 * Injected project settings service.
29 private ProjectSettingsService _projectSettings;
31 * Injected application settings service.
33 private ApplicationSettings _applicationSettings;
36 * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
38 private String _menuProperty;
41 * Value of the title bar property. It can be: study, knowledge.
43 private String _titleProperty;
46 * 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
47 * menu also can be called. It is necessary for correct building the title bar.
49 private String _editDisabledProperty = "false";
52 * Value of the tool bar property. It can be: none, standard, study, back.
54 private String _toolProperty;
57 * Value of the left menu property. It can be: open, study, knowledge, scenario.
59 private String _leftMenuProperty;
61 // ==============================================================================================================================
63 // ==============================================================================================================================
66 * Initialize application.
67 * @return SUCCESS if succeeded, ERROR - if exception is caught
69 public String doInitialize() {
70 StringBuffer wappurl = _request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
73 LOG.info(new StringBuffer("Initializing ").append(wappurl)
74 .append("...").toString());
76 ProjectSettingsService project = getProjectSettings();
77 ApplicationSettings wapp = getApplicationSettings().init(
78 wappurl.toString(), this.getLocale());
79 String root = wapp.getApplicationRootPath();
80 LOG.debug("Application root: " + root);
82 // Database configuration
83 project.configure(root
84 + wapp.getApplicationProperty("wapp.configuration"));
86 // Application configuration
87 System.setProperty("java.security.auth.login.config", root
88 + wapp.getApplicationProperty("wapp.login"));
90 + wapp.getApplicationProperty("wapp.customization"));
92 // Initialization of the user session
93 Map<String, Object> session = getSession();
95 session.put("user.rights", new ApplicationRights(null)); // No user connected yet
96 session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
97 session.put("knowledge.filter", wapp
98 .getFilter(Constants.KNOWLEDGE_MENU));
100 setMenuProperty(Constants.NONE);
101 initializationScreenContext(_menuProperty);
103 } catch (Exception error) {
104 LOG.fatal("Reason:", error);
106 setMenuProperty(Constants.STUDY_MENU);
107 setTitleProperty(Constants.STUDY_MENU);
108 setEditDisabledProperty("true");
109 setToolProperty(Constants.NONE);
110 setLeftMenuProperty(Constants.STUDY_MENU);
111 initializationFullScreenContext(_menuProperty, _titleProperty,
112 _editDisabledProperty, _toolProperty, _leftMenuProperty);
119 // ==============================================================================================================================
121 // ==============================================================================================================================
125 * @see org.splat.simer.Action#setServletRequest(javax.servlet.http.HttpServletRequest)
128 public void setServletRequest(final HttpServletRequest request) {
129 this._request = request;
133 * Get project settings.
135 * @return Project settings service
137 private ProjectSettingsService getProjectSettings() {
138 return _projectSettings;
142 * Set project settings service.
144 * @param projectSettingsService
145 * project settings service
147 public void setProjectSettings(
148 final ProjectSettingsService projectSettingsService) {
149 _projectSettings = projectSettingsService;
153 * Get the applicationSettings.
155 * @return the applicationSettings
158 public ApplicationSettings getApplicationSettings() {
159 return _applicationSettings;
163 * Set the applicationSettings.
165 * @param applicationSettings
166 * the applicationSettings to set
169 public void setApplicationSettings(
170 final ApplicationSettings applicationSettings) {
171 _applicationSettings = applicationSettings;
175 * Get the menuProperty.
177 * @return the menuProperty
179 public String getMenuProperty() {
180 return _menuProperty;
184 * Set the menuProperty.
186 * @param menuProperty
187 * the menuProperty to set
189 public void setMenuProperty(final String menuProperty) {
190 this._menuProperty = menuProperty;
194 * Get the _titleProperty.
196 * @return the _titleProperty
198 public String getTitleProperty() {
199 return _titleProperty;
203 * Set the titleProperty.
205 * @param titleProperty
206 * the titleProperty to set
208 public void setTitleProperty(final String titleProperty) {
209 _titleProperty = titleProperty;
213 * Get the editDisabledProperty.
215 * @return the editDisabledProperty
217 public final String getEditDisabledProperty() {
218 return _editDisabledProperty;
222 * Set the editDisabledProperty.
224 * @param editDisabledProperty
225 * the editDisabledProperty to set
227 public final void setEditDisabledProperty(final String editDisabledProperty) {
228 _editDisabledProperty = editDisabledProperty;
232 * Get the toolProperty.
234 * @return the toolProperty
236 public String getToolProperty() {
237 return _toolProperty;
241 * Set the toolProperty.
243 * @param toolProperty
244 * the toolProperty to set
246 public void setToolProperty(final String toolProperty) {
247 _toolProperty = toolProperty;
251 * Get the leftMenuProperty.
253 * @return the leftMenuProperty
255 public String getLeftMenuProperty() {
256 return _leftMenuProperty;
260 * Set the leftMenuProperty.
262 * @param leftMenuProperty
263 * the leftMenuProperty to set
265 public void setLeftMenuProperty(final String leftMenuProperty) {
266 _leftMenuProperty = leftMenuProperty;