[9874] | 1 | /*
|
---|
[10322] | 2 | * SOAPServer.java.in: a template for a new SOAPServer
|
---|
[9874] | 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 | */
|
---|
[10285] | 19 |
|
---|
[9874] | 20 | package org.greenstone.gsdl3;
|
---|
| 21 |
|
---|
[10285] | 22 | import org.greenstone.gsdl3.core.MessageRouter;
|
---|
[22085] | 23 | import org.greenstone.util.GlobalProperties;
|
---|
[10123] | 24 | import org.greenstone.gsdl3.util.GSFile;
|
---|
[9874] | 25 | import org.greenstone.gsdl3.util.GSXML;
|
---|
[16688] | 26 | import org.greenstone.gsdl3.util.XMLConverter;
|
---|
[9874] | 27 | import org.w3c.dom.Element;
|
---|
[16688] | 28 | import org.w3c.dom.Node;
|
---|
[9874] | 29 | import java.io.File;
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | * The server side of a SOAP connection
|
---|
| 33 | *
|
---|
[25727] | 34 | * @author Katherine Don
|
---|
[9874] | 35 | * @see <a href="http://www.w3.org/TR/SOAP/">Simple Object Access Protocol (SOAP) 1.1 </a>
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | public class SOAPServerlocalsite
|
---|
| 39 | {
|
---|
[10322] | 40 |
|
---|
[10285] | 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";
|
---|
[16688] | 45 |
|
---|
[10285] | 46 | /** The no-args constructor */
|
---|
[9874] | 47 | public SOAPServerlocalsite() {
|
---|
[16688] | 48 |
|
---|
[10285] | 49 | String gsdl3_home = GlobalProperties.getGSDL3Home();
|
---|
[9874] | 50 | if (gsdl3_home == null || gsdl3_home.equals("")) {
|
---|
[10285] | 51 | System.err.println("Couldn't access GSDL3Home from GlobalProerties.getGSDL3HOME, can't initialize the SOAP Server.");
|
---|
[9874] | 52 | return;
|
---|
| 53 | }
|
---|
[10285] | 54 | String site_home = GSFile.siteHome(gsdl3_home, this.site_name);
|
---|
[9874] | 55 |
|
---|
| 56 | File site_file = new File(site_home);
|
---|
| 57 | if (!site_file.isDirectory()) {
|
---|
[10285] | 58 | System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialize the SOAP Server.");
|
---|
[9874] | 59 | return;
|
---|
| 60 | }
|
---|
[10285] | 61 | mr = new MessageRouter();
|
---|
| 62 | mr.setSiteName(this.site_name);
|
---|
| 63 | mr.configure();
|
---|
[9874] | 64 | }
|
---|
| 65 |
|
---|
[10322] | 66 |
|
---|
[10285] | 67 | public Element [] process (Element [] xml_in) {
|
---|
[9874] | 68 | Element [] result = new Element[xml_in.length];
|
---|
| 69 | for (int i=0; i<xml_in.length; i++) {
|
---|
| 70 | Element req = xml_in[i];
|
---|
| 71 | // get rid of the obligatory namespace that axis needs
|
---|
| 72 | String tag_name = req.getTagName();
|
---|
| 73 | String namespace="";
|
---|
| 74 | if (tag_name.indexOf(':')!= -1) {
|
---|
| 75 | namespace = tag_name.substring(0, tag_name.indexOf(':'));
|
---|
[10285] | 76 | tag_name = tag_name.substring(tag_name.indexOf(':')+1);
|
---|
[9874] | 77 | }
|
---|
[10285] | 78 | Element new_req = GSXML.duplicateWithNewName(req.getOwnerDocument(), req, tag_name, true);
|
---|
[16688] | 79 | Node n = mr.process(new_req);
|
---|
[28966] | 80 | Element r = GSXML.nodeToElement(n);
|
---|
[9874] | 81 | // add the namespace back on
|
---|
| 82 | //Element new_res = r;
|
---|
| 83 | //if (!namespace.equals("")) {
|
---|
| 84 | // new_res = GSXML.duplicateWithNewName(r.getOwnerDocument(), r, namespace+r.getTagName(), true);
|
---|
[10285] | 85 | //}
|
---|
[9874] | 86 | result[i] = r;
|
---|
| 87 | }
|
---|
| 88 | return result;
|
---|
[10322] | 89 | }
|
---|
[9874] | 90 | }
|
---|
| 91 |
|
---|