diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2016-03-24 13:25:04 +0100 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2016-03-24 13:25:04 +0100 |
commit | b819b1f8cd82383fd2b2ed63dc71f6ac23fa9731 (patch) | |
tree | e5cc15a66e0ac60efeb98257f81c6852bd337476 | |
parent | d8afdada80249cc2d944b120343fdc22c22ba707 (diff) | |
download | moa-id-spss-b819b1f8cd82383fd2b2ed63dc71f6ac23fa9731.tar.gz moa-id-spss-b819b1f8cd82383fd2b2ed63dc71f6ac23fa9731.tar.bz2 moa-id-spss-b819b1f8cd82383fd2b2ed63dc71f6ac23fa9731.zip |
fix problem in moa-id-configuration with duplicate entries and delete operation
6 files changed, 94 insertions, 64 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java index 22a978014..4cb7eba2d 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java @@ -42,9 +42,7 @@ public class OAGeneralConfig implements IOnlineApplicationData{ private static final Logger log = Logger.getLogger(OAGeneralConfig.class); private boolean isActive = false; - - private String dbID = null; - + private String identifier = null; private String friendlyName = null; private boolean businessService = false; @@ -67,7 +65,7 @@ public class OAGeneralConfig implements IOnlineApplicationData{ friendlyName = dbOAConfig.getFriendlyName(); identifier = dbOAConfig.getPublicURLPrefix(); - + if (dbOAConfig.getType().equals(Constants.MOA_CONFIG_BUSINESSSERVICE)) businessService = true; else @@ -163,27 +161,5 @@ public class OAGeneralConfig implements IOnlineApplicationData{ public void setActive(boolean isActive) { this.isActive = isActive; - } - - /** - * @return the dbID - */ - public String getDbID() { - return dbID; - } - - - /** - * @param dbID the dbID to set - */ - public void setDbID(long dbID) { - this.dbID = String.valueOf(dbID); - } - - /** - * @param dbID the dbID to set - */ - public void setDbID(String dbID) { - this.dbID = dbID; - } + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java index 71639abef..c80bc1925 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java @@ -262,25 +262,8 @@ public class BasicOAAction extends BasicAction { OnlineApplication onlineapplication = null; - Object oadbid = request.getSession().getAttribute(Constants.SESSION_OAID); - Long oaid = (long) -1; - - if (oadbid != null) { - try { - oaid = (Long) oadbid; - if (oaid < 0 || oaid > Long.MAX_VALUE) { - throw new BasicOAActionException( - LanguageHelper.getErrorString("errors.edit.oa.oaid", request), - Constants.STRUTS_ERROR); - } - - } catch (Throwable t) { - throw new BasicOAActionException( - LanguageHelper.getErrorString("errors.edit.oa.oaid", request), - Constants.STRUTS_ERROR); - } - } - + Long oaid = getOAIDFromSession(); + // valid DBID and check entry OAGeneralConfig oaGeneralForm = ((OAGeneralConfig)formList.get(new OAGeneralConfig().getName())); String oaidentifier = oaGeneralForm.getIdentifier(); @@ -316,14 +299,15 @@ public class BasicOAAction extends BasicAction { onlineapplication = configuration.getDbRead().getOnlineApplication(oaidentifier); } - setNewOA(true); + if (onlineapplication != null) { log.info("The OAIdentifier is not unique"); throw new BasicOAActionException( LanguageHelper.getErrorString("validation.general.oaidentifier.notunique", request), Constants.STRUTS_ERROR_VALIDATION); - } + } else + setNewOA(true); } else { onlineapplication = configuration.getDbRead().getOnlineApplication(oaid); @@ -362,6 +346,29 @@ public class BasicOAAction extends BasicAction { } + protected Long getOAIDFromSession() throws BasicOAActionException { + Object oadbid = request.getSession().getAttribute(Constants.SESSION_OAID); + Long oaid = (long) -1; + + if (oadbid != null) { + try { + oaid = (Long) oadbid; + if (oaid < 0 || oaid > Long.MAX_VALUE) { + throw new BasicOAActionException( + LanguageHelper.getErrorString("errors.edit.oa.oaid", request), + Constants.STRUTS_ERROR); + } + + } catch (Throwable t) { + throw new BasicOAActionException( + LanguageHelper.getErrorString("errors.edit.oa.oaid", request), + Constants.STRUTS_ERROR); + } + } + + return oaid; + } + protected String preProcessDeleteOnlineApplication() throws BasicOAActionException { try { Object formidobj = session.getAttribute(Constants.SESSION_FORMID); 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 a8dd48ca0..85b8a8ea0 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 @@ -344,9 +344,35 @@ public class EditOAAction extends BasicOAAction { } oaidentifier = preProcessDeleteOnlineApplication(); - OnlineApplication onlineapplication = configuration.getDbRead() - .getOnlineApplication(oaidentifier); - + List<OnlineApplication> onlineapplications = configuration.getDbRead() + .getOnlineApplications(oaidentifier); + + Long oaid = getOAIDFromSession(); + + OnlineApplication onlineapplication = null; + + if (onlineapplications != null && onlineapplications.size() > 1) { + log.info("Found more then one OA with PublicURLPrefix in configuration. " + + "Select OA with DB Id ..."); + + for (OnlineApplication oa : onlineapplications) { + if (oa.getHjid().equals(oaid)) { + if (onlineapplication == null) + onlineapplication = oa; + + else { + log.error("Found more then one OA with same PublicURLPrefix and same DBID."); + new BasicOAActionException( + "Found more then one OA with same PublicURLPrefix and same DBID.", + Constants.STRUTS_SUCCESS); + + } + } + } + + } else if (onlineapplications != null && onlineapplications.size() == 1) + onlineapplication = onlineapplications.get(0); + request.getSession().setAttribute(Constants.SESSION_OAID, null); // try { diff --git a/id/ConfigWebTool/src/main/resources/struts.xml b/id/ConfigWebTool/src/main/resources/struts.xml index f978e9385..6182a30ce 100644 --- a/id/ConfigWebTool/src/main/resources/struts.xml +++ b/id/ConfigWebTool/src/main/resources/struts.xml @@ -115,8 +115,9 @@ </action> <action name="main" method="generateMainFrame" class="at.gv.egovernment.moa.id.configuration.struts.action.MainAction"> + <result name="input">/jsp/mainpage.jsp</result> <result name="success">/jsp/mainpage.jsp</result> - <result name="error">/error.jsp</result> + <result name="error">/error.jsp</result> <result name="reauthentication" type="redirectAction"> <param name="actionName">logout</param> <param name="namespace">/</param> diff --git a/id/moa-spss-container/pom.xml b/id/moa-spss-container/pom.xml index 32bea1974..49557d83e 100644 --- a/id/moa-spss-container/pom.xml +++ b/id/moa-spss-container/pom.xml @@ -8,6 +8,7 @@ <groupId>MOA.id</groupId> <artifactId>moa-spss-container</artifactId> <version>${moa-id-version}</version> + <packaging>pom</packaging> <name>MOA-SPSS-Container-for-MOA-ID</name> <description>This module holds MOA-SPSS and all required library</description> diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java index 28c705c71..e2f793edf 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java @@ -248,30 +248,49 @@ public class NewConfigurationDBRead { * @param id * @return */ - public OnlineApplication getOnlineApplication(String id) { + public List<OnlineApplication> getOnlineApplications(String id) { Logger.trace("Getting OnlineApplication with ID " + id + " from database."); // select onlineapplication from OnlineApplication onlineapplication // where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) - OnlineApplication result = null; + List<OnlineApplication> result = new ArrayList<OnlineApplication>(); List<OnlineApplication> allOAs = getAllOnlineApplications(); for (OnlineApplication oa : nullGuard(allOAs)) { - String publicUrlPrefix = oa.getPublicURLPrefix(); - if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) { - if (id.substring(0, publicUrlPrefix.length()).equals(publicUrlPrefix)) { - if (result != null) { - Logger.warn("OAIdentifier match to more then one DB-entry!"); - return null; - } else { - result = oa; - } - } + String publicUrlPrefix = oa.getPublicURLPrefix(); + if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) { + if (id.substring(0, publicUrlPrefix.length()).equals(publicUrlPrefix)) + result.add(oa); + } } return result; } + + /** + * + * @param id + * @return + */ + public OnlineApplication getOnlineApplication(String id) { + Logger.trace("Getting OnlineApplication with ID " + id + " from database."); + + // select onlineapplication from OnlineApplication onlineapplication + // where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) + List<OnlineApplication> result = getOnlineApplications(id); + + if (result != null && result.size() == 1) + return result.get(0); + + else if (result != null && result.size() > 1) + Logger.warn("OAIdentifier match to more then one DB-entry!"); + + else + Logger.warn("no OA with OAIdentifier: "+ id); + + return null; + } /** * |