Revision 4080
Added by daigle about 16 years ago
SldFactory.java | ||
---|---|---|
38 | 38 |
package edu.ucsb.nceas.metacat.spatial; |
39 | 39 |
|
40 | 40 |
import edu.ucsb.nceas.utilities.XMLUtilities; |
41 |
import edu.ucsb.nceas.metacat.MetaCatUtil;
|
|
41 |
import edu.ucsb.nceas.metacat.util.SystemUtil;
|
|
42 | 42 |
|
43 | 43 |
import javax.servlet.ServletConfig; |
44 | 44 |
import javax.servlet.ServletContext; |
... | ... | |
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
/** |
105 |
* Control servlet response depending on the action parameter specified |
|
106 |
* Modifies the original SLD according to various access contraints |
|
107 |
* and sends it as the servlet response. |
|
108 |
* |
|
109 |
* @param request Incoming servlet request. |
|
110 |
* @param response Servlet response. |
|
111 |
*/ |
|
112 |
private void handleGetOrPost(HttpServletRequest request, HttpServletResponse response) |
|
113 |
throws ServletException, IOException |
|
114 |
{ |
|
115 |
String dataset = request.getParameter("originalSld"); |
|
116 |
String filename = MetaCatUtil.getOption("certPath") + "data/styles/" + dataset; |
|
117 |
try { |
|
118 |
String sld = getSld(filename); |
|
119 |
System.out.println(sld); |
|
120 |
response.setContentType("text/xml"); |
|
121 |
response.getWriter().write(sld); |
|
122 |
} catch (FileNotFoundException fnf) { |
|
123 |
fnf.printStackTrace(); |
|
124 |
} catch (Exception e) { |
|
125 |
e.printStackTrace(); |
|
126 |
} |
|
127 |
|
|
128 |
} |
|
105 |
* Control servlet response depending on the action parameter specified |
|
106 |
* Modifies the original SLD according to various access contraints and |
|
107 |
* sends it as the servlet response. |
|
108 |
* |
|
109 |
* @param request |
|
110 |
* Incoming servlet request. |
|
111 |
* @param response |
|
112 |
* Servlet response. |
|
113 |
*/ |
|
114 |
private void handleGetOrPost(HttpServletRequest request, HttpServletResponse response) |
|
115 |
throws ServletException, IOException { |
|
116 |
String dataset = request.getParameter("originalSld"); |
|
117 |
|
|
118 |
try { |
|
119 |
String certPath = SystemUtil.getContextDir(); |
|
120 |
String filename = certPath + "data/styles/" + dataset; |
|
121 |
String sld = getSld(filename); |
|
122 |
System.out.println(sld); |
|
123 |
response.setContentType("text/xml"); |
|
124 |
response.getWriter().write(sld); |
|
125 |
} catch (FileNotFoundException fnf) { |
|
126 |
fnf.printStackTrace(); |
|
127 |
} catch (Exception e) { |
|
128 |
e.printStackTrace(); |
|
129 |
} |
|
130 |
|
|
131 |
} |
|
129 | 132 |
|
130 | 133 |
/** |
131 |
* Given a filename of an existing SLD document,
|
|
132 |
* reads the sld and adds an ogc:Filter to exclude/include
|
|
133 |
* certain docids based on user's permissions.
|
|
134 |
* The sld file is specified without path and
|
|
135 |
* must exist within geoserver's styles folder (context/data/styles/*)
|
|
136 |
*
|
|
137 |
* returns SLD document as a String.
|
|
138 |
*
|
|
139 |
* @param filename Filename of the base sld.
|
|
140 |
* @todo Implement the doc id list queries for contraints.
|
|
141 |
*/
|
|
134 |
* Given a filename of an existing SLD document, reads the sld and adds an
|
|
135 |
* ogc:Filter to exclude/include certain docids based on user's permissions.
|
|
136 |
* The sld file is specified without path and must exist within geoserver's
|
|
137 |
* styles folder (context/data/styles/*)
|
|
138 |
*
|
|
139 |
* returns SLD document as a String.
|
|
140 |
*
|
|
141 |
* @param filename
|
|
142 |
* Filename of the base sld.
|
|
143 |
* @todo Implement the doc id list queries for contraints.
|
|
144 |
*/
|
|
142 | 145 |
private String getSld(String filename) throws FileNotFoundException |
143 | 146 |
{ |
144 | 147 |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
Also available in: Unified diff
Merge 1.9 changes into Head