Project

General

Profile

1 2678 harris
<!--
2
  *   '$RCSfile$'
3
  *   '$Author$'
4
  *   '$Date$'
5
  *   '$Revision$'
6
  *
7
  *
8
  * This program is free software; you can redistribute it and/or modify
9
  * it under the terms of the GNU General Public License as published by
10
  * the Free Software Foundation; either version 2 of the License, or
11
  * (at your option) any later version.
12
  *
13
  * This program is distributed in the hope that it will be useful,
14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
  * GNU General Public License for more details.
17
  *
18
  * You should have received a copy of the GNU General Public License
19
  * along with this program; if not, write to the Free Software
20
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
-->
22
23
<%@ page import="org.apache.tools.mail.MailMessage" %>
24
<%@ page import="java.io.PrintStream" %>
25
<%@ page import="java.io.BufferedReader" %>
26
<%@ page import="java.util.StringTokenizer" %>
27
<%@ page import="java.io.InputStreamReader" %>
28
<%@ page import="java.net.URLConnection" %>
29
<%@ page import="java.net.URL" %>
30
31
32
<%
33
    System.out.println("********************************************************");
34
    System.out.println("********************************************************");
35
    System.out.println("**************** metacat_spatialresolver.jsp*****************\n");
36
37
38 2699 harris
    String _request = request.getParameter("REQUEST");
39
    _request = (_request!=null)? _request.trim() : "";
40 2678 harris
41 2699 harris
  	System.out.println("uri: >>" + request.getRequestURI());
42
	  System.out.println("request string: >>" + request.getQueryString()+" \n");
43 2678 harris
44
45 2699 harris
	// connect to the metacat spatial option, request the info using the wms getFeatureId call
46
  // parse the response for the url to the metacat document and then redirect there. The query
47
  // should look like
48
  // VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-143.09099999999998,19.856,-96.79899999999999,43.002&WIDTH=600&HEIGHT=300&LAYERS=topp:RIVERS&FORMAT=text/html&FEATURE_COUNT=1&QUERY_LAYERS=topp:RIVERS&X=328&Y=218
49
50
  if ( request.getQueryString().indexOf("metacat_testdata") > -1 ) {
51
  URL url = new URL("http://nebulous.msi.ucsb.edu:8080/geoserver/wms?"+request.getQueryString());
52 2678 harris
	URLConnection c = url.openConnection();
53
	BufferedReader in = new BufferedReader(
54
                                new InputStreamReader(
55
                                c.getInputStream()));
56
        String inputLine;
57
58
        while ((inputLine = in.readLine()) != null)
59
60
			if ( inputLine.startsWith("url") ) {
61
62
				StringTokenizer _st = new StringTokenizer(inputLine, " ");
63
				_st.nextToken(); // url string
64
				_st.nextToken(); // equals sign
65
				String _redirectTo = _st.nextToken();
66
				System.out.println("redirecting to: " + _redirectTo);
67
				response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
68
				String newLocn = _redirectTo;
69
				response.setHeader("Location",newLocn);
70
			}
71
        in.close();
72 2699 harris
	} else {
73
    System.out.println(" -- not a metacat query");
74
    String _url = "http://sulphur.homelinux.com:9999/geoserver/wms?"+ request.getQueryString();
75
76
    System.out.println("redirecting to: " + _url);
77
    response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
78
    response.setHeader("Location",_url);
79 2678 harris
80 2699 harris
  }
81
82 2678 harris
%>
83
84
<html>
85
<head>
86
<title>Metacat Spatial Resolver</title>
87
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
88
<link href="styles.css" rel="stylesheet" type="text/css">
89
</head>
90
91
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/blue_pixel_bg.jpg">
92
<table width="100%" border="0" cellspacing="0" cellpadding="0">
93
  <!--DWLayoutTable-->
94
  <tr>
95
          <td  width="700" height="20" background="images/blue_pixel_bg.jpg"></td>
96
97
  </tr>
98
99
100
101
102
  <tr>
103
    <td bgcolor="#6699CC"> <table width="700" border="0" cellspacing="0" cellpadding="0">
104
        <tr>
105
          <td>&nbsp;</td>
106
          <td><td>&nbsp;</td>
107
        </tr>
108
      </table>
109
  </tr>
110
</table>
111
</body>
112
</html>