aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/at')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egiz/components/configuration/api/AbstractConfigurationImpl.java6
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java3
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java25
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java776
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java22
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java134
6 files changed, 571 insertions, 395 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egiz/components/configuration/api/AbstractConfigurationImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egiz/components/configuration/api/AbstractConfigurationImpl.java
index d5ea2342a..e2db54609 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egiz/components/configuration/api/AbstractConfigurationImpl.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egiz/components/configuration/api/AbstractConfigurationImpl.java
@@ -526,6 +526,12 @@ public abstract class AbstractConfigurationImpl implements Configuration {
}
/* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.Configuration#deleteIds(java.lang.String)
+ */
+ @Override
+ abstract public void deleteIds(String idSearch) throws ConfigurationException;
+
+ /* (non-Javadoc)
* @see at.gv.egiz.components.configuration.api.Configuration#synchronize()
*/
@Override
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java
index 974646ef0..694ff0720 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java
@@ -113,6 +113,9 @@ public class ConfigurationMigrationUtils {
* @return MOA-ID 3.x OnlineApplication configuration without prefix but never Null
*/
public static Map<String, String> convertHyberJaxBOnlineApplicationToKeyValue(OnlineApplication oa) {
+ //TODO: add C-PEPS countries and STORK attributes from general config!!!!
+ //TODO: add correct list identifiers for metadata handling
+
Map<String, String> result = new HashMap<String, String>();
if (oa != null) {
//convert oaID and friendlyname
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java
index 78eec24ee..34e3f3c7e 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java
@@ -1,7 +1,9 @@
package at.gv.egovernment.moa.id.commons.config;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
/**
@@ -26,14 +28,24 @@ public final class MOAIDConfigurationConstants {
public static final Map<String, String> BUSINESSSERVICENAMES;
+ public static final List<String> ALLOWED_WBPK_PREFIXES;
+
static {
Hashtable<String, String> tmp = new Hashtable<String, String>();
tmp.put(IDENIFICATIONTYPE_FN, "Firmenbuchnummer");
tmp.put(IDENIFICATIONTYPE_ZVR, "Vereinsnummer");
tmp.put(IDENIFICATIONTYPE_ERSB, "ERsB Kennzahl");
tmp.put(IDENIFICATIONTYPE_STORK, "STORK");
-
BUSINESSSERVICENAMES = Collections.unmodifiableMap(tmp);
+
+ List<String> awbpk = new ArrayList<String>();
+ awbpk.add(IDENIFICATIONTYPE_FN);
+ awbpk.add(IDENIFICATIONTYPE_ERSB);
+ awbpk.add(IDENIFICATIONTYPE_ZVR);
+ awbpk.add(PREFIX_WPBK + IDENIFICATIONTYPE_FN);
+ awbpk.add(PREFIX_WPBK + IDENIFICATIONTYPE_ERSB);
+ awbpk.add(PREFIX_WPBK + IDENIFICATIONTYPE_ZVR);
+ ALLOWED_WBPK_PREFIXES = Collections.unmodifiableList(awbpk);
}
@@ -206,9 +218,10 @@ public final class MOAIDConfigurationConstants {
public static final String GENERAL_DEFAULTS_TEMPLATES_ONLINE = GENERAL_DEFAULTS_TEMPLATES + ".onlineBKU";
private static final String GENERAL_AUTH = PREFIX_MOAID_GENERAL + ".auth";
- public static final String GENERAL_AUTH_CERTSTORE_URL = GENERAL_AUTH + ".certstore.url";
- public static final String GENERAL_AUTH_TRUSTSTORE_URL = GENERAL_AUTH + ".truststore.url";
- public static final String GENERAL_AUTH_REVOCATIONCHECKING = GENERAL_AUTH + ".revocationchecking";
+ private static final String GENERAL_AUTH_CERTIFICATE = GENERAL_AUTH + ".certificate";
+ public static final String GENERAL_AUTH_CERTSTORE_URL = GENERAL_AUTH_CERTIFICATE + ".certstore.url";
+ public static final String GENERAL_AUTH_TRUSTSTORE_URL = GENERAL_AUTH_CERTIFICATE + ".truststore.url";
+ public static final String GENERAL_AUTH_REVOCATIONCHECKING = GENERAL_AUTH_CERTIFICATE + ".revocationchecking";
public static final String GENERAL_AUTH_TIMEOUTS_TRANSACTION = GENERAL_AUTH + ".timeouts.transaction"; //Anmeldedaten
public static final String GENERAL_AUTH_TIMEOUS_SSO_CREATE = GENERAL_AUTH + ".timeouts.sso.create";
@@ -256,8 +269,8 @@ public final class MOAIDConfigurationConstants {
public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_COMPANY = GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT + ".company";
public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_TYPE = GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT + ".type";
- public static final String GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_NAME = GENERAL_AUTH + ".authblock.transformation.name";
- public static final String GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64 = GENERAL_AUTH + ".authblock.transformation.base64";
+ public static final String GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_NAME = GENERAL_AUTH + ".authblock.transformation.preview";
+ public static final String GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64 = GENERAL_AUTH + ".authblock.transformation.data";
public static final String GENERAL_AUTH_STORK = GENERAL_AUTH + "." + STORK;
public static final String GENERAL_AUTH_STORK_QAA = GENERAL_AUTH_STORK + ".qaa";
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 66143efad..8f6100f84 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
@@ -1,53 +1,69 @@
-//package at.gv.egovernment.moa.id.commons.db;
-//
-//import java.util.ArrayList;
-//import java.util.Collections;
-//import java.util.Date;
-//import java.util.List;
-//
-//import org.springframework.beans.factory.annotation.Autowired;
-//
-//import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
-//import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
-//import at.gv.egovernment.moa.logging.Logger;
-//
-///**
-// *
-// *
-// */
-//public class NewConfigurationDBRead {
-//
-// private static MOAIDConfiguration conf;
-//
-// @Autowired(required = true)
-// public void setConfiguration(MOAIDConfiguration conf) {
-// // https://jira.spring.io/browse/SPR-3845
-// NewConfigurationDBRead.conf = conf;
-// }
-//
-// @SuppressWarnings("unchecked")
-// public static <T extends Iterable<?>> T nullGuard(T item) {
-// if (item == null) {
-// return (T) Collections.emptyList();
-// } else {
-// return item;
-// }
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public static List<UserDatabase> getAllUsers() {
-// Logger.trace("Get All Users from database.");
-//
+package at.gv.egovernment.moa.id.commons.db;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import at.gv.egiz.components.configuration.api.ConfigurationException;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration;
+import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral;
+import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes;
+import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs;
+import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration;
+import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
+
+import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ *
+ *
+ */
+public class NewConfigurationDBRead {
+
+ private static MOAIDConfiguration conf;
+
+ @Autowired(required = true)
+ public void setConfiguration(MOAIDConfiguration conf) {
+ // https://jira.spring.io/browse/SPR-3845
+ NewConfigurationDBRead.conf = conf;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T extends Iterable<?>> T nullGuard(T item) {
+ if (item == null) {
+ return (T) Collections.emptyList();
+ } else {
+ return item;
+ }
+
+ }
+
+ public static Map<String, String> getOnlineApplicationKeyValueWithId(String id) {
+ try {
+ return conf.getOnlineApplication(id);
+
+ } catch (ConfigurationException e) {
+ Logger.warn("OnlineApplication with Id: " + id + " not found.", e);
+ return null;
+
+ }
+ }
+
+
+
+ /**
+ *
+ * @return
+ */
+ public static List<UserDatabase> getAllUsers() {
+ Logger.trace("Get All Users from database.");
+
// // select userdatabase from UserDatabase userdatabase
// List<UserDatabase> result = conf.getList("getAllUsers", UserDatabase.class);
// if (result.size() == 0) {
@@ -56,46 +72,52 @@
// }
//
// return result;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public static List<OnlineApplication> getAllOnlineApplications() {
-// Logger.trace("Get All OnlineApplications from database.");
-//
-// // select onlineapplication from OnlineApplication onlineapplication
+
+ //TODO!!!
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static List<OnlineApplication> getAllOnlineApplications() {
+ Logger.trace("Get All OnlineApplications from database.");
+
+ // select onlineapplication from OnlineApplication onlineapplication
// return conf.getList(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, OnlineApplication.class);
-//
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public static List<OnlineApplication> getAllNewOnlineApplications() {
-// Logger.trace("Get All New OnlineApplications from database.");
-//
-// // select onlineapplication from OnlineApplication onlineapplication
-// // where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1'
-// List<OnlineApplication> result = new ArrayList<OnlineApplication>();
-// List<OnlineApplication> allOAs = getAllOnlineApplications();
-//
-// for (OnlineApplication oa : nullGuard(allOAs)) {
-// if (!oa.isIsActive() && oa.isIsAdminRequired()) {
-// result.add(oa);
-// }
-// }
-//
-// if (result.size() == 0) {
-// Logger.trace("No entries found.");
-// return null;
-// }
-//
-// return result;
-// }
-//
+
+ //TODO!!!
+ return null;
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static List<OnlineApplication> getAllNewOnlineApplications() {
+ Logger.trace("Get All New OnlineApplications from database.");
+
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1'
+ List<OnlineApplication> result = new ArrayList<OnlineApplication>();
+ List<OnlineApplication> allOAs = getAllOnlineApplications();
+
+ for (OnlineApplication oa : nullGuard(allOAs)) {
+ if (!oa.isIsActive() && oa.isIsAdminRequired()) {
+ result.add(oa);
+ }
+ }
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return result;
+ }
+
// /**
// *
// * @return
@@ -138,291 +160,291 @@
//
// return result;
// }
-//
-// /**
-// *
-// * @return
-// */
-// public static List<OnlineApplication> getAllActiveOnlineApplications() {
-// Logger.trace("Get All New OnlineApplications from database.");
-//
-// // select onlineapplication from OnlineApplication onlineapplication
-// // where onlineapplication.isActive = '1'
-// List<OnlineApplication> result = new ArrayList<OnlineApplication>();
-// List<OnlineApplication> allOAs = getAllOnlineApplications();
-//
-// for (OnlineApplication oa : nullGuard(allOAs)) {
-// if (oa.isIsActive()) {
-// result.add(oa);
-// }
-// }
-//
-// if (result.size() == 0) {
-// Logger.trace("No entries found.");
-// return null;
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param id
-// * @return
-// */
-// public static OnlineApplication getActiveOnlineApplication(String id) {
-// Logger.trace("Getting Active OnlineApplication with ID " + id + " from database.");
-//
-// // select onlineapplication from OnlineApplication onlineapplication
-// // where onlineapplication.publicURLPrefix =
-// // SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'
-// OnlineApplication result = null;
-// List<OnlineApplication> allActiveOAs = getAllActiveOnlineApplications();
-//
-// for (OnlineApplication oa : nullGuard(allActiveOAs)) {
-// String publicUrlPrefix = oa.getPublicURLPrefix();
-// if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) {
-// if ((id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix))) {
-// if (result != null) {
-// Logger.warn("OAIdentifier match to more then one DB-entry!");
-// return null;
-// } else {
-// result = oa;
-// }
-// }
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param dbid
-// * @return
-// */
-// public static OnlineApplication getOnlineApplication(long dbid) {
-// Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database.");
-//
-// // select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id
-// OnlineApplication result = null;
-// List<OnlineApplication> allOAs = getAllOnlineApplications();
-//
-// for (OnlineApplication oa : nullGuard(allOAs)) {
-// if (oa.getHjid() == dbid) {
-// result = oa;
-// break;
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param id
-// * @return
-// */
-// public static 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))
-// OnlineApplication result = null;
-// List<OnlineApplication> allOAs = getAllOnlineApplications();
-//
-// for (OnlineApplication oa : nullGuard(allOAs)) {
-// String publicUrlPrefix = oa.getPublicURLPrefix();
-// if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) {
-// if (id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix)) {
-// if (result != null) {
-// Logger.warn("OAIdentifier match to more then one DB-entry!");
-// return null;
-// } else {
-// result = oa;
-// }
-// }
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param id
-// * @return
-// */
-// public static List<OnlineApplication> searchOnlineApplications(String id) {
-// Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
-//
-// // select onlineapplication from OnlineApplication onlineapplication
-// // where onlineapplication.friendlyName like :id
-// List<OnlineApplication> result = new ArrayList<OnlineApplication>();
-// List<OnlineApplication> allOAs = getAllOnlineApplications();
-//
-// for (OnlineApplication oa : nullGuard(allOAs)) {
-// if (id.equals(oa.getFriendlyName())) {
-// result.add(oa);
-// }
-// }
-//
-// if (result.size() == 0) {
-// Logger.trace("No entries found.");
-// return null;
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public static List<UserDatabase> getAllOpenUsersRequests() {
-// Logger.trace("Get all new Users from Database");
-//
-// // select userdatabase from UserDatabase userdatabase
-// // where userdatabase.userRequestTokken is not null
-// // and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0'
-// List<UserDatabase> result = new ArrayList<UserDatabase>();
-// List<UserDatabase> allUsers = getAllUsers();
-//
-// for (UserDatabase user : nullGuard(allUsers)) {
-// // TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?)
-// if ((user.getUserRequestTokken() != null && !user.getUserRequestTokken().isEmpty() && !user.getUserRequestTokken().equals("NULL"))
-// && (user.isIsAdminRequest()) && (!user.isIsMailAddressVerified())) {
-// result.add(user);
-// }
-// }
-//
-// if (result.size() == 0) {
-// Logger.trace("No entries found.");
-// return null;
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param tokken
-// * @return
-// */
-// public static UserDatabase getNewUserWithTokken(String tokken) {
-// Logger.trace("Getting Userinformation with Tokken " + tokken + " from database.");
-//
-// // select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken
-// UserDatabase result = null;
-// List<UserDatabase> allUsers = getAllUsers();
-//
-// for (UserDatabase user : nullGuard(allUsers)) {
-// if (user.getUserRequestTokken().equals(tokken)) {
-// result = user;
-// break;
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param id
-// * @return
-// */
-// public static UserDatabase getUsersWithOADBID(long id) {
-// Logger.trace("Getting Userinformation with OADBID " + id + " from database.");
-//
-// // select userdatabase from UserDatabase userdatabase
-// // inner join userdatabase.onlineApplication oa where oa.hjid = :id
-// UserDatabase result = null;
-// List<UserDatabase> allUsers = getAllUsers();
-//
-// boolean quit = false;
-// for (UserDatabase user : nullGuard(allUsers)) {
-//
-// for (OnlineApplication oa : user.getOnlineApplication()) {
-//
-// if (oa.getHjid() == id) {
-// result = user;
-// quit = true;
-// break;
-// }
-// }
-//
-// if (quit) {
-// break;
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param id
-// * @return
-// */
-// public static UserDatabase getUserWithID(long id) {
-// Logger.trace("Getting Userinformation with ID " + id + " from database.");
-//
-// // select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id
-// UserDatabase result = null;
-// List<UserDatabase> allUsers = getAllUsers();
-//
-// for (UserDatabase user : nullGuard(allUsers)) {
-// if (user.getHjid() == id) {
-// result = user;
-// break;
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param username
-// * @return
-// */
-// public static UserDatabase getUserWithUserName(String username) {
-// Logger.trace("Getting Userinformation with ID " + username + " from database.");
-//
-// // select userdatabase from UserDatabase userdatabase where userdatabase.username = :username
-// UserDatabase result = null;
-// List<UserDatabase> allUsers = getAllUsers();
-//
-// for (UserDatabase user : nullGuard(allUsers)) {
-// if (user.getUsername().equals(username)) {
-// result = user;
-// break;
-// }
-// }
-//
-// return result;
-// }
-//
-// /**
-// *
-// * @param bpkwbpk
-// * @return
-// */
-// public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) {
-// Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database.");
-//
-// // select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk
-// UserDatabase result = null;
-// List<UserDatabase> allUsers = getAllUsers();
-//
-// for (UserDatabase user : nullGuard(allUsers)) {
-// if (user.getBpk().equals(bpkwbpk)) {
-// result = user;
-// break;
-// }
-// }
-//
-// return result;
-// }
-//
-//}
+
+ /**
+ *
+ * @return
+ */
+ public static List<OnlineApplication> getAllActiveOnlineApplications() {
+ Logger.trace("Get All New OnlineApplications from database.");
+
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.isActive = '1'
+ List<OnlineApplication> result = new ArrayList<OnlineApplication>();
+ List<OnlineApplication> allOAs = getAllOnlineApplications();
+
+ for (OnlineApplication oa : nullGuard(allOAs)) {
+ if (oa.isIsActive()) {
+ result.add(oa);
+ }
+ }
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public static OnlineApplication getActiveOnlineApplication(String id) {
+ Logger.trace("Getting Active OnlineApplication with ID " + id + " from database.");
+
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.publicURLPrefix =
+ // SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'
+ OnlineApplication result = null;
+ List<OnlineApplication> allActiveOAs = getAllActiveOnlineApplications();
+
+ for (OnlineApplication oa : nullGuard(allActiveOAs)) {
+ String publicUrlPrefix = oa.getPublicURLPrefix();
+ if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) {
+ if ((id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix))) {
+ if (result != null) {
+ Logger.warn("OAIdentifier match to more then one DB-entry!");
+ return null;
+ } else {
+ result = oa;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param dbid
+ * @return
+ */
+ public static OnlineApplication getOnlineApplication(long dbid) {
+ Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database.");
+
+ // select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id
+ OnlineApplication result = null;
+ List<OnlineApplication> allOAs = getAllOnlineApplications();
+
+ for (OnlineApplication oa : nullGuard(allOAs)) {
+ if (oa.getHjid() == dbid) {
+ result = oa;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public static 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))
+ OnlineApplication result = null;
+ List<OnlineApplication> allOAs = getAllOnlineApplications();
+
+ for (OnlineApplication oa : nullGuard(allOAs)) {
+ String publicUrlPrefix = oa.getPublicURLPrefix();
+ if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) {
+ if (id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix)) {
+ if (result != null) {
+ Logger.warn("OAIdentifier match to more then one DB-entry!");
+ return null;
+ } else {
+ result = oa;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public static List<OnlineApplication> searchOnlineApplications(String id) {
+ Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.friendlyName like :id
+ List<OnlineApplication> result = new ArrayList<OnlineApplication>();
+ List<OnlineApplication> allOAs = getAllOnlineApplications();
+
+ for (OnlineApplication oa : nullGuard(allOAs)) {
+ if (id.equals(oa.getFriendlyName())) {
+ result.add(oa);
+ }
+ }
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static List<UserDatabase> getAllOpenUsersRequests() {
+ Logger.trace("Get all new Users from Database");
+
+ // select userdatabase from UserDatabase userdatabase
+ // where userdatabase.userRequestTokken is not null
+ // and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0'
+ List<UserDatabase> result = new ArrayList<UserDatabase>();
+ List<UserDatabase> allUsers = getAllUsers();
+
+ for (UserDatabase user : nullGuard(allUsers)) {
+ // TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?)
+ if ((user.getUserRequestTokken() != null && !user.getUserRequestTokken().isEmpty() && !user.getUserRequestTokken().equals("NULL"))
+ && (user.isIsAdminRequest()) && (!user.isIsMailAddressVerified())) {
+ result.add(user);
+ }
+ }
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param tokken
+ * @return
+ */
+ public static UserDatabase getNewUserWithTokken(String tokken) {
+ Logger.trace("Getting Userinformation with Tokken " + tokken + " from database.");
+
+ // select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken
+ UserDatabase result = null;
+ List<UserDatabase> allUsers = getAllUsers();
+
+ for (UserDatabase user : nullGuard(allUsers)) {
+ if (user.getUserRequestTokken().equals(tokken)) {
+ result = user;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public static UserDatabase getUsersWithOADBID(long id) {
+ Logger.trace("Getting Userinformation with OADBID " + id + " from database.");
+
+ // select userdatabase from UserDatabase userdatabase
+ // inner join userdatabase.onlineApplication oa where oa.hjid = :id
+ UserDatabase result = null;
+ List<UserDatabase> allUsers = getAllUsers();
+
+ boolean quit = false;
+ for (UserDatabase user : nullGuard(allUsers)) {
+
+ for (OnlineApplication oa : user.getOnlineApplication()) {
+
+ if (oa.getHjid() == id) {
+ result = user;
+ quit = true;
+ break;
+ }
+ }
+
+ if (quit) {
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public static UserDatabase getUserWithID(long id) {
+ Logger.trace("Getting Userinformation with ID " + id + " from database.");
+
+ // select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id
+ UserDatabase result = null;
+ List<UserDatabase> allUsers = getAllUsers();
+
+ for (UserDatabase user : nullGuard(allUsers)) {
+ if (user.getHjid() == id) {
+ result = user;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param username
+ * @return
+ */
+ public static UserDatabase getUserWithUserName(String username) {
+ Logger.trace("Getting Userinformation with ID " + username + " from database.");
+
+ // select userdatabase from UserDatabase userdatabase where userdatabase.username = :username
+ UserDatabase result = null;
+ List<UserDatabase> allUsers = getAllUsers();
+
+ for (UserDatabase user : nullGuard(allUsers)) {
+ if (user.getUsername().equals(username)) {
+ result = user;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @param bpkwbpk
+ * @return
+ */
+ public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) {
+ Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database.");
+
+ // select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk
+ UserDatabase result = null;
+ List<UserDatabase> allUsers = getAllUsers();
+
+ for (UserDatabase user : nullGuard(allUsers)) {
+ if (user.getBpk().equals(bpkwbpk)) {
+ result = user;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java
index 8e845478b..00c191228 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java
@@ -100,7 +100,10 @@ public class DatabaseConfigPropertyImpl extends AbstractConfigurationImpl {
protected void deleteKey(String key) {
log.debug("Deleting entry with key '{}'.", key);
- em.remove(em.find(ConfigProperty.class, key));
+ ConfigProperty el = em.find(ConfigProperty.class, key);
+ if (el != null)
+ em.remove(el);
+
}
/* (non-Javadoc)
@@ -117,7 +120,10 @@ public class DatabaseConfigPropertyImpl extends AbstractConfigurationImpl {
TypedQuery<String> query = em.createQuery("select key from ConfigProperty dbconfig where dbconfig.key like :key", String.class);
query.setParameter("key", searchString.replace("*", "%"));
List<String> result = query.getResultList();
- return result.toArray(new String[result.size()]);
+ if (result == null)
+ return null;
+ else
+ return result.toArray(new String[result.size()]);
}
/* (non-Javadoc)
@@ -166,7 +172,17 @@ public class DatabaseConfigPropertyImpl extends AbstractConfigurationImpl {
return result;
}
-
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#deleteIds(java.lang.String)
+ */
+ @Override
+ public void deleteIds(String idSearch) throws ConfigurationException {
+ String[] keyList = findConfigurationId(idSearch);
+ for (String el : keyList) {
+ deleteKey(el);
+
+ }
+ }
// @Override
// public String getPropertyValue(String key) {
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java
index 626db2167..0e4616825 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java
@@ -22,23 +22,35 @@
*/
package at.gv.egovernment.moa.id.commons.utils;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import at.gv.egovernment.moa.util.MiscUtil;
+
/**
* @author tlenz
*
*/
public class KeyValueUtils {
+ public static final String KEY_DELIMITER = ".";
+
/**
* Extract the first child of an input key after a the prefix
*
- * @param key: Full input key
- * @param prefix: Prefix
+ * @param key Full input key
+ * @param prefix Prefix
* @return Child key {String} if it exists or null
*/
public static String getFirstChildAfterPrefix(String key, String prefix) {
String idAfterPrefix = removePrefixFromKey(key, prefix);
if (idAfterPrefix != null) {
- int index = idAfterPrefix.indexOf(".");
+ int index = idAfterPrefix.indexOf(KEY_DELIMITER);
if (index > 0) {
String adding = idAfterPrefix.substring(0, index);
if (!(adding.isEmpty())) {
@@ -57,14 +69,14 @@ public class KeyValueUtils {
/**
* Extract the prefix from an input key
*
- * @param key: Full input key
- * @param suffix: Suffix of this key
+ * @param key Full input key
+ * @param suffix Suffix of this key
* @return Prefix {String} of the key or null if input key does not ends with postfix string
*/
public static String getPrefixFromKey(String key, String suffix) {
if (key != null && key.endsWith(suffix)) {
String idPreforeSuffix = key.substring(0, key.length()-suffix.length());
- if (idPreforeSuffix.endsWith("."))
+ if (idPreforeSuffix.endsWith(KEY_DELIMITER))
return idPreforeSuffix.substring(0, idPreforeSuffix.length()-1);
else
return idPreforeSuffix;
@@ -76,8 +88,8 @@ public class KeyValueUtils {
/**
* Remove a prefix string from a key
*
- * @param key: Full input key
- * @param prefix: Prefix, which should be removed
+ * @param key Full input key
+ * @param prefix Prefix, which should be removed
* @return The suffix of the input key or null if the input does not starts with the prefix
*/
public static String removePrefixFromKey(String key, String prefix) {
@@ -86,7 +98,7 @@ public class KeyValueUtils {
if (key!=null && key.startsWith(prefix)) {
String afterPrefix = key.substring(prefix.length());
- int index = afterPrefix.indexOf(".");
+ int index = afterPrefix.indexOf(KEY_DELIMITER);
if (index == 0) {
afterPrefix = afterPrefix.substring(1);
@@ -98,4 +110,108 @@ public class KeyValueUtils {
return null;
}
+ /**
+ * Remove a prefix string from all keys in {Map<String, String>} of key/value pairs
+ *
+ * @param keys Input data of key/value pairs
+ * @param prefix Prefix which should be removed
+ * @return {Map<String, String>} of key/value pairs without prefix in key, but never null
+ */
+ public static Map<String, String> removePrefixFromKeys(Map<String, String> keys, String prefix) {
+ Map<String, String> result = new HashMap<String, String>();
+ Iterator<Entry<String, String>> interator = keys.entrySet().iterator();
+ while(interator.hasNext()) {
+ Entry<String, String> el = interator.next();
+ String newKey = removePrefixFromKey(el.getKey(), prefix);
+ if (MiscUtil.isNotEmpty(newKey)) {
+ result.put(newKey, el.getValue());
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Get a subset of key/value pairs which starts with a prefix string
+ * The Prefix is removed from the key
+ *
+ * @param keys Input data of key/value pairs
+ * @param prefix Prefix string
+ * @return {Map<String, String>} of key/value pairs without prefix in key, but never null
+ */
+ public static Map<String, String> getSubSetWithPrefix(Map<String, String> keys, String prefix) {
+ return removePrefixFromKeys(keys, prefix);
+ }
+
+
+ /**
+ * Add a prefix to key/value pairs to make the key absolute according to key namespace convention
+ *
+ * @param input Input key/value pairs which should be updated
+ * @param prefix Key prefix, which should be added if the key is not absolute
+ * @param absolutIdentifier Key identifier, which indicates an absolute key
+ * @return {Map<String, String>} of key/value pairs in which all keys are absolute but never null
+ */
+ public static Map<String, String> makeKeysAbsolut(Map<String, String> input, String prefix, String absolutIdentifier) {
+ Map<String, String> result = new HashMap<String, String>();
+ Iterator<Entry<String, String>> interator = input.entrySet().iterator();
+ while(interator.hasNext()) {
+ Entry<String, String> el = interator.next();
+ if (!el.getKey().startsWith(absolutIdentifier)) {
+ //key is not absolute -> add prefix
+ result.put(prefix
+ + KEY_DELIMITER
+ + el.getKey(),
+ el.getValue());
+
+ } else {
+ //key is absolute
+ result.put(el.getKey(), el.getValue());
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the parent key string from an input key
+ *
+ * @param key input key
+ * @return parent key or the empty String if no parent exists
+ */
+ public static String getParentKey(String key) {
+ if (MiscUtil.isNotEmpty(key)) {
+ int index = key.lastIndexOf(KEY_DELIMITER);
+ if (index > 0) {
+ return key.substring(0, index);
+
+ }
+ }
+
+ return new String();
+ }
+
+ /**
+ * Find the highest free list counter
+ *
+ * @param input Array of list keys
+ * @param listPrefix {String} prefix of the list
+ * @return {int} highest free list counter
+ */
+ public static int findNextFreeListCounter(String[] input,
+ String listPrefix) {
+ List<Integer> counters = new ArrayList<Integer>();
+ if (input == null || input.length == 0)
+ return 0;
+
+ else {
+ for (String key : input) {
+ String listIndex = getFirstChildAfterPrefix(key, listPrefix);
+ counters.add(Integer.parseInt(listIndex));
+
+ }
+ Collections.sort(counters);
+ return counters.get(counters.size()-1) + 1;
+ }
+ }
+
}