Skip to content

Commit

Permalink
Merge pull request #40 from gcheng/dev-bookmark
Browse files Browse the repository at this point in the history
fix the failed java unit test related to getBlob.
  • Loading branch information
Albert Cheng committed Apr 6, 2012
2 parents bb5fbed + f338598 commit e629c80
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,31 +383,15 @@ 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();

if (prefix != null) {
// 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e629c80

Please sign in to comment.