import java.util.Map;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
-import org.apache.struts2.util.ServletContextAware;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.ApplicationRights;
+import org.splat.wapp.Constants;
-
-
+/**
+ * Start application action.
+ */
public class StartAction extends Action implements ServletRequestAware {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 5875058140682652964L;
- private HttpServletRequest request = null;
+ /**
+ * HTTP request.
+ */
+ private transient HttpServletRequest _request = null;
- private ProjectSettingsService _projectSettingsService;
- private ApplicationSettings _ApplicationSettings;
-
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * Injected project settings service.
+ */
+ private ProjectSettingsService _projectSettings;
+ /**
+ * Injected application settings service.
+ */
+ private ApplicationSettings _applicationSettings;
+
+ /**
+ * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
-
+
/**
- * Value of the title bar property.
- * It can be: study, knowledge.
+ * Value of the title bar property. It can be: study, knowledge.
*/
private String _titleProperty;
-
+
/**
- * 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 menu also can be called.
- * It is necessary for correct building the title bar.
+ * 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
+ * menu also can be called. It is necessary for correct building the title bar.
*/
private String _editDisabledProperty = "false";
-
+
/**
- * Value of the tool bar property.
- * It can be: none, standard, study, back.
+ * Value of the tool bar property. It can be: none, standard, study, back.
*/
private String _toolProperty;
-
+
/**
- * Value of the left menu property.
- * It can be: open, study, knowledge, scenario.
+ * Value of the left menu property. It can be: open, study, knowledge, scenario.
*/
private String _leftMenuProperty;
+ // ==============================================================================================================================
+ // Action execution
+ // ==============================================================================================================================
+
/**
- * Serial version ID.
+ * Initialize application.
+ * @return SUCCESS if succeeded, ERROR - if exception is caught
+ */
+ public String doInitialize() {
+ StringBuffer wappurl = _request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
+ String res = SUCCESS;
+
+ LOG.info(new StringBuffer("Initializing ").append(wappurl)
+ .append("...").toString());
+ try {
+ ProjectSettingsService project = getProjectSettings();
+ ApplicationSettings wapp = getApplicationSettings().init(
+ wappurl.toString(), this.getLocale());
+ String root = wapp.getApplicationRootPath();
+ LOG.debug("Application root: " + root);
+
+ // Database configuration
+ project.configure(root
+ + wapp.getApplicationProperty("wapp.configuration"));
+
+ // Application configuration
+ System.setProperty("java.security.auth.login.config", root
+ + wapp.getApplicationProperty("wapp.login"));
+ wapp.configure(root
+ + wapp.getApplicationProperty("wapp.customization"));
+
+ // Initialization of the user session
+ Map<String, Object> session = getSession();
+
+ session.put("user.rights", new ApplicationRights(null)); // No user connected yet
+ session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
+ session.put("knowledge.filter", wapp
+ .getFilter(Constants.KNOWLEDGE_MENU));
+
+ setMenuProperty(Constants.NONE);
+ initializationScreenContext(_menuProperty);
+
+ } catch (Exception error) {
+ LOG.fatal("Reason:", error);
+
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ setEditDisabledProperty("true");
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.STUDY_MENU);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+ res = ERROR;
+ }
+ return res;
+ }
+
+ // ==============================================================================================================================
+ // Setter
+ // ==============================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.simer.Action#setServletRequest(javax.servlet.http.HttpServletRequest)
*/
- private static final long serialVersionUID = 5875058140682652964L;
-
-// ==============================================================================================================================
-// Action execution
-// ==============================================================================================================================
-
- public String doInitialize () throws Exception {
-// -----------------------------
-// Session connex = Database.getSession();
-// Transaction transax = connex.beginTransaction();
- StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
-
- LOG.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
- try {
- ProjectSettingsService project = getProjectSettings();
- ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
- String root = wapp.getApplicationRootPath();
- LOG.debug("Application root: " + root);
-
-// Database configuration
- project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
-
-// Application configuration
- System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
- wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
-
-// Initialization of the user session
- Map<String, Object> session = getSession();
-
- session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
- session.put("study.filter", wapp.getFilter("study"));
- session.put("knowledge.filter", wapp.getFilter("knowledge"));
-
-// transax.commit();
-
- setMenuProperty("none");
- initializationScreenContext(_menuProperty);
-
- return SUCCESS;
- }
- catch (Exception error) {
- LOG.fatal("Reason:", error);
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("none");
- setLeftMenuProperty("study");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
- return ERROR;
- }
- }
-
-// ==============================================================================================================================
-// Setter
-// ==============================================================================================================================
-
- public void setServletRequest (HttpServletRequest request) {
-// ----------------------------------------------------------
- this.request = request;
- }
- /**
- * Get project settings.
+ @Override
+ public void setServletRequest(final HttpServletRequest request) {
+ this._request = request;
+ }
+
+ /**
+ * Get project settings.
+ *
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* Set project settings service.
- * @param projectSettingsService project settings service
+ *
+ * @param projectSettingsService
+ * project settings service
*/
public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
}
/**
* Get the applicationSettings.
+ *
* @return the applicationSettings
*/
+ @Override
public ApplicationSettings getApplicationSettings() {
- return _ApplicationSettings;
+ return _applicationSettings;
}
/**
* Set the applicationSettings.
- * @param applicationSettings the applicationSettings to set
+ *
+ * @param applicationSettings
+ * the applicationSettings to set
*/
- public void setApplicationSettings(ApplicationSettings applicationSettings) {
- _ApplicationSettings = applicationSettings;
+ @Override
+ public void setApplicationSettings(
+ final ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the _titleProperty.
+ *
* @return the _titleProperty
*/
public String getTitleProperty() {
}
/**
- * Set the _titleProperty.
- * @param _titleProperty the titleProperty to set
+ * Set the titleProperty.
+ *
+ * @param titleProperty
+ * the titleProperty to set
*/
- public void setTitleProperty(String titleProperty) {
+ public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
}
/**
* Get the editDisabledProperty.
+ *
* @return the editDisabledProperty
*/
public final String getEditDisabledProperty() {
/**
* Set the editDisabledProperty.
- * @param editDisabledProperty the editDisabledProperty to set
+ *
+ * @param editDisabledProperty
+ * the editDisabledProperty to set
*/
- public final void setEditDisabledProperty(String editDisabledProperty) {
+ public final void setEditDisabledProperty(final String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
}
/**
* Get the toolProperty.
+ *
* @return the toolProperty
*/
public String getToolProperty() {
/**
* Set the toolProperty.
- * @param toolProperty the toolProperty to set
+ *
+ * @param toolProperty
+ * the toolProperty to set
*/
public void setToolProperty(final String toolProperty) {
_toolProperty = toolProperty;
}
-
+
/**
* Get the leftMenuProperty.
+ *
* @return the leftMenuProperty
*/
public String getLeftMenuProperty() {
/**
* Set the leftMenuProperty.
- * @param leftMenuProperty the leftMenuProperty to set
+ *
+ * @param leftMenuProperty
+ * the leftMenuProperty to set
*/
public void setLeftMenuProperty(final String leftMenuProperty) {
_leftMenuProperty = leftMenuProperty;