comparison artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java @ 79:f69e5b87f05f

Implementation to export artifacts as xml (applied patch from issue208 by SLT). artifacts/trunk@792 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 16 Mar 2010 16:03:06 +0000
parents 48d1a9a082c2
children d348fe1fd822
comparison
equal deleted inserted replaced
78:55eefe63a777 79:f69e5b87f05f
8 8
9 import org.apache.log4j.Logger; 9 import org.apache.log4j.Logger;
10 10
11 import org.w3c.dom.Document; 11 import org.w3c.dom.Document;
12 import org.w3c.dom.NodeList; 12 import org.w3c.dom.NodeList;
13
13 /** 14 /**
14 * Bootstrap facility for the global context and the artifact factories. 15 * Bootstrap facility for the global context and the artifact factories.
15 * 16 *
16 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> 17 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
17 */ 18 */
29 "/artifact-database/factories/artifact-factories/artifact-factory"; 30 "/artifact-database/factories/artifact-factories/artifact-factory";
30 31
31 public static final String SERVICE_FACTORIES = 32 public static final String SERVICE_FACTORIES =
32 "/artifact-database/factories/service-factories/service-factory"; 33 "/artifact-database/factories/service-factories/service-factory";
33 34
35 public static final String EXPORT_SECRET =
36 "/artifact-database/export-secret/text()";
37
38 public static final String DEFAULT_EXORT_SECRET =
39 "!!!CHANGE ME! I'M NO SECRET!!!";
40
34 protected Object context; 41 protected Object context;
35 42
36 protected ArtifactFactory [] artifactFactories; 43 protected ArtifactFactory [] artifactFactories;
37 44
38 protected ServiceFactory [] serviceFactories; 45 protected ServiceFactory [] serviceFactories;
46
47 protected byte [] exportSecret;
48
39 49
40 public FactoryBootstrap() { 50 public FactoryBootstrap() {
41 } 51 }
42 52
43 void buildContext() { 53 void buildContext() {
165 175
166 serviceFactories = (ServiceFactory [])loadedFactories.toArray( 176 serviceFactories = (ServiceFactory [])loadedFactories.toArray(
167 new ServiceFactory[loadedFactories.size()]); 177 new ServiceFactory[loadedFactories.size()]);
168 } 178 }
169 179
180 protected void setupExportSecret() {
181 String secret = Config.getStringXPath(EXPORT_SECRET);
182
183 if (secret == null) {
184 logger.warn("NO EXPORT SECRET SET! USING INSECURE DEFAULT!");
185 secret = DEFAULT_EXORT_SECRET;
186 }
187
188 exportSecret = StringUtils.getUTF8Bytes(secret);
189 }
190
170 public void boot() { 191 public void boot() {
192 setupExportSecret();
171 buildContext(); 193 buildContext();
172 loadArtifactFactories(); 194 loadArtifactFactories();
173 loadServiceFactories(); 195 loadServiceFactories();
174 } 196 }
175 197
182 } 204 }
183 205
184 public Object getContext() { 206 public Object getContext() {
185 return context; 207 return context;
186 } 208 }
209
210 public byte [] getExportSecret() {
211 return exportSecret;
212 }
187 } 213 }
188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: 214 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org