# HG changeset patch # User Ingo Weinzierl # Date 1299001506 0 # Node ID cee54e52000cdc17df1ea339372b8c70d083eb86 # Parent caf9f456f7e38562361c822ff5b9b08959d2f996 Added the registration of the UserFactory to the bootstrap process. artifacts/trunk@1349 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r caf9f456f7e3 -r cee54e52000c ChangeLog --- a/ChangeLog Tue Mar 01 17:43:16 2011 +0000 +++ b/ChangeLog Tue Mar 01 17:45:06 2011 +0000 @@ -1,3 +1,8 @@ +2011-03-01 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java: + Added the registration of the UserFactory to the bootstrap process. + 2011-03-01 Sascha L. Teichmann * artifact-database/src/main/resources/sql/org-h2-driver.properties, diff -r caf9f456f7e3 -r cee54e52000c artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Tue Mar 01 17:43:16 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Tue Mar 01 17:45:06 2011 +0000 @@ -11,6 +11,7 @@ import de.intevation.artifacts.ArtifactContextFactory; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.ServiceFactory; +import de.intevation.artifacts.UserFactory; import java.util.ArrayList; @@ -57,6 +58,19 @@ "/artifact-database/factories/service-factories/service-factory"; /** + * XPath to figure out the class name of the user factory from global + * configuration. + */ + public static final String USER_FACTORY = + "/artfifact-database/factories/user-factory/text()"; + + /** + * The name of the default user factory. + */ + public static final String DEFAULT_USER_FACTORY = + "de.intevation.artifactdatabase.DefaultUserFactory"; + + /** * XPath to figure out the secret used to sign the artifact exports * made by the artfifact database server. */ @@ -89,6 +103,11 @@ protected ServiceFactory [] serviceFactories; /** + * The factory that is used to create and list users. + */ + protected UserFactory userFactory; + + /** * byte array holding the export signing secret. */ protected byte [] exportSecret; @@ -237,6 +256,34 @@ new ServiceFactory[loadedFactories.size()]); } + + /** + * Scans the global configuration for the configured user factory. + */ + protected void loadUserFactory() { + logger.info("loading user factory"); + + String className = Config.getStringXPath( + USER_FACTORY, DEFAULT_USER_FACTORY); + + try { + Class clazz = Class.forName(className); + userFactory = (UserFactory) clazz.newInstance(); + } + catch (ClassNotFoundException cnfe) { + logger.error(cnfe.getLocalizedMessage(), cnfe); + } + catch (InstantiationException ie) { + logger.error(ie.getLocalizedMessage(), ie); + } + catch (ClassCastException cce) { + logger.error(cce.getLocalizedMessage(), cce); + } + catch (IllegalAccessException iae) { + logger.error(iae.getLocalizedMessage(), iae); + } + } + /** * Fetches the export signing secret from the global configuration. * If none is found if defaults to the DEFAULT_EXORT_SECRET which @@ -261,6 +308,7 @@ buildContext(); loadArtifactFactories(); loadServiceFactories(); + loadUserFactory(); } /**