1 package org.astrogrid.portal.utils.acting;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 import javax.xml.parsers.ParserConfigurationException;
7
8 import org.apache.avalon.framework.parameters.Parameters;
9 import org.apache.cocoon.environment.Request;
10 import org.apache.cocoon.environment.Session;
11 import org.astrogrid.common.creator.CreatorException;
12 import org.w3c.dom.Element;
13 import org.xml.sax.SAXException;
14
15 /***
16 * @author peter.shillan <mailto:gps@roe.ac.uk />
17 */
18 public interface ActionUtils {
19 /***
20 * Get a request parameter given a parameter passed into the action via the sitemap.
21 *
22 * @param sitemapParam sitemap given parameter whose value is the request parameter name
23 * @param defaultValue default value of request parameter name
24 * @param params sitemap parameters
25 * @param request request context object
26 *
27 * @return value of request parameter
28 */
29 public String getRequestParameter(String sitemapParam, String defaultValue, Parameters params, Request request);
30
31 /***
32 * @see ActionUtils#getRequestParameter(String, String, Parameters, Request)
33 */
34 public String getRequestParameter(String sitemapParam, Parameters params, Request request);
35
36 /***
37 * Get a session attribute given a attribute passed into the action via the sitemap.
38 *
39 * @param sitemapParam sitemap given attribute whose value is the session attribute name
40 * @param defaultValue default value of session attribute name
41 * @param params sitemap parameters
42 * @param session session context object
43 *
44 * @return value of session attribute
45 */
46 public String getSessionAttribute(String sitemapParam, String defaultValue, Parameters params, Session session);
47
48 /***
49 * @see ActionUtils#getSessionAttribute(String, String, Parameters, Session)
50 */
51 public String getSessionAttribute(String sitemapParam, Parameters params, Session session);
52
53 /***
54 * Get a session object given a attribute passed into the action via the sitemap.
55 *
56 * @param sitemapParam sitemap given attribute whose value is the session attribute name
57 * @param defaultValue default value of session attribute name
58 * @param params sitemap parameters
59 * @param session session context object
60 *
61 * @return value of session object
62 */
63 public Object getSessionObject(String sitemapParam, String defaultValue, Parameters params, Session session);
64
65 /***
66 * @see ActionUtils#getSessionObject(String, String, Parameters, Session)
67 */
68 public Object getSessionObject(String sitemapParam, Parameters params, Session session);
69
70 public String getAnyParameter(String sitemapParam, Parameters params, Request request, Session session);
71 public String getAnyParameter(String sitemapParam, String defaultValue, Parameters params, Request request, Session session);
72
73 public Object getAnyParameterObject(String sitemapParam, Parameters params, Request request, Session session);
74 public Object getAnyParameterObject(String sitemapParam, String defaultValue, Parameters params, Request request, Session session);
75
76 /***
77 * @see ActionUtils#getNewObject(String, String, Parameters, Object[])
78 */
79 public Object getNewObject(String sitemapParam, Parameters params, Request request, List args) throws CreatorException;
80 /***
81 * Get a new instance of a class name given in the sitemap parameters.
82 *
83 * @see org.astrogrid.common.creator.Creator
84 *
85 * @param sitemapParam sitemap parameter containing the class name
86 * @param defaultClassName default class name to use
87 * @param params sitemap parameters
88 * @param request request context object
89 * @param args constructor arguments
90 *
91 * @return new instance
92 */
93 public Object getNewObject(String sitemapParam, String defaultClassName, Parameters params, Request request, List args) throws CreatorException;
94 public Element getDomElement(String adql) throws ParserConfigurationException, SAXException, IOException;
95 public ValidationHandler validate(String xml);
96 public boolean shouldValidate(String xml);
97 public boolean shouldBeNSAware(String xml);
98 }