1 | /*
|
---|
2 | * PhindService.java
|
---|
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 | package org.greenstone.gsdl3.service;
|
---|
20 |
|
---|
21 | import org.w3c.dom.Document;
|
---|
22 | import org.w3c.dom.Node;
|
---|
23 | import org.w3c.dom.Element;
|
---|
24 | import org.w3c.dom.Text;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * PhindService - the phind phrase browsing service
|
---|
28 | *
|
---|
29 | * @author <a href="mailto:[email protected]">Katherine Don</a>
|
---|
30 | * @version $Revision: 3342 $
|
---|
31 | */
|
---|
32 | public class PhindService
|
---|
33 | extends ServiceModule {
|
---|
34 |
|
---|
35 |
|
---|
36 | protected Element processService(String name, Element request) {
|
---|
37 |
|
---|
38 | if (!name.equals("PhindBrowse")) {
|
---|
39 | System.err.println("PhindService:you have asked for a non-existant service - "+name+"!");
|
---|
40 | return null;
|
---|
41 | }
|
---|
42 | // create dummy response
|
---|
43 | Element res = doc_.createElement("response");
|
---|
44 | res.setAttribute("from", "PhindBrowse");
|
---|
45 | Element data = doc_.createElement("content");
|
---|
46 | Text t = doc_.createTextNode("this is the results for a phind request");
|
---|
47 | data.appendChild(t);
|
---|
48 |
|
---|
49 | res.appendChild(data);
|
---|
50 |
|
---|
51 | return res;
|
---|
52 |
|
---|
53 | }
|
---|
54 | /** configure the service module
|
---|
55 | *
|
---|
56 | * @param info a DOM Element containing any config info for the service
|
---|
57 | * @return true if configured
|
---|
58 | */
|
---|
59 | public boolean configure(Element info) {
|
---|
60 |
|
---|
61 | System.out.println("configuring PhindService");
|
---|
62 |
|
---|
63 | // set up short_service_info_ - for now just has name and type
|
---|
64 | Element e = doc_.createElement("service");
|
---|
65 | e.setAttribute("type", "query");
|
---|
66 | e.setAttribute("name", "PhindBrowse");
|
---|
67 | short_service_info_.appendChild(e);
|
---|
68 |
|
---|
69 | // set up service_info_map_ - we only have one element, and it has
|
---|
70 | // no extra info yet - we are not processing the config info
|
---|
71 | Element f = doc_.createElement("service");
|
---|
72 | f.setAttribute("type", "query");
|
---|
73 | f.setAttribute("name", "PhindBrowse");
|
---|
74 | service_info_map_.put("PhindBrowse", f);
|
---|
75 |
|
---|
76 | return true;
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | }
|
---|