1 package org.splat.simer;
5 import javax.servlet.http.HttpServletRequest;
7 import org.apache.struts2.interceptor.ServletRequestAware;
8 import org.hibernate.HibernateException;
9 import org.hibernate.Session;
10 import org.hibernate.Transaction;
11 import org.splat.som.ApplicationRights;
12 import org.splat.dal.dao.som.Database;
13 import org.splat.service.technical.ProjectSettingsService;
17 public class StartAction extends Action implements ServletRequestAware {
19 private HttpServletRequest request = null;
21 private ProjectSettingsService _projectSettingsService;
22 private ApplicationSettings _ApplicationSettings;
25 * Value of the menu property.
26 * It can be: none, create, open, study, knowledge, sysadmin, help.
28 private String _menuProperty;
31 * Value of the title bar property.
32 * It can be: study, knowledge.
34 private String _titleProperty;
37 * Property that indicates whether the current open study is editable or not.
38 * On the screen it looks like pen on the status icon, pop-up menu also can be called.
39 * It is necessary for correct building the title bar.
41 private String _editDisabledProperty = "false";
46 private static final long serialVersionUID = 5875058140682652964L;
48 // ==============================================================================================================================
50 // ==============================================================================================================================
52 public String doInitialize () throws Exception {
53 // -----------------------------
54 // Session connex = Database.getSession();
55 // Transaction transax = connex.beginTransaction();
56 StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
58 logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
60 ProjectSettingsService project = getProjectSettings();
61 ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
62 String root = wapp.getApplicationRootPath();
64 // Database configuration
65 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
67 // Application configuration
68 System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
69 wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
71 // Initialization of the user session
72 Map<String, Object> session = getSession();
74 session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
75 session.put("study.filter", wapp.getFilter("study"));
76 session.put("knowledge.filter", wapp.getFilter("knowledge"));
80 setMenuProperty("none");
81 initializationScreenContext(_menuProperty);
85 catch (Exception error) {
86 logger.fatal("Reason:", error);
88 setMenuProperty("study");
89 setTitleProperty("study");
90 setEditDisabledProperty("true");
91 initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
97 // ==============================================================================================================================
99 // ==============================================================================================================================
101 public void setServletRequest (HttpServletRequest request) {
102 // ----------------------------------------------------------
103 this.request = request;
106 * Get project settings.
107 * @return Project settings service
109 private ProjectSettingsService getProjectSettings() {
110 return _projectSettingsService;
114 * Set project settings service.
115 * @param projectSettingsService project settings service
117 public void setProjectSettings(
118 ProjectSettingsService projectSettingsService) {
119 _projectSettingsService = projectSettingsService;
123 * Get the applicationSettings.
124 * @return the applicationSettings
126 public ApplicationSettings getApplicationSettings() {
127 return _ApplicationSettings;
131 * Set the applicationSettings.
132 * @param applicationSettings the applicationSettings to set
134 public void setApplicationSettings(ApplicationSettings applicationSettings) {
135 _ApplicationSettings = applicationSettings;
139 * Get the menuProperty.
140 * @return the menuProperty
142 public String getMenuProperty() {
143 return _menuProperty;
147 * Set the menuProperty.
148 * @param menuProperty the menuProperty to set
150 public void setMenuProperty(String menuProperty) {
151 this._menuProperty = menuProperty;
155 * Get the _titleProperty.
156 * @return the _titleProperty
158 public String getTitleProperty() {
159 return _titleProperty;
163 * Set the _titleProperty.
164 * @param _titleProperty the titleProperty to set
166 public void setTitleProperty(String titleProperty) {
167 _titleProperty = titleProperty;
171 * Get the editDisabledProperty.
172 * @return the editDisabledProperty
174 public final String getEditDisabledProperty() {
175 return _editDisabledProperty;
179 * Set the editDisabledProperty.
180 * @param editDisabledProperty the editDisabledProperty to set
182 public final void setEditDisabledProperty(String editDisabledProperty) {
183 _editDisabledProperty = editDisabledProperty;