aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java364
1 files changed, 182 insertions, 182 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
index f6066d68f..432991f33 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
@@ -1,182 +1,182 @@
-package at.gv.egovernment.moa.id.commons.db;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-
-import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
-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 com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * This class is used to extract information from a legacy moa-id database.
- */
-public class ConfigurationFromDBExtractor {
-
- /**
- * This class should not be instantiated.
- */
- private ConfigurationFromDBExtractor() {
- }
-
- /**
- * Helper method, to query for a single value. NOTE: returns {@code null} if
- * there is no result, more than one result or if an exception is thrown
- * while querying the database.
- *
- * @param queryString
- * a jpa query string.
- * @param clazz
- * the class type of the expected result.
- * @return the result of the query or {@code null}.
- */
- private static <T> T getSingleValue(String queryString, Class<T> clazz) {
- T result = null;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
- TypedQuery<T> query = session.createQuery(queryString, clazz);
- try {
- result = query.getSingleResult();
- } catch (Exception e) {
- return null;
- }
- return result;
- }
-
- /**
- * Helper method, to query for a a list of values. NOTE: the returned list
- * may be empty but is never {@code null}.
- *
- * @param queryString
- * a jpa query string.
- * @param clazz
- * the class type of the elements the expected result list.
- * @return a list with the result of the query or an empty list.
- */
- private static <T> List<T> getListOfValues(String queryString, Class<T> clazz) {
- List<T> result = new ArrayList<T>();
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
- TypedQuery<T> query = session.createQuery(queryString, clazz);
- try {
- result = query.getResultList();
- } catch (Exception e) {
- return new ArrayList<T>();
- }
- return result;
- }
-
- /**
- * Extracts an {@link AuthComponentGeneral} from the database. NOTE: returns
- * {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return an AuthComponentgeneral or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY)
- public static AuthComponentGeneral getAuthComponentGeneral() {
- return getSingleValue("from AuthComponentGeneral", AuthComponentGeneral.class);
- }
-
- /**
- * Extracts an {@link AuthComponentGeneral} from the database. NOTE: returns
- * {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return an AuthComponentgeneral or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.CHAINING_MODES_KEY)
- public static ChainingModes getChainingModes() {
- return (ChainingModes) getSingleValue("from ChainingModes", ChainingModes.class);
- }
-
- /**
- * Extracts a list of {@link OnlineApplication} from the database. NOTE: the
- * returned list may be empty but is never {@code null}.
- *
- * @return a list of {@link OnlineApplication}.
- */
- @JsonProperty(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY)
- public static List<OnlineApplication> getOnlineApplications() {
- return getListOfValues("from OnlineApplication", OnlineApplication.class);
- }
-
- /**
- * Extracts a list of {@link GenericConfiguration} from the database. NOTE:
- * the returned list may be empty but is never {@code null}.
- *
- * @return a list of {@link GenericConfiguration}.
- */
- @JsonProperty(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY)
- public static List<GenericConfiguration> getGenericConfigurations() {
- return getListOfValues("from GenericConfiguration", GenericConfiguration.class);
- }
-
- /**
- * Extracts the trusted CA-certificates from the database. NOTE: returns
- * {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return the trusted CA-certificates or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY)
- public static String getTrustedCACertificates() {
- return getSingleValue("select trustedCACertificates from MOAIDConfiguration", String.class);
- }
-
- /**
- * Extracts a {@link DefaultBKUs} from the database. NOTE: returns
- * {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return a DefaultBKUs or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY)
- public static DefaultBKUs getDefaultBKUs() {
- return getSingleValue("select defaultBKUs from MOAIDConfiguration", DefaultBKUs.class);
- }
-
- /**
- * Extracts a {@link SLRequestTemplates} from the database. NOTE: returns
- * {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return a SLRequestTemplates or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY)
- public static SLRequestTemplates getSLRequestTemplates() {
- return getSingleValue("select SLRequestTemplates from MOAIDConfiguration", SLRequestTemplates.class);
- }
-
- /**
- * Extracts the moa-id timestamp (last update) from the database. NOTE:
- * returns {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return the moa-id timestamp (last update) or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY)
- public static Date getTimeStampItem() {
- return getSingleValue("select timestampItem from MOAIDConfiguration", Date.class);
- }
-
- /**
- * Extracts the date of the last pvp2refresh from the database. NOTE:
- * returns {@code null} if there is no result, more than one result or if an
- * exception is thrown while querying the database.
- *
- * @return the date of the last pvp2refresh or {@code null}.
- */
- @JsonProperty(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY)
- public static Date getPvp2RefreshItem() {
- return getSingleValue("select pvp2RefreshItem from MOAIDConfiguration", Date.class);
- }
-
-}
+//package at.gv.egovernment.moa.id.commons.db;
+//
+//import java.util.ArrayList;
+//import java.util.Date;
+//import java.util.List;
+//
+//import javax.persistence.EntityManager;
+//import javax.persistence.TypedQuery;
+//
+//import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+//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 com.fasterxml.jackson.annotation.JsonProperty;
+//
+///**
+// * This class is used to extract information from a legacy moa-id database.
+// */
+//public class ConfigurationFromDBExtractor {
+//
+// /**
+// * This class should not be instantiated.
+// */
+// private ConfigurationFromDBExtractor() {
+// }
+//
+// /**
+// * Helper method, to query for a single value. NOTE: returns {@code null} if
+// * there is no result, more than one result or if an exception is thrown
+// * while querying the database.
+// *
+// * @param queryString
+// * a jpa query string.
+// * @param clazz
+// * the class type of the expected result.
+// * @return the result of the query or {@code null}.
+// */
+// private static <T> T getSingleValue(String queryString, Class<T> clazz) {
+// T result = null;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+// TypedQuery<T> query = session.createQuery(queryString, clazz);
+// try {
+// result = query.getSingleResult();
+// } catch (Exception e) {
+// return null;
+// }
+// return result;
+// }
+//
+// /**
+// * Helper method, to query for a a list of values. NOTE: the returned list
+// * may be empty but is never {@code null}.
+// *
+// * @param queryString
+// * a jpa query string.
+// * @param clazz
+// * the class type of the elements the expected result list.
+// * @return a list with the result of the query or an empty list.
+// */
+// private static <T> List<T> getListOfValues(String queryString, Class<T> clazz) {
+// List<T> result = new ArrayList<T>();
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+// TypedQuery<T> query = session.createQuery(queryString, clazz);
+// try {
+// result = query.getResultList();
+// } catch (Exception e) {
+// return new ArrayList<T>();
+// }
+// return result;
+// }
+//
+// /**
+// * Extracts an {@link AuthComponentGeneral} from the database. NOTE: returns
+// * {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return an AuthComponentgeneral or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY)
+// public static AuthComponentGeneral getAuthComponentGeneral() {
+// return getSingleValue("from AuthComponentGeneral", AuthComponentGeneral.class);
+// }
+//
+// /**
+// * Extracts an {@link AuthComponentGeneral} from the database. NOTE: returns
+// * {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return an AuthComponentgeneral or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.CHAINING_MODES_KEY)
+// public static ChainingModes getChainingModes() {
+// return (ChainingModes) getSingleValue("from ChainingModes", ChainingModes.class);
+// }
+//
+// /**
+// * Extracts a list of {@link OnlineApplication} from the database. NOTE: the
+// * returned list may be empty but is never {@code null}.
+// *
+// * @return a list of {@link OnlineApplication}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY)
+// public static List<OnlineApplication> getOnlineApplications() {
+// return getListOfValues("from OnlineApplication", OnlineApplication.class);
+// }
+//
+// /**
+// * Extracts a list of {@link GenericConfiguration} from the database. NOTE:
+// * the returned list may be empty but is never {@code null}.
+// *
+// * @return a list of {@link GenericConfiguration}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY)
+// public static List<GenericConfiguration> getGenericConfigurations() {
+// return getListOfValues("from GenericConfiguration", GenericConfiguration.class);
+// }
+//
+// /**
+// * Extracts the trusted CA-certificates from the database. NOTE: returns
+// * {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return the trusted CA-certificates or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY)
+// public static String getTrustedCACertificates() {
+// return getSingleValue("select trustedCACertificates from MOAIDConfiguration", String.class);
+// }
+//
+// /**
+// * Extracts a {@link DefaultBKUs} from the database. NOTE: returns
+// * {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return a DefaultBKUs or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY)
+// public static DefaultBKUs getDefaultBKUs() {
+// return getSingleValue("select defaultBKUs from MOAIDConfiguration", DefaultBKUs.class);
+// }
+//
+// /**
+// * Extracts a {@link SLRequestTemplates} from the database. NOTE: returns
+// * {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return a SLRequestTemplates or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY)
+// public static SLRequestTemplates getSLRequestTemplates() {
+// return getSingleValue("select SLRequestTemplates from MOAIDConfiguration", SLRequestTemplates.class);
+// }
+//
+// /**
+// * Extracts the moa-id timestamp (last update) from the database. NOTE:
+// * returns {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return the moa-id timestamp (last update) or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY)
+// public static Date getTimeStampItem() {
+// return getSingleValue("select timestampItem from MOAIDConfiguration", Date.class);
+// }
+//
+// /**
+// * Extracts the date of the last pvp2refresh from the database. NOTE:
+// * returns {@code null} if there is no result, more than one result or if an
+// * exception is thrown while querying the database.
+// *
+// * @return the date of the last pvp2refresh or {@code null}.
+// */
+// @JsonProperty(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY)
+// public static Date getPvp2RefreshItem() {
+// return getSingleValue("select pvp2RefreshItem from MOAIDConfiguration", Date.class);
+// }
+//
+//}