source: greenstone3/trunk/src/java/org/greenstone/gsdl3/SOAPServerlocalsite.java@ 16688

Last change on this file since 16688 was 16688, checked in by davidb, 16 years ago

Changed 'Element process(Element)' in ModuleInterface to 'Node process(Node)'. After some deliberation is was decided this is a more useful (generic) layer of the DOM to pass information around in. Helps with the DocType problem when producing XSL Transformed pages, for example. When this was an Element, it would loose track of its DocType. Supporting method provided in XMLConverter 'Element nodeToElement(Node)' which checks a nodes docType and casts to Element if appropriate, or if a Document, typecasts to that and then extracts the top-level Element. With this fundamental change in ModuleInterface, around 20 files needed to be updated (Actions, Services, etc) that build on top of 'process()' to reflect this change, and use nodeToElement where necessary.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/*
2 * SOAPServer.java.in: a template for a new SOAPServer
3 * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20package org.greenstone.gsdl3;
21
22import org.greenstone.gsdl3.core.MessageRouter;
23import org.greenstone.gsdl3.util.GlobalProperties;
24import org.greenstone.gsdl3.util.GSFile;
25import org.greenstone.gsdl3.util.GSXML;
26import org.greenstone.gsdl3.util.XMLConverter;
27import org.w3c.dom.Element;
28import org.w3c.dom.Node;
29import java.io.File;
30
31/**
32 * The server side of a SOAP connection
33 *
34 * @author <a href="mailto:[email protected]">Katherine Don</a>
35 * @see <a href="http://www.w3.org/TR/SOAP/">Simple Object Access Protocol (SOAP) 1.1 </a>
36 */
37
38public class SOAPServerlocalsite
39{
40
41 /** The message router we're talking to */
42 protected MessageRouter mr=null;
43 /** the name of the site we are serving */
44 protected String site_name = "localsite";
45
46 protected XMLConverter converter = null;
47
48 /** The no-args constructor */
49 public SOAPServerlocalsite() {
50
51 converter = new XMLConverter();
52
53 String gsdl3_home = GlobalProperties.getGSDL3Home();
54 if (gsdl3_home == null || gsdl3_home.equals("")) {
55 System.err.println("Couldn't access GSDL3Home from GlobalProerties.getGSDL3HOME, can't initialize the SOAP Server.");
56 return;
57 }
58 String site_home = GSFile.siteHome(gsdl3_home, this.site_name);
59
60 File site_file = new File(site_home);
61 if (!site_file.isDirectory()) {
62 System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialize the SOAP Server.");
63 return;
64 }
65 mr = new MessageRouter();
66 mr.setSiteName(this.site_name);
67 mr.configure();
68 }
69
70
71 public Element [] process (Element [] xml_in) {
72 Element [] result = new Element[xml_in.length];
73 for (int i=0; i<xml_in.length; i++) {
74 Element req = xml_in[i];
75 // get rid of the obligatory namespace that axis needs
76 String tag_name = req.getTagName();
77 String namespace="";
78 if (tag_name.indexOf(':')!= -1) {
79 namespace = tag_name.substring(0, tag_name.indexOf(':'));
80 tag_name = tag_name.substring(tag_name.indexOf(':')+1);
81 }
82 Element new_req = GSXML.duplicateWithNewName(req.getOwnerDocument(), req, tag_name, true);
83 Node n = mr.process(new_req);
84 Element r = converter.nodeToElement(n);
85 // add the namespace back on
86 //Element new_res = r;
87 //if (!namespace.equals("")) {
88 // new_res = GSXML.duplicateWithNewName(r.getOwnerDocument(), r, namespace+r.getTagName(), true);
89 //}
90 result[i] = r;
91 }
92 return result;
93 }
94}
95
Note: See TracBrowser for help on using the repository browser.