1 | package org.greenstone.gsdl3.service;
|
---|
2 |
|
---|
3 | import org.w3c.dom.Document;
|
---|
4 | import org.w3c.dom.Node;
|
---|
5 | import org.w3c.dom.Element;
|
---|
6 | import org.w3c.dom.Text;
|
---|
7 |
|
---|
8 | /** PhindService - the phind phrase browsing service
|
---|
9 | *
|
---|
10 | */
|
---|
11 | public class PhindService
|
---|
12 | extends ServiceModule {
|
---|
13 |
|
---|
14 |
|
---|
15 | protected Element processService(String name, Element request) {
|
---|
16 |
|
---|
17 | if (!name.equals("PhindPhraseBrowse")) {
|
---|
18 | System.err.println("PhindService:you have asked for a non-existant service - "+name+"!");
|
---|
19 | return null;
|
---|
20 | }
|
---|
21 | // create dummy response
|
---|
22 | Element res = doc_.createElement("response");
|
---|
23 | res.setAttribute("from", "PhindPhraseBrowse");
|
---|
24 | Element data = doc_.createElement("content");
|
---|
25 | Text t = doc_.createTextNode("this is the results for a phind request");
|
---|
26 | data.appendChild(t);
|
---|
27 |
|
---|
28 | res.appendChild(data);
|
---|
29 |
|
---|
30 | return res;
|
---|
31 |
|
---|
32 | }
|
---|
33 | /** configure the service module
|
---|
34 | *
|
---|
35 | * @param info a DOM Element containing any config info for the service
|
---|
36 | * @return true if configured
|
---|
37 | */
|
---|
38 | public boolean configure(Element info) {
|
---|
39 |
|
---|
40 | System.out.println("configuring PhindService");
|
---|
41 |
|
---|
42 | // set up short_service_info_ - for now just has name and type
|
---|
43 | Element e = doc_.createElement("service");
|
---|
44 | e.setAttribute("type", "query");
|
---|
45 | e.setAttribute("name", "PhindPhraseBrowse");
|
---|
46 | short_service_info_.appendChild(e);
|
---|
47 |
|
---|
48 | // set up service_info_map_ - we only have one element, and it has
|
---|
49 | // no extra info yet - we are not processing the config info
|
---|
50 | Element f = doc_.createElement("service");
|
---|
51 | f.setAttribute("type", "query");
|
---|
52 | f.setAttribute("name", "PhindPhraseBrowse");
|
---|
53 | service_info_map_.put("PhindPhraseBrowse", f);
|
---|
54 |
|
---|
55 | return true;
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | }
|
---|