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

Last change on this file since 28964 was 28964, checked in by kjdon, 10 years ago

nodeToElement now in GSXML. Some param changes for a few GSXML methods

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