diff options
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java')
-rw-r--r-- | id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java index 442ff6247..2d652d748 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java @@ -1,28 +1,28 @@ package at.gv.egovernment.moa.id.commons.config.persistence; -import java.util.Arrays; import java.util.List; import java.util.Properties; -import javax.persistence.EntityExistsException; +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.stereotype.Component; import at.gv.egiz.components.configuration.api.Configuration; +import at.gv.egiz.components.configuration.api.ConfigurationException; +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +import at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty; import at.gv.egovernment.moa.id.commons.db.dao.config.ConfigPropertyDaoImpl; +import at.gv.egovernment.moa.logging.Logger; /** * The implementation of a key-value configuration implementing the {@link Configuration} interface. * It employs the {@link ConfigPropertyDao} to persist configuration data. */ @Component -public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOAIDConfiguration { - - private final Logger log = LoggerFactory.getLogger(getClass()); - +public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOAIDConfiguration { + Configuration configPropertyDao; // private JsonMapper mapper = new JsonMapper(); @@ -39,13 +39,47 @@ public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOA /* (non-Javadoc) * @see at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration#getPropertySubset(java.lang.String) */ - @Override - public Properties getPropertySubset(String preFix) { + public Properties getPropertySubset(String preFix) throws ConfigurationException{ // TODO Auto-generated method stub return null; } - + @Override + public Properties getOnlineApplication(String publicURLPrefix) + throws ConfigurationException { + EntityManager em = this.getPersistenceContext(); + if (null == em) { + Logger.error("No EntityManager set!"); + throw new ConfigurationException("No EntityManager set!"); + + } + + String keyId = MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES + + ".%." + + MOAIDConfigurationConstants.SERVICE_UNIQUEIDENTIFIER; + TypedQuery<ConfigProperty> query = em.createQuery("select * from ConfigProperty dbconfig where dbconfig.key like :key and dbconfig.value = SUBSTRING(:uniqueID, 1, LENGTH(dbconfig.value))", ConfigProperty.class); + query.setParameter("key", keyId); + query.setParameter("uniqueID", publicURLPrefix); + List<ConfigProperty> result = query.getResultList(); + + if (result.size() == 0) { + Logger.debug("No entries found."); + return null; + } + + if (result.size() > 1) { + Logger.warn("OAIdentifier match to more then one DB-entry!"); + return null; + } + + String oaKey = result.get(0).getKey(); + String oaValue = result.get(0).getValue(); + Logger.trace("Find online application with uniqueID: " + oaValue + " and keyID: " + oaKey); + + + + return null; + } /** * Small helper method. NOTE: may return empty properties, but never {@code null}. * @param propPrefix the prefix of the desired property. |