1 /*
2 * $Id: Register.java,v 1.6 2006/10/17 10:11:41 clq2 Exp $
3 */
4
5 package org.astrogrid.dataservice.service.servlet;
6 import org.astrogrid.webapp.*;
7
8 import java.io.IOException;
9 import java.io.Writer;
10 import java.net.URL;
11 import javax.servlet.ServletException;
12 import javax.servlet.http.HttpServletRequest;
13 import javax.servlet.http.HttpServletResponse;
14 import org.apache.commons.logging.LogFactory;
15 import org.astrogrid.cfg.ConfigFactory;
16 import org.astrogrid.dataservice.metadata.VoDescriptionServer;
17 import org.astrogrid.dataservice.service.ServletHelper;
18 import org.astrogrid.registry.client.RegistryDelegateFactory;
19 //import org.astrogrid.registry.client.DelegateProperties;
20 import org.astrogrid.registry.client.query.RegistryService;
21 import org.astrogrid.dataservice.metadata.v0_10.VoResourceSupport;
22
23 import org.w3c.dom.Document;
24 import org.astrogrid.xml.DomHelper;
25
26 /***
27 * Calling this servlet sends the registry entry to the configured Registry
28 *
29 * @author mch
30 */
31 public class Register extends DefaultServlet {
32
33 public void doGet(HttpServletRequest request,
34 HttpServletResponse response) throws ServletException, IOException {
35
36 try {
37 String regParam = request.getParameter("RegistryUrl");
38 if ((regParam == null) || (regParam.trim().length()==0)) {
39 //regParam = ConfigFactory.getCommonConfig().getString(DelegateProperties.ADMIN_URL_PROPERTY);
40 regParam = ConfigFactory.getCommonConfig().getString(RegistryDelegateFactory.ADMIN_URL_PROPERTY);
41 }
42 /*
43 // KEA TOFIX COMPLETE THIS REGISTRY CHECK IN BRANCH FOLLOWING
44 // PAL_KEA_1716
45 // Check the status of the Authority ID in the publishing registry.
46 // If it doesn't exist, we need to create it.
47 // If it does exist, it needs to be managed by the publishing
48 // registry and not some other registry.
49
50 // Need to look for ivorn 'ivo://{authID}/authority'
51 // If it exists, this ivorn needs to have the ivo-id attribute
52 // in the <managingOrg> tag set to the same ivorn, e.g.
53 // <managingOrg ivo-id="ivo://{authID}/authority">blah</managingOrg>
54 String authIDIvorn = VoResourceSupport.makeAuthorityId();
55 System.out.println("AUTH ID IS " + authIDIvorn);
56 authIDIvorn = "ivo://org.astrogrid.test1+authority";
57 System.out.println("AUTH ID IS NOW " + authIDIvorn);
58
59 //String publishRegQuery = regParam.
60 //URL publishRegistry = new URL(regParam);
61
62 RegistryService service =
63 RegistryDelegateFactory.createQuery();
64 Document registration = service.getResourceByIdentifier(authIDIvorn);
65 System.out.println("REG AUTH ID IS :");
66 System.out.println(DomHelper.DocumentToString(registration));
67 */
68
69 VoDescriptionServer.pushToRegistry(new URL(regParam));
70
71 //submit query - and return just the query ID
72 response.setContentType("text/plain");
73 Writer w = response.getWriter();
74 w.write(regParam);
75 }
76 catch (Throwable th) {
77 LogFactory.getLog(request.getContextPath()).error(th+" Registering",th);
78 doError(response, "Registering",th);
79 }
80 }
81
82 }