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;
33 private static final long serialVersionUID = 5875058140682652964L;
35 // ==============================================================================================================================
37 // ==============================================================================================================================
39 public String doInitialize () throws Exception {
40 // -----------------------------
41 // Session connex = Database.getSession();
42 // Transaction transax = connex.beginTransaction();
43 StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
45 logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
47 ProjectSettingsService project = getProjectSettings();
48 ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
49 String root = wapp.getApplicationRootPath();
51 // Database configuration
52 project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
54 // Application configuration
55 System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
56 wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
58 // Initialization of the user session
59 Map<String, Object> session = getSession();
61 session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
62 session.put("study.filter", wapp.getFilter("study"));
63 session.put("knowledge.filter", wapp.getFilter("knowledge"));
67 setMenuProperty("none");
68 initializationScreenContext(_menuProperty);
72 catch (Exception error) {
73 logger.fatal("Reason:", error);
75 setMenuProperty("study");
76 initializationScreenContext(_menuProperty);
82 // ==============================================================================================================================
84 // ==============================================================================================================================
86 public void setServletRequest (HttpServletRequest request) {
87 // ----------------------------------------------------------
88 this.request = request;
91 * Get project settings.
92 * @return Project settings service
94 private ProjectSettingsService getProjectSettings() {
95 return _projectSettingsService;
99 * Set project settings service.
100 * @param projectSettingsService project settings service
102 public void setProjectSettings(
103 ProjectSettingsService projectSettingsService) {
104 _projectSettingsService = projectSettingsService;
108 * Get the applicationSettings.
109 * @return the applicationSettings
111 public ApplicationSettings getApplicationSettings() {
112 return _ApplicationSettings;
116 * Set the applicationSettings.
117 * @param applicationSettings the applicationSettings to set
119 public void setApplicationSettings(ApplicationSettings applicationSettings) {
120 _ApplicationSettings = applicationSettings;
124 * Get the menuProperty.
125 * @return the menuProperty
127 public String getMenuProperty() {
128 return _menuProperty;
132 * Set the menuProperty.
133 * @param menuProperty the menuProperty to set
135 public void setMenuProperty(String menuProperty) {
136 this._menuProperty = menuProperty;