From 50463b886bd5dcb4441fddc124a955647cbec99b Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 9 Mar 2012 13:30:50 -0800 Subject: [PATCH] Bug 734487 - Part 0. r=trivial --- .../android/base/sync/net/BaseResource.java | 59 +++++-------------- 1 file changed, 14 insertions(+), 45 deletions(-) diff --git a/mobile/android/base/sync/net/BaseResource.java b/mobile/android/base/sync/net/BaseResource.java index 53884ec4aa0..19786456080 100644 --- a/mobile/android/base/sync/net/BaseResource.java +++ b/mobile/android/base/sync/net/BaseResource.java @@ -1,39 +1,6 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Android Sync Client. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Richard Newman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.mozilla.gecko.sync.net; @@ -75,6 +42,8 @@ import ch.boye.httpclientandroidlib.params.HttpProtocolParams; import ch.boye.httpclientandroidlib.protocol.BasicHttpContext; import ch.boye.httpclientandroidlib.protocol.HttpContext; +import org.mozilla.gecko.sync.Logger; + /** * Provide simple HTTP access to a Sync server or similar. * Implements Basic Auth by asking its delegate for credentials. @@ -109,11 +78,11 @@ public class BaseResource implements Resource { public BaseResource(URI uri, boolean rewrite) { if (rewrite && uri.getHost().equals("localhost")) { // Rewrite localhost URIs to refer to the special Android emulator loopback passthrough interface. - Log.d(LOG_TAG, "Rewriting " + uri + " to point to " + ANDROID_LOOPBACK_IP + "."); + Logger.debug(LOG_TAG, "Rewriting " + uri + " to point to " + ANDROID_LOOPBACK_IP + "."); try { this.uri = new URI(uri.getScheme(), uri.getUserInfo(), ANDROID_LOOPBACK_IP, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { - Log.e(LOG_TAG, "Got error rewriting URI for Android emulator.", e); + Logger.error(LOG_TAG, "Got error rewriting URI for Android emulator.", e); } } else { this.uri = uri; @@ -204,7 +173,7 @@ public class BaseResource implements Resource { private void execute() { try { HttpResponse response = client.execute(request, context); - Log.i(LOG_TAG, "Response: " + response.getStatusLine().toString()); + Logger.debug(LOG_TAG, "Response: " + response.getStatusLine().toString()); delegate.handleHttpResponse(response); } catch (ClientProtocolException e) { delegate.handleHttpProtocolException(e); @@ -221,10 +190,10 @@ public class BaseResource implements Resource { try { this.prepareClient(); } catch (KeyManagementException e) { - Log.e(LOG_TAG, "Couldn't prepare client.", e); + Logger.error(LOG_TAG, "Couldn't prepare client.", e); delegate.handleTransportException(e); } catch (NoSuchAlgorithmException e) { - Log.e(LOG_TAG, "Couldn't prepare client.", e); + Logger.error(LOG_TAG, "Couldn't prepare client.", e); delegate.handleTransportException(e); } this.execute(); @@ -232,19 +201,19 @@ public class BaseResource implements Resource { @Override public void get() { - Log.i(LOG_TAG, "HTTP GET " + this.uri.toASCIIString()); + Logger.debug(LOG_TAG, "HTTP GET " + this.uri.toASCIIString()); this.go(new HttpGet(this.uri)); } @Override public void delete() { - Log.i(LOG_TAG, "HTTP DELETE " + this.uri.toASCIIString()); + Logger.debug(LOG_TAG, "HTTP DELETE " + this.uri.toASCIIString()); this.go(new HttpDelete(this.uri)); } @Override public void post(HttpEntity body) { - Log.i(LOG_TAG, "HTTP POST " + this.uri.toASCIIString()); + Logger.debug(LOG_TAG, "HTTP POST " + this.uri.toASCIIString()); HttpPost request = new HttpPost(this.uri); request.setEntity(body); this.go(request); @@ -252,7 +221,7 @@ public class BaseResource implements Resource { @Override public void put(HttpEntity body) { - Log.i(LOG_TAG, "HTTP PUT " + this.uri.toASCIIString()); + Logger.debug(LOG_TAG, "HTTP PUT " + this.uri.toASCIIString()); HttpPut request = new HttpPut(this.uri); request.setEntity(body); this.go(request);