1
2
3
4
5
6
7 package org.astrogrid.datacenter.queriers.test;
8
9 import java.io.IOException;
10 import java.net.URL;
11 import org.astrogrid.config.Config;
12 import org.astrogrid.config.ConfigException;
13 import org.astrogrid.config.SimpleConfig;
14 import org.astrogrid.datacenter.metadata.AuthorityConfigPlugin;
15 import org.astrogrid.datacenter.metadata.CeaResourceServer;
16 import org.astrogrid.datacenter.metadata.FileResourcePlugin;
17 import org.astrogrid.datacenter.metadata.VoResourcePlugin;
18 import org.astrogrid.datacenter.queriers.QuerierPluginFactory;
19 import org.astrogrid.datacenter.queriers.sql.TabularSkyServicePlugin;
20
21 /***
22 * A special file-serving metadata server; it checks that the SampleStarsPlugin
23 * is the current plugin and throws an exception if not, so that we don't get
24 * incompatible metadata vs plugin
25 * <p>
26 * @author M Hill
27 */
28
29 public class SampleStarsMetaServer extends FileResourcePlugin
30 {
31 /*** Returns a URL to the metadata file */
32 public URL[] getResourceUrls() throws IOException {
33
34
35 String pluginClass = SimpleConfig.getSingleton().getString(QuerierPluginFactory.QUERIER_PLUGIN_KEY);
36 String sampleStarsClass = SampleStarsPlugin.class.getName();
37 if (!pluginClass.equals(SampleStarsPlugin.class.getName())) {
38 throw new ConfigException("Server is configured to return sample stars metadata but the plugin is "+pluginClass);
39 }
40
41 URL url = SampleStarsMetaServer.class.getResource("samplestars.metadata.xml");
42 if (url == null) {
43
44 url = Config.resolveFilename("samplestars.metadata.xml");
45 }
46 return new URL[] { url };
47 }
48
49 /***
50 * Initialises config so that authority ID, etc are set
51 */
52 public static void initConfig() {
53
54
55
56
57
58 SimpleConfig.getSingleton().setProperties(VoResourcePlugin.RESOURCE_PLUGIN_KEY, new Object[] {
59 AuthorityConfigPlugin.class.getName(),
60 SampleStarsMetaServer.class.getName(),
61 TabularSkyServicePlugin.class.getName(),
62 CeaResourceServer.class.getName()
63 });
64
65
66
67 SimpleConfig.setProperty("datacenter.name", "SampleStars AstroGrid Datacenter");
68 SimpleConfig.setProperty("datacenter.shortname", "PAL-Sample");
69 SimpleConfig.setProperty("datacenter.publisher", "AstroGrid");
70 SimpleConfig.setProperty("datacenter.description", "An unconfigured datacenter; it contains two tables of sample stars and galaxies for testing and demonstration purposes.");
71 SimpleConfig.setProperty("datacenter.contact.name", "Martin Hill");
72 SimpleConfig.setProperty("datacenter.contact.email", "mch@roe.ac.uk");
73
74 SimpleConfig.setProperty("datacenter.authorityId", "astrogrid.org");
75 SimpleConfig.setProperty("datacenter.resourceKey", "pal-sample");
76
77 }
78
79 }
80
81