View Javadoc

1   /*
2    * $Id: AuthorityConfigPlugin.java,v 1.8 2004/11/03 01:35:18 mch Exp $
3    *
4    * (C) Copyright Astrogrid...
5    */
6   
7   package org.astrogrid.datacenter.metadata;
8   
9   import java.io.IOException;
10  import java.io.StringWriter;
11  import java.util.Date;
12  import org.astrogrid.config.SimpleConfig;
13  import org.astrogrid.datacenter.service.AxisDataServer;
14  import org.astrogrid.datacenter.service.DataServer;
15  import org.astrogrid.io.xml.XmlPrinter;
16  import org.astrogrid.io.xml.XmlTagPrinter;
17  
18  /***
19   * Generates an Authority Resource from information stored in the configuration
20   * file
21   * <p>
22   * @author M Hill
23   */
24  
25  public class AuthorityConfigPlugin implements VoResourcePlugin {
26     
27     /***
28      * Returns an authority resource element, based on values in the configuration
29      * file
30      */
31     public String[] getVoResources() throws IOException {
32        StringWriter sw = new StringWriter();
33        
34        XmlPrinter resourceSnippet = new XmlPrinter(sw, false);
35        XmlTagPrinter authResource = resourceSnippet.newTag("Resource",
36              new String[] {
37                 "xsi:type='AuthorityType'",
38                 "status='active'",
39                 "updated='"+VoDescriptionServer.REGISTRY_DATEFORMAT.format(new Date())+"'"
40              });
41        XmlTagPrinter identifier = authResource.newTag("Identifier");
42        identifier.writeTag("AuthorityID", SimpleConfig.getSingleton().getString(VoDescriptionServer.AUTHID_KEY));
43        identifier.writeTag("ResourceKey", "authority");
44  
45        /*** This isn't right - it's submitting datacenter information as part of the organisation's information */
46        authResource.writeTag("Title", DataServer.getDatacenterName());
47        authResource.writeTag("ShortName", SimpleConfig.getSingleton().getString("datacenter.shortname", ""));
48        
49        XmlTagPrinter summary = authResource.newTag("Summary");
50        summary.writeTag("Description", SimpleConfig.getSingleton().getString("datacenter.description", ""));
51        summary.writeTag("ReferenceURL", SimpleConfig.getSingleton().getString("datacenter.url", ""));
52     
53        //VoDescriptionServer.writeCuration(authResource);
54  
55        resourceSnippet.close();
56        sw.close();
57        String s = sw.toString(); //so we can pause here with a breakpoint and see what it is
58        return new String[] { s };
59     }
60     
61  }
62  
63