From bf1c8cc094a3e2a4d0a53facfeecbf5eb282d9b9 Mon Sep 17 00:00:00 2001 From: Gerwin Gsenger Date: Wed, 21 Jan 2015 13:34:07 +0100 Subject: add javadoc --- .../commons/db/ConfigurationFromDBExtractor.java | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'id/server/moa-id-commons/src/main/java/at/gv') 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 78cd8a670..394c9cdeb 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 @@ -16,11 +16,28 @@ 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 getSingleValue(String queryString, Class clazz) { T result = null; EntityManager session = ConfigurationDBUtils.getCurrentSession(); @@ -33,6 +50,16 @@ public class ConfigurationFromDBExtractor { 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 List getListOfValues(String queryString, Class clazz) { List result = new ArrayList(); EntityManager session = ConfigurationDBUtils.getCurrentSession(); @@ -45,46 +72,107 @@ public class ConfigurationFromDBExtractor { 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 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 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); -- cgit v1.2.3