From b819b1f8cd82383fd2b2ed63dc71f6ac23fa9731 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 24 Mar 2016 13:25:04 +0100 Subject: fix problem in moa-id-configuration with duplicate entries and delete operation --- .../moa/id/commons/db/NewConfigurationDBRead.java | 43 ++++++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'id/server/moa-id-commons') 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 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 result = new ArrayList(); List 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 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; + } /** * -- cgit v1.2.3