Return-Path: Delivered-To: apmail-portals-jetspeed-dev-archive@www.apache.org Received: (qmail 62260 invoked from network); 9 Jun 2006 05:02:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jun 2006 05:02:40 -0000 Received: (qmail 14240 invoked by uid 500); 9 Jun 2006 05:02:39 -0000 Delivered-To: apmail-portals-jetspeed-dev-archive@portals.apache.org Received: (qmail 13827 invoked by uid 500); 9 Jun 2006 05:02:38 -0000 Mailing-List: contact jetspeed-dev-help@portals.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@portals.apache.org Received: (qmail 13816 invoked by uid 99); 9 Jun 2006 05:02:38 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 22:02:38 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 22:02:37 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D20441A983A; Thu, 8 Jun 2006 22:02:16 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: jetspeed-dev@portals.apache.org From: taylor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060609050216.D20441A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@
- - - - - - - - - - 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 @@ commons-logging commons-logging - + + commons-httpclient + commons-httpclient + 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 = ""; - - // 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 = ""; + + // 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