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";
48 private static final long serialVersionUID = 5875058140682652964L;
50 // ==============================================================================================================================
52 // ==============================================================================================================================
54 public String doInitialize () throws Exception {
55 // -----------------------------
56 // Session connex = Database.getSession();
57 // Transaction transax = connex.beginTransaction();
58 StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
60 logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
62 ProjectSettingsService project = getProjectSettings();
63 ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
64 String root = wapp.getApplicationRootPath();
65 logger.debug("Application root: " + root);
67 // Database configuration
68 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
70 // Application configuration
71 System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
72 wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
74 // Initialization of the user session
75 Map<String, Object> session = getSession();
77 session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
78 session.put("study.filter", wapp.getFilter("study"));
79 session.put("knowledge.filter", wapp.getFilter("knowledge"));
83 setMenuProperty("none");
84 initializationScreenContext(_menuProperty);
88 catch (Exception error) {
89 logger.fatal("Reason:", error);
91 setMenuProperty("study");
92 setTitleProperty("study");
93 setEditDisabledProperty("true");
94 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
100 // ==============================================================================================================================
102 // ==============================================================================================================================
104 public void setServletRequest (HttpServletRequest request) {
105 // ----------------------------------------------------------
106 this.request = request;
109 * Get project settings.
110 * @return Project settings service
112 private ProjectSettingsService getProjectSettings() {
113 return _projectSettingsService;
117 * Set project settings service.
118 * @param projectSettingsService project settings service
120 public void setProjectSettings(
121 ProjectSettingsService projectSettingsService) {
122 _projectSettingsService = projectSettingsService;
126 * Get the applicationSettings.
127 * @return the applicationSettings
129 public ApplicationSettings getApplicationSettings() {
130 return _ApplicationSettings;
134 * Set the applicationSettings.
135 * @param applicationSettings the applicationSettings to set
137 public void setApplicationSettings(ApplicationSettings applicationSettings) {
138 _ApplicationSettings = applicationSettings;
142 * Get the menuProperty.
143 * @return the menuProperty
145 public String getMenuProperty() {
146 return _menuProperty;
150 * Set the menuProperty.
151 * @param menuProperty the menuProperty to set
153 public void setMenuProperty(String menuProperty) {
154 this._menuProperty = menuProperty;
158 * Get the _titleProperty.
159 * @return the _titleProperty
161 public String getTitleProperty() {
162 return _titleProperty;
166 * Set the _titleProperty.
167 * @param _titleProperty the titleProperty to set
169 public void setTitleProperty(String titleProperty) {
170 _titleProperty = titleProperty;
174 * Get the editDisabledProperty.
175 * @return the editDisabledProperty
177 public final String getEditDisabledProperty() {
178 return _editDisabledProperty;
182 * Set the editDisabledProperty.
183 * @param editDisabledProperty the editDisabledProperty to set
185 public final void setEditDisabledProperty(String editDisabledProperty) {
186 _editDisabledProperty = editDisabledProperty;