1 | package org.greenstone.gsdl3.action;
|
---|
2 |
|
---|
3 | import org.greenstone.gsdl3.util.*;
|
---|
4 |
|
---|
5 | // XML classes
|
---|
6 | import org.w3c.dom.Node;
|
---|
7 | import org.w3c.dom.Element;
|
---|
8 |
|
---|
9 | // other java stuff
|
---|
10 | import java.util.*;
|
---|
11 |
|
---|
12 | import java.io.Serializable;
|
---|
13 |
|
---|
14 | import java.io.PrintWriter;
|
---|
15 | import java.io.Serializable;
|
---|
16 | import java.io.StringWriter;
|
---|
17 |
|
---|
18 | import org.apache.log4j.*;
|
---|
19 |
|
---|
20 | public class RSSAction extends Action
|
---|
21 | {
|
---|
22 |
|
---|
23 | static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.RSSAction.class.getName());
|
---|
24 |
|
---|
25 | /** process a request */
|
---|
26 | public Node process(Node message_node)
|
---|
27 | {
|
---|
28 |
|
---|
29 | Element message = this.converter.nodeToElement(message_node);
|
---|
30 |
|
---|
31 | // assume only one request
|
---|
32 | Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
|
---|
33 |
|
---|
34 | UserContext userContext = new UserContext(request);
|
---|
35 | // get the param list
|
---|
36 | Element cgi_param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
|
---|
37 | HashMap<String, Serializable> params = GSXML.extractParams(cgi_param_list, false);
|
---|
38 |
|
---|
39 | String service_name = "RSSFeed"; // RSSFeed service of RSSRetrieve.java
|
---|
40 | String collection = (String) params.get(GSParams.COLLECTION);
|
---|
41 | String to = GSPath.prependLink(service_name, collection); // collection/RSSFeed
|
---|
42 |
|
---|
43 | // the first part of the response is the service description
|
---|
44 | // for now get this again from the service.
|
---|
45 | // this should be cached somehow later on.
|
---|
46 |
|
---|
47 | Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
|
---|
48 | Element rss_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
|
---|
49 | mr_request_message.appendChild(rss_request);
|
---|
50 |
|
---|
51 | Element rss_response = (Element) this.mr.process(mr_request_message);
|
---|
52 | rss_response = (Element) GSXML.getChildByTagName(rss_response, GSXML.RESPONSE_ELEM); // just the response tag
|
---|
53 | // NEED ERROR PROCESSING ?
|
---|
54 |
|
---|
55 | // siteMeta and interfaceOptions are unnecessary, as rss.xsl is going to remove it anyway
|
---|
56 | // but may be handy when doing o=xml to view the original xml as it came through from the GS server
|
---|
57 | addSiteMetadata(rss_response, userContext);
|
---|
58 | addInterfaceOptions(rss_response);
|
---|
59 |
|
---|
60 | Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
|
---|
61 | result.appendChild(this.doc.importNode(rss_response, true));
|
---|
62 | return result;
|
---|
63 |
|
---|
64 | }
|
---|
65 |
|
---|
66 | }
|
---|