portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r412929 - in /portals/jetspeed-2/trunk/applications: demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm gems/pom.xml gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
Date Fri, 09 Jun 2006 05:02:16 GMT
Author: taylor
Date: Thu Jun  8 22:02:15 2006
New Revision: 412929

URL: http://svn.apache.org/viewvc?rev=412929&view=rev
Log:
update to google maps portlet from Jonathan Phillips
Should now work on the desktop

Modified:
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
    portals/jetspeed-2/trunk/applications/gems/pom.xml
    portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm?rev=412929&r1=412928&r2=412929&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
(original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/other/googlemaps/GoogleMaps.vm
Thu Jun  8 22:02:15 2006
@@ -1,6 +1,7 @@
 <script language="JavaScript" type="text/javascript">
+	loc = escape("$renderRequest.getPreferences().getValue('Location','')");
 	dojo.io.bind({
-		url: "$renderRequest.getScheme():\/\/$renderRequest.getServerName():$renderRequest.getServerPort()$renderRequest.getContextPath()\/yahoogeocode?location=$renderRequest.getPreferences().getValue('Location','')",
+		url: "$renderRequest.getScheme():\/\/$renderRequest.getServerName():$renderRequest.getServerPort()$renderRequest.getContextPath()\/yahoogeocode?location="
+ loc,
 		mimetype: "text/xml",
 		error: function(type, error){
 			top.alert("error");
@@ -22,15 +23,5 @@
 	}
 </script>
 <div id="map" style="width: 500px; height: 300px"></div>
-
-
-
-
-
-
-
-
-
-
 
 

Modified: portals/jetspeed-2/trunk/applications/gems/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/pom.xml?rev=412929&r1=412928&r2=412929&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/pom.xml (original)
+++ portals/jetspeed-2/trunk/applications/gems/pom.xml Thu Jun  8 22:02:15 2006
@@ -65,7 +65,10 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+        </dependency>
     </dependencies>
 
     <!-- Project Information -->

Modified: portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java?rev=412929&r1=412928&r2=412929&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
Thu Jun  8 22:02:15 2006
@@ -1,98 +1,90 @@
-/* Copyright 2004 Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.gems.googlemaps;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.HttpException;
-
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * YahooGeocodeProxyServlet
- * 
- * 
- * @author jonathan david phillips
- * @version $Id: YahooGeocodeProxyServlet.java 000001 2006-04-25 00:57:00Z jdp $
- */
-
-public class YahooGeocodeProxyServlet extends HttpServlet
-{
-    /**
-     * Configuration 
-     */
-     private static final String YAHOO_REQUEST = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location=";
-
-    /**
-     * doGet() override doGet
-     */
-     protected void doGet(HttpServletRequest req, HttpServletResponse resp)
-		throws ServletException, java.io.IOException {
-		String location = req.getParameter("location");
-		String url = YAHOO_REQUEST + location;
-		String content = "<error/>";
-		
-		// get content from yahoo, code from http://jakarta.apache.org/commons/httpclient/tutorial.html
-		HttpClient client = new HttpClient();
-		GetMethod method = new GetMethod(url);
-		method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, 
-    			new DefaultHttpMethodRetryHandler(3, false));
-		try {
-			int statusCode = client.executeMethod(method);
-			if (statusCode != HttpStatus.SC_OK) {
-				System.err.println("Method failed: " + method.getStatusLine());
-			}
-			// set content
-			content = method.getResponseBodyAsString();
-
-		} catch (HttpException e) {
-			System.err.println("Fatal protocol violation: " + e.getMessage());
-			e.printStackTrace();
-		} catch (IOException e) {
-			System.err.println("Fatal transport error: " + e.getMessage());
-			e.printStackTrace();
-		} finally {
-			method.releaseConnection();
-		}
-					
-		//  return content
-		resp.setContentType("text/xml");
-		PrintWriter out = resp.getWriter();
-		out.print(content);
-		out.close();
-	}
-}
-
-
-
-
-
-
-
-
-
-
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.googlemaps;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URLEncoder;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpException;
+
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * YahooGeocodeProxyServlet
+ * 
+ * 
+ * @author jonathan david phillips
+ * @version $Id: YahooGeocodeProxyServlet.java 000001 2006-04-25 00:57:00Z jdp $
+ */
+
+public class YahooGeocodeProxyServlet extends HttpServlet
+{
+    /**
+     * Configuration 
+     */
+     private static final String YAHOO_REQUEST = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location=";
+
+    /**
+     * doGet() override doGet
+     */
+     protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+		throws ServletException, java.io.IOException {
+		String location = req.getParameter("location");
+		location = URLEncoder.encode(location,"UTF-8");
+		String url = YAHOO_REQUEST + location;
+		String content = "<error/>";
+		
+		// get content from yahoo, code from http://jakarta.apache.org/commons/httpclient/tutorial.html
+		HttpClient client = new HttpClient();
+		GetMethod method = new GetMethod(url);
+		method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, 
+    			new DefaultHttpMethodRetryHandler(3, false));
+		try {
+			int statusCode = client.executeMethod(method);
+			if (statusCode != HttpStatus.SC_OK) {
+				System.err.println("Method failed: " + method.getStatusLine());
+			}
+			// set content
+			content = method.getResponseBodyAsString();
+
+		} catch (HttpException e) {
+			System.err.println("Fatal protocol violation: " + e.getMessage());
+			e.printStackTrace();
+		} catch (IOException e) {
+			System.err.println("Fatal transport error: " + e.getMessage());
+			e.printStackTrace();
+		} finally {
+			method.releaseConnection();
+		}
+					
+		//  return content
+		resp.setContentType("text/xml");
+		PrintWriter out = resp.getWriter();
+		out.print(content);
+		out.close();
+	}
+}
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message