Skip to content
This repository
Browse code

Merge pull request #40 from gcheng/dev-bookmark

fix the failed java unit test related to getBlob.
  • Loading branch information...
commit e629c80c09bbc886150befec84166d39a7acec67 2 parents bb5fbed + f338598
Albert Cheng authored April 05, 2012
22  ...osoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java
@@ -2,15 +2,15 @@
2 2
  * Copyright 2011 Microsoft Corporation
3 3
  * 
4 4
  * Licensed under the Apache License, Version 2.0 (the "License");
5  
- *  you may not use this file except in compliance with the License.
6  
- *  You may obtain a copy of the License at
7  
- *    http://www.apache.org/licenses/LICENSE-2.0
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ * http://www.apache.org/licenses/LICENSE-2.0
8 8
  * 
9  
- *  Unless required by applicable law or agreed to in writing, software
10  
- *  distributed under the License is distributed on an "AS IS" BASIS,
11  
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  
- *  See the License for the specific language governing permissions and
13  
- *  limitations under the License.
  9
+ * Unless required by applicable law or agreed to in writing, software
  10
+ * distributed under the License is distributed on an "AS IS" BASIS,
  11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12
+ * See the License for the specific language governing permissions and
  13
+ * limitations under the License.
14 14
  */
15 15
 package com.microsoft.windowsazure.services.blob.implementation;
16 16
 
@@ -122,6 +122,10 @@ private void ThrowIfError(ClientResponse r) {
122 122
         PipelineHelpers.ThrowIfError(r);
123 123
     }
124 124
 
  125
+    private void ThrowIfNotSuccess(ClientResponse clientResponse) {
  126
+        PipelineHelpers.ThrowIfNotSuccess(clientResponse);
  127
+    }
  128
+
125 129
     private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) {
126 130
         return PipelineHelpers.addOptionalQueryParam(webResource, key, value);
127 131
     }
@@ -630,7 +634,7 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio
630 634
         builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition());
631 635
 
632 636
         ClientResponse response = builder.get(ClientResponse.class);
633  
-        ThrowIfError(response);
  637
+        ThrowIfNotSuccess(response);
634 638
 
635 639
         GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response);
636 640
         GetBlobResult blobResult = new GetBlobResult();
14  ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java
@@ -27,9 +27,17 @@
27 27
 import com.sun.jersey.api.client.WebResource.Builder;
28 28
 
29 29
 public class PipelineHelpers {
30  
-    public static void ThrowIfError(ClientResponse r) {
31  
-        if (r.getStatus() >= 400) {
32  
-            throw new UniformInterfaceException(r);
  30
+    public static void ThrowIfNotSuccess(ClientResponse clientResponse) {
  31
+        int statusCode = clientResponse.getStatus();
  32
+
  33
+        if ((statusCode < 200) || (statusCode >= 300)) {
  34
+            throw new UniformInterfaceException(clientResponse);
  35
+        }
  36
+    }
  37
+
  38
+    public static void ThrowIfError(ClientResponse clientResponse) {
  39
+        if (clientResponse.getStatus() >= 400) {
  40
+            throw new UniformInterfaceException(clientResponse);
33 41
         }
34 42
     }
35 43
 
20  ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java
@@ -383,8 +383,7 @@ public QueryTablesResult queryTables() throws ServiceException {
383 383
 
384 384
     @Override
385 385
     public QueryTablesResult queryTables(QueryTablesOptions options) throws ServiceException {
386  
-
387  
-        Query query = options.getQuery();
  386
+        Query query = new Query();
388 387
         String nextTableName = options.getNextTableName();
389 388
         String prefix = options.getPrefix();
390 389
 
@@ -392,22 +391,7 @@ public QueryTablesResult queryTables(QueryTablesOptions options) throws ServiceE
392 391
             // Append Max char to end '{' is 1 + 'z' in AsciiTable ==> upperBound is prefix + '{'
393 392
             Filter prefixFilter = Filter.and(Filter.ge(Filter.litteral("TableName"), Filter.constant(prefix)),
394 393
                     Filter.le(Filter.litteral("TableName"), Filter.constant(prefix + "{")));
395  
-
396  
-            // a new query is needed if prefix alone is passed in
397  
-            if (query == null) {
398  
-                query = new Query();
399  
-            }
400  
-
401  
-            // examine the existing filter on the query
402  
-            if (query.getFilter() == null) {
403  
-                // use the prefix filter if the query filter is null
404  
-                query.setFilter(prefixFilter);
405  
-            }
406  
-            else {
407  
-                // combine and use the prefix filter if the query filter exists
408  
-                Filter combinedFilter = Filter.and(query.getFilter(), prefixFilter);
409  
-                query.setFilter(combinedFilter);
410  
-            }
  394
+            query.setFilter(prefixFilter);
411 395
         }
412 396
 
413 397
         WebResource webResource = getResource(options).path("Tables");
10  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java
@@ -16,18 +16,8 @@
16 16
 
17 17
 public class QueryTablesOptions extends TableServiceOptions {
18 18
     private String nextTableName;
19  
-    private Query query;
20 19
     private String prefix;
21 20
 
22  
-    public Query getQuery() {
23  
-        return query;
24  
-    }
25  
-
26  
-    public QueryTablesOptions setQuery(Query query) {
27  
-        this.query = query;
28  
-        return this;
29  
-    }
30  
-
31 21
     public String getNextTableName() {
32 22
         return nextTableName;
33 23
     }

0 notes on commit e629c80

Please sign in to comment.
Something went wrong with that request. Please try again.