Salome HOME
Actions menu properties are refactored, unnecessary code is removed.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / StartAction.java
1 package org.splat.simer;
2
3 import java.util.Map;
4
5 import org.splat.service.technical.ProjectSettingsService;
6 import org.splat.som.ApplicationRights;
7 import org.splat.wapp.Constants;
8
9 /**
10  * Start application action.
11  */
12 public class StartAction extends Action {
13         /**
14          * Serial version ID.
15          */
16         private static final long serialVersionUID = 5875058140682652964L;
17
18         /**
19          * Injected project settings service.
20          */
21         private ProjectSettingsService _projectSettings;
22
23         // ==============================================================================================================================
24         // Action execution
25         // ==============================================================================================================================
26
27         /**
28          * Initialize application.
29          * 
30          * @return SUCCESS if succeeded, ERROR - if exception is caught
31          */
32         public String doInitialize() {
33                 StringBuffer wappurl = getServletRequest().getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
34                 String res = SUCCESS;
35
36                 LOG.info(new StringBuffer("Initializing ").append(wappurl)
37                                 .append("...").toString());
38                 try {
39                         ProjectSettingsService project = getProjectSettings();
40                         ApplicationSettings wapp = getApplicationSettings();
41                         wapp.setLocale(this.getLocale());
42                         String root = ApplicationSettings.getApplicationRootPath();
43                         LOG.debug("Application root: " + root);
44
45                         // Database configuration
46                         project.configure(root
47                                         + ApplicationSettings
48                                                         .getApplicationProperty("wapp.configuration"));
49
50                         // Configure menus for the current user
51                         wapp.configure();
52
53                         // Initialization of the user session
54                         Map<String, Object> session = getSession();
55
56                         session.put("user.rights", new ApplicationRights(null)); // No user connected yet
57                         session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
58                         session.put("knowledge.filter", wapp
59                                         .getFilter(Constants.KNOWLEDGE_MENU));
60
61                         initializationScreenContext(Constants.NONE);
62
63                 } catch (Exception error) {
64                         LOG.fatal("Reason:", error);
65
66                         initializationFullScreenContext(Constants.STUDY_MENU,
67                                         Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
68                                         Constants.STUDY_MENU);
69
70                         res = ERROR;
71                 }
72                 return res;
73         }
74
75         // ==============================================================================================================================
76         // Setter
77         // ==============================================================================================================================
78
79         /**
80          * Get project settings.
81          * 
82          * @return Project settings service
83          */
84         private ProjectSettingsService getProjectSettings() {
85                 return _projectSettings;
86         }
87
88         /**
89          * Set project settings service.
90          * 
91          * @param projectSettingsService
92          *            project settings service
93          */
94         public void setProjectSettings(
95                         final ProjectSettingsService projectSettingsService) {
96                 _projectSettings = projectSettingsService;
97         }
98 }