aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java42
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java22
2 files changed, 53 insertions, 11 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java
index 90543e588..39225a5b0 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java
@@ -4,12 +4,16 @@ import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead;
import at.gv.egovernment.moa.id.config.ConfigurationException;
import at.gv.egovernment.moa.id.config.ConfigurationProvider;
@@ -33,6 +37,14 @@ public class ConfigurationToJSONConverter {
System.out.println("=====================================");
System.out.println("=====================================");
converter.readConfigFromDB();
+ System.out.println("=====================================");
+ System.out.println("=====================================");
+
+ // otherwise the database connection is not initialized
+ AuthConfigurationProvider.getInstance();
+ List<String> methodNames = Arrays.asList("getAllOnlineApplications", "getAllUsers", "getMOAIDConfiguration");
+ converter.extractDataViaConfigurationDBRead(methodNames);
+ converter.readExtractedConfigurationDBReadData(methodNames);
} catch (ConfigurationException e) {
e.printStackTrace();
@@ -51,6 +63,33 @@ public class ConfigurationToJSONConverter {
}
+ public void extractDataViaConfigurationDBRead(List<String> methodNames) {
+ System.out.println("Start extracting");
+ // read objects from db and write to key-value
+ for (String name : methodNames) {
+ try {
+ Method method = ConfigurationDBRead.class.getMethod(name);
+ Object tmp = method.invoke(null, new Object[] {});
+ JsonProperty annotation = method.getAnnotation(JsonProperty.class);
+ if (annotation != null) {
+ configDataBase.set(annotation.value(), tmp);
+ } else {
+ System.out.println("Annotate Method with name: " + name);
+ }
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException e) {
+ System.out.println("Problems while extracting ConfigurationDBRead data.");
+ }
+ }
+ }
+
+ public void readExtractedConfigurationDBReadData(List<String> methodNames) {
+ for (String name : methodNames) {
+ Object tmp = configDataBase.get(name);
+ System.out.println(">>> OBJECT: " + tmp);
+ }
+ }
+
public void writeConfigToJSONDB() {
try {
@@ -73,8 +112,7 @@ public class ConfigurationToJSONConverter {
System.out.println("CHECK if '" + pd.getDisplayName() + "' is NOT ANNOTATED");
}
} catch (IllegalAccessException | InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ System.out.println("Problems while writing the configuration to the database.");
}
}
}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
index 6efdd6223..f5421a47d 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
@@ -22,6 +22,15 @@
*******************************************************************************/
package at.gv.egovernment.moa.id.commons.db;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+
import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
@@ -29,15 +38,7 @@ import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.MiscUtil;
//import org.apache.commons.lang.StringEscapeUtils;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceException;
-
-import org.apache.commons.lang3.StringEscapeUtils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("rawtypes")
public class ConfigurationDBRead {
@@ -139,6 +140,7 @@ public class ConfigurationDBRead {
return (OnlineApplication) result.get(0);
}
+ @JsonProperty("getMOAIDConfiguration")
public static MOAIDConfiguration getMOAIDConfiguration() {
Logger.trace("Load MOAID Configuration from database.");
@@ -158,6 +160,7 @@ public class ConfigurationDBRead {
return (MOAIDConfiguration) result.get(0);
}
+ @JsonProperty("getAllOnlineApplications")
public static List<OnlineApplication> getAllOnlineApplications() {
Logger.trace("Get All OnlineApplications from database.");
@@ -194,6 +197,7 @@ public class ConfigurationDBRead {
return result;
}
+ @JsonProperty("getAllUsers")
public static List<UserDatabase> getAllUsers() {
Logger.trace("Get All OnlineApplications from database.");