diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-04-03 10:05:38 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-04-03 10:05:38 +0200 |
commit | 80580d72ba7f5af54b77ef1b47c42005e0b5ded8 (patch) | |
tree | 67ac78fdc9a546f721a813727c384eb713bb773a /id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java | |
parent | 38f6c7b91e28ed17078812448b8a0b5a37c29321 (diff) | |
download | moa-id-spss-80580d72ba7f5af54b77ef1b47c42005e0b5ded8.tar.gz moa-id-spss-80580d72ba7f5af54b77ef1b47c42005e0b5ded8.tar.bz2 moa-id-spss-80580d72ba7f5af54b77ef1b47c42005e0b5ded8.zip |
refactor Struts action classes
Diffstat (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java')
-rw-r--r-- | id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java | 216 |
1 files changed, 86 insertions, 130 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java index 2e8ec29de..4830ffb71 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java @@ -32,6 +32,7 @@ import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; import at.gv.egovernment.moa.id.configuration.data.FormularCustomization; import at.gv.egovernment.moa.id.configuration.data.oa.*; +import at.gv.egovernment.moa.id.configuration.exception.BasicActionException; import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.helper.MailHelper; @@ -57,17 +58,11 @@ import java.math.BigInteger; import java.security.cert.CertificateException; import java.util.*; -public class EditOAAction extends ActionSupport implements ServletRequestAware, ServletResponseAware { +public class EditOAAction extends BasicAction { private final Logger log = Logger.getLogger(EditOAAction.class); - private static final long serialVersionUID = 1L; - private HttpServletRequest request; - private HttpServletResponse response; - - private AuthenticatedUser authUser; - private String oaidobj; private boolean newOA; private String formID; @@ -96,15 +91,13 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, // STRUTS actions public String inital() { - HttpSession session = request.getSession(); - if (session == null) { - log.info("No http Session found."); - return Constants.STRUTS_ERROR; - } - - Object authUserObj = session.getAttribute(Constants.SESSION_AUTH); - - authUser = (AuthenticatedUser) authUserObj; + try { + populateBasicInformations(); + + } catch (BasicActionException e) { + return Constants.STRUTS_ERROR; + + } long oaid = -1; @@ -183,19 +176,17 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, public String newOA() { log.debug("insert new Online-Application"); - HttpSession session = request.getSession(); - if (session == null) { - log.info("No http Session found."); - return Constants.STRUTS_ERROR; - } + try { + populateBasicInformations(); + + } catch (BasicActionException e) { + return Constants.STRUTS_ERROR; + + } session.setAttribute(Constants.SESSION_OAID, null); nextPage = Constants.STRUTS_RETURNAREA_VALUES.main.name(); - Object authUserObj = session.getAttribute(Constants.SESSION_AUTH); - - authUser = (AuthenticatedUser) authUserObj; - UserDatabase userdb = ConfigurationDBRead.getUserWithID(authUser.getUserID()); if (!authUser.isAdmin() && userdb.isIsMailAddressVerified() != null && !userdb.isIsMailAddressVerified()) { @@ -236,14 +227,13 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, } public String saveOA() { - HttpSession session = request.getSession(); - if (session == null) { - log.info("No http Session found."); - return Constants.STRUTS_ERROR; - } - - Object authUserObj = session.getAttribute(Constants.SESSION_AUTH); - authUser = (AuthenticatedUser) authUserObj; + try { + populateBasicInformations(); + + } catch (BasicActionException e) { + return Constants.STRUTS_ERROR; + + } Object formidobj = session.getAttribute(Constants.SESSION_FORMID); if (formidobj != null && formidobj instanceof String) { @@ -507,12 +497,13 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, } public String cancleAndBackOA() { - - HttpSession session = request.getSession(); - if (session == null) { - log.info("No http Session found."); - return Constants.STRUTS_ERROR; - } + try { + populateBasicInformations(); + + } catch (BasicActionException e) { + return Constants.STRUTS_ERROR; + + } Object nextPageAttr = session.getAttribute(Constants.SESSION_RETURNAREA); if (nextPageAttr != null && nextPageAttr instanceof String) { @@ -533,14 +524,13 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, } public String deleteOA() { - HttpSession session = request.getSession(); - if (session == null) { - log.info("No http Session found."); - return Constants.STRUTS_ERROR; - } - - Object authUserObj = session.getAttribute(Constants.SESSION_AUTH); - authUser = (AuthenticatedUser) authUserObj; + try { + populateBasicInformations(); + + } catch (BasicActionException e) { + return Constants.STRUTS_ERROR; + + } Object formidobj = session.getAttribute(Constants.SESSION_FORMID); if (formidobj != null && formidobj instanceof String) { @@ -648,75 +638,75 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, String preview = null; - HttpSession session = request.getSession(); - if (session == null) { - log.info("No http Session found."); - preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible", request); + try { + populateBasicInformations(); + + } catch (BasicActionException e) { + return Constants.STRUTS_ERROR; + + } + InputStream input = null; - } else { - InputStream input = null; - - try { - Object mapobj = session.getAttribute(Constants.SESSION_BKUFORMPREVIEW); - if (mapobj != null && mapobj instanceof Map<?, ?>) { + try { + Object mapobj = session.getAttribute(Constants.SESSION_BKUFORMPREVIEW); + if (mapobj != null && mapobj instanceof Map<?, ?>) { - ConfigurationProvider config = ConfigurationProvider.getInstance(); - String templateURL = config.getConfigRootDir() + ConfigurationProvider.HTMLTEMPLATE_DIR - + ConfigurationProvider.HTMLTEMPLATE_FILE; + ConfigurationProvider config = ConfigurationProvider.getInstance(); + String templateURL = config.getConfigRootDir() + ConfigurationProvider.HTMLTEMPLATE_DIR + + ConfigurationProvider.HTMLTEMPLATE_FILE; - File file = new File(templateURL); - input = new FileInputStream(file); + File file = new File(templateURL); + input = new FileInputStream(file); - String contextpath = config.getMOAIDInstanceURL(); - if (MiscUtil.isEmpty(contextpath)) { - log.info("NO MOA-ID instance URL configurated."); - throw new ConfigurationException("No MOA-ID instance configurated"); - } + String contextpath = config.getMOAIDInstanceURL(); + if (MiscUtil.isEmpty(contextpath)) { + log.info("NO MOA-ID instance URL configurated."); + throw new ConfigurationException("No MOA-ID instance configurated"); + } - preview = LoginFormBuilder.getTemplate(input); - preview = preview.replace(LoginFormBuilder.CONTEXTPATH, contextpath); + preview = LoginFormBuilder.getTemplate(input); + preview = preview.replace(LoginFormBuilder.CONTEXTPATH, contextpath); - Map<String, String> map = (Map<String, String>) mapobj; + Map<String, String> map = (Map<String, String>) mapobj; - request.setCharacterEncoding("UTF-8"); + request.setCharacterEncoding("UTF-8"); - String module = request.getParameter(Constants.REQUEST_FORMCUSTOM_MODULE); - String value = request.getParameter(Constants.REQUEST_FORMCUSTOM_VALUE); + String module = request.getParameter(Constants.REQUEST_FORMCUSTOM_MODULE); + String value = request.getParameter(Constants.REQUEST_FORMCUSTOM_VALUE); - if (value != null) { - String[] query = URLDecoder.decode(request.getQueryString()).split("&"); - value = query[1].substring("value=".length()); - } + if (value != null) { + String[] query = URLDecoder.decode(request.getQueryString()).split("&"); + value = query[1].substring("value=".length()); + } - synchronized (map) { + synchronized (map) { - if (MiscUtil.isNotEmpty(module)) { - if (map.containsKey("#" + module + "#")) { - if (MiscUtil.isNotEmpty(value)) { - if (FormBuildUtils.FONTFAMILY.contains(module) || FormBuildUtils.HEADER_TEXT.contains(module) - || value.startsWith("#")) - map.put("#" + module + "#", value); - else - map.put("#" + module + "#", "#" + value); + if (MiscUtil.isNotEmpty(module)) { + if (map.containsKey("#" + module + "#")) { + if (MiscUtil.isNotEmpty(value)) { + if (FormBuildUtils.FONTFAMILY.contains(module) || FormBuildUtils.HEADER_TEXT.contains(module) + || value.startsWith("#")) + map.put("#" + module + "#", value); + else + map.put("#" + module + "#", "#" + value); - } else { - map.put("#" + module + "#", FormBuildUtils.getDefaultMap().get("#" + module + "#")); - } + } else { + map.put("#" + module + "#", FormBuildUtils.getDefaultMap().get("#" + module + "#")); } } - preview = FormBuildUtils.customiceLayoutBKUSelection(preview, true, false, map, true); } - - } else { - preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible", request); - + preview = FormBuildUtils.customiceLayoutBKUSelection(preview, true, false, map, true); } - } catch (Exception e) { - log.warn("BKUSelection Preview can not be generated.", e); + } else { preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible", request); } + + } catch (Exception e) { + log.warn("BKUSelection Preview can not be generated.", e); + preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible", request); + } stream = new ByteArrayInputStream(preview.getBytes()); @@ -1132,33 +1122,6 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, return Constants.STRUTS_SUCCESS; } - // Getter and Setter - public void setServletResponse(HttpServletResponse arg0) { - this.response = arg0; - - } - - public void setServletRequest(HttpServletRequest arg0) { - this.request = arg0; - - } - - public HttpServletRequest getRequest() { - return request; - } - - public void setRequest(HttpServletRequest request) { - this.request = request; - } - - public HttpServletResponse getResponse() { - return response; - } - - public void setResponse(HttpServletResponse response) { - this.response = response; - } - public OAGeneralConfig getGeneralOA() { return generalOA; } @@ -1207,13 +1170,6 @@ public class EditOAAction extends ActionSupport implements ServletRequestAware, } /** - * @return the authUser - */ - public AuthenticatedUser getAuthUser() { - return authUser; - } - - /** * @return the newOA */ public boolean isNewOA() { |