source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/RSSAction.java@ 27087

Last change on this file since 27087 was 27087, checked in by ak19, 11 years ago

Implemented RSS support for GS3. At present, can see this with a=rss in the url, when a collection is built. Soon will have a button (at least for the GS3 demo collection).

File size: 2.2 KB
Line 
1package org.greenstone.gsdl3.action;
2
3import org.greenstone.gsdl3.util.*;
4
5// XML classes
6import org.w3c.dom.Node;
7import org.w3c.dom.Element;
8
9// other java stuff
10import java.util.*;
11
12import java.io.Serializable;
13
14import java.io.PrintWriter;
15import java.io.Serializable;
16import java.io.StringWriter;
17
18import org.apache.log4j.*;
19
20public 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}
Note: See TracBrowser for help on using the repository browser.