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();
78 wapp.setLocale(this.getLocale());
79 String root = ApplicationSettings.getApplicationRootPath();
80 LOG.debug("Application root: " + root);
82 // Database configuration
83 project.configure(root
84 + ApplicationSettings.getApplicationProperty("wapp.configuration"));
86 // Configure menus for the current user
89 // Initialization of the user session
90 Map<String, Object> session = getSession();
92 session.put("user.rights", new ApplicationRights(null)); // No user connected yet
93 session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
94 session.put("knowledge.filter", wapp
95 .getFilter(Constants.KNOWLEDGE_MENU));
97 setMenuProperty(Constants.NONE);
98 initializationScreenContext(_menuProperty);
100 } catch (Exception error) {
101 LOG.fatal("Reason:", error);
103 setMenuProperty(Constants.STUDY_MENU);
104 setTitleProperty(Constants.STUDY_MENU);
105 setEditDisabledProperty("true");
106 setToolProperty(Constants.NONE);
107 setLeftMenuProperty(Constants.STUDY_MENU);
108 initializationFullScreenContext(_menuProperty, _titleProperty,
109 _editDisabledProperty, _toolProperty, _leftMenuProperty);
116 // ==============================================================================================================================
118 // ==============================================================================================================================
122 * @see org.splat.simer.Action#setServletRequest(javax.servlet.http.HttpServletRequest)
125 public void setServletRequest(final HttpServletRequest request) {
126 this._request = request;
130 * Get project settings.
132 * @return Project settings service
134 private ProjectSettingsService getProjectSettings() {
135 return _projectSettings;
139 * Set project settings service.
141 * @param projectSettingsService
142 * project settings service
144 public void setProjectSettings(
145 final ProjectSettingsService projectSettingsService) {
146 _projectSettings = projectSettingsService;
150 * Get the applicationSettings.
152 * @return the applicationSettings
155 public ApplicationSettings getApplicationSettings() {
156 return _applicationSettings;
160 * Set the applicationSettings.
162 * @param applicationSettings
163 * the applicationSettings to set
166 public void setApplicationSettings(
167 final ApplicationSettings applicationSettings) {
168 _applicationSettings = applicationSettings;
172 * Get the menuProperty.
174 * @return the menuProperty
176 public String getMenuProperty() {
177 return _menuProperty;
181 * Set the menuProperty.
183 * @param menuProperty
184 * the menuProperty to set
186 public void setMenuProperty(final String menuProperty) {
187 this._menuProperty = menuProperty;
191 * Get the _titleProperty.
193 * @return the _titleProperty
195 public String getTitleProperty() {
196 return _titleProperty;
200 * Set the titleProperty.
202 * @param titleProperty
203 * the titleProperty to set
205 public void setTitleProperty(final String titleProperty) {
206 _titleProperty = titleProperty;
210 * Get the editDisabledProperty.
212 * @return the editDisabledProperty
214 public final String getEditDisabledProperty() {
215 return _editDisabledProperty;
219 * Set the editDisabledProperty.
221 * @param editDisabledProperty
222 * the editDisabledProperty to set
224 public final void setEditDisabledProperty(final String editDisabledProperty) {
225 _editDisabledProperty = editDisabledProperty;
229 * Get the toolProperty.
231 * @return the toolProperty
233 public String getToolProperty() {
234 return _toolProperty;
238 * Set the toolProperty.
240 * @param toolProperty
241 * the toolProperty to set
243 public void setToolProperty(final String toolProperty) {
244 _toolProperty = toolProperty;
248 * Get the leftMenuProperty.
250 * @return the leftMenuProperty
252 public String getLeftMenuProperty() {
253 return _leftMenuProperty;
257 * Set the leftMenuProperty.
259 * @param leftMenuProperty
260 * the leftMenuProperty to set
262 public void setLeftMenuProperty(final String leftMenuProperty) {
263 _leftMenuProperty = leftMenuProperty;