From 564d8aa92e6835c633dd26d3c459ebbc23f87060 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2012 15:17:55 -0700 Subject: [PATCH 1/2] fix the failed java unit test related to getBlob. --- .../blob/implementation/BlobRestProxy.java | 22 +++++++++++-------- .../core/utils/pipeline/PipelineHelpers.java | 14 +++++++++--- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 5bba95ef4599c..861cd21f3672f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -2,15 +2,15 @@ * Copyright 2011 Microsoft Corporation * * 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 + * 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. + * 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 com.microsoft.windowsazure.services.blob.implementation; @@ -122,6 +122,10 @@ private void ThrowIfError(ClientResponse r) { PipelineHelpers.ThrowIfError(r); } + private void ThrowIfNotSuccess(ClientResponse clientResponse) { + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + } + private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { return PipelineHelpers.addOptionalQueryParam(webResource, key, value); } @@ -630,7 +634,7 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); + ThrowIfNotSuccess(response); GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response); GetBlobResult blobResult = new GetBlobResult(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java index a36de8dc02476..21b95538f6e11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java @@ -27,9 +27,17 @@ import com.sun.jersey.api.client.WebResource.Builder; public class PipelineHelpers { - public static void ThrowIfError(ClientResponse r) { - if (r.getStatus() >= 400) { - throw new UniformInterfaceException(r); + public static void ThrowIfNotSuccess(ClientResponse clientResponse) { + int statusCode = clientResponse.getStatus(); + + if ((statusCode < 200) || (statusCode >= 300)) { + throw new UniformInterfaceException(clientResponse); + } + } + + public static void ThrowIfError(ClientResponse clientResponse) { + if (clientResponse.getStatus() >= 400) { + throw new UniformInterfaceException(clientResponse); } } From f338598b11d7fadde72deaa2b5319efbda00ed95 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 5 Apr 2012 17:34:13 -0700 Subject: [PATCH 2/2] Fix issue #217 Table: QueryTablesOptions.Query not fully used. --- .../table/implementation/TableRestProxy.java | 20 ++----------------- .../table/models/QueryTablesOptions.java | 10 ---------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java index 604f51149d596..ce6c5e34a1fce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java @@ -380,8 +380,7 @@ public QueryTablesResult queryTables() throws ServiceException { @Override public QueryTablesResult queryTables(QueryTablesOptions options) throws ServiceException { - - Query query = options.getQuery(); + Query query = new Query(); String nextTableName = options.getNextTableName(); String prefix = options.getPrefix(); @@ -389,22 +388,7 @@ public QueryTablesResult queryTables(QueryTablesOptions options) throws ServiceE // Append Max char to end '{' is 1 + 'z' in AsciiTable ==> upperBound is prefix + '{' Filter prefixFilter = Filter.and(Filter.ge(Filter.litteral("TableName"), Filter.constant(prefix)), Filter.le(Filter.litteral("TableName"), Filter.constant(prefix + "{"))); - - // a new query is needed if prefix alone is passed in - if (query == null) { - query = new Query(); - } - - // examine the existing filter on the query - if (query.getFilter() == null) { - // use the prefix filter if the query filter is null - query.setFilter(prefixFilter); - } - else { - // combine and use the prefix filter if the query filter exists - Filter combinedFilter = Filter.and(query.getFilter(), prefixFilter); - query.setFilter(combinedFilter); - } + query.setFilter(prefixFilter); } WebResource webResource = getResource(options).path("Tables"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java index 36b975d7a6900..f115f9ed52d8f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java @@ -16,18 +16,8 @@ public class QueryTablesOptions extends TableServiceOptions { private String nextTableName; - private Query query; private String prefix; - public Query getQuery() { - return query; - } - - public QueryTablesOptions setQuery(Query query) { - this.query = query; - return this; - } - public String getNextTableName() { return nextTableName; }