Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 6 issues in table service layer #27

Merged
merged 18 commits into from
Apr 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
2012.01.31. Version 0.1.3
2012.02.28 Version 0.2.0
* Added Support for Azure Table in com.microsoft.windowsazure.services.table
* Added Client Tests for Table
* Added a dependency on apache commons-lang3 3.1
* ResultsSegment exposes an ArrayList instead of an Iterable
* UserAgent updated to v1.1.2

2012.01.31 Version 0.1.3
* Updated User Agent to v0.1.1
* Updated License Headers
* Blob Client Mark bug fix
Expand All @@ -8,7 +15,7 @@
* Date parsing support for various number of fractional decimals
* StorageErrorResponse updated to support lower case xml for tables

2011.12.22. Version 0.1.2
2011.12.22 Version 0.1.2
* Fixed CloudBlob.download to lock to ETag during a resume
* Ensured that Client Side Exceptions are not resumed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Windows Azure Java Developer Center</a></p>
<h3>Option 1: Via Git</h3>
<p>To get the source code of the SDK via git just type:<br/>
<pre>git clone git://github.com/WindowsAzure/azure-sdk-for-java.git
cd ./azure-sdk-for-java
cd ./azure-sdk-for-java/microsoft-azure-api
mvn compile</pre>

<h3>Option 2: Via Maven</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ public void createQueue(String queue) throws ServiceException {
}

public void createQueue(String queue, CreateQueueOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue);

WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION);
Expand All @@ -165,6 +168,9 @@ public void deleteQueue(String queue) throws ServiceException {
}

public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue);

WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION);
Expand Down Expand Up @@ -195,6 +201,9 @@ public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceExcep
}

public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).queryParam("comp", "metadata");

Builder builder = webResource.header("x-ms-version", API_VERSION);
Expand All @@ -216,6 +225,9 @@ public void setQueueMetadata(String queue, HashMap<String, String> metadata) thr

public void setQueueMetadata(String queue, HashMap<String, String> metadata, QueueServiceOptions options)
throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).queryParam("comp", "metadata");

WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION);
Expand All @@ -229,6 +241,9 @@ public void createMessage(String queue, String messageText) throws ServiceExcept
}

public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).path("messages");
webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds());
webResource = addOptionalQueryParam(webResource, "messagettl", options.getTimeToLiveInSeconds());
Expand All @@ -249,6 +264,11 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String

public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText,
int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();
if (messageId == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).path("messages").path(messageId);
webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt);
webResource = addOptionalQueryParam(webResource, "visibilitytimeout", visibilityTimeoutInSeconds);
Expand All @@ -272,6 +292,9 @@ public ListMessagesResult listMessages(String queue) throws ServiceException {
}

public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).path("messages");
webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds());
webResource = addOptionalQueryParam(webResource, "numofmessages", options.getNumberOfMessages());
Expand All @@ -286,6 +309,9 @@ public PeekMessagesResult peekMessages(String queue) throws ServiceException {
}

public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).path("messages").queryParam("peekonly", "true");
webResource = addOptionalQueryParam(webResource, "numofmessages", options.getNumberOfMessages());

Expand All @@ -300,6 +326,11 @@ public void deleteMessage(String queue, String messageId, String popReceipt) thr

public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options)
throws ServiceException {
if (queue == null)
throw new NullPointerException();
if (messageId == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).path("messages").path(messageId);
webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt);

Expand All @@ -313,6 +344,9 @@ public void clearMessages(String queue) throws ServiceException {
}

public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(queue).path("messages");

Builder builder = webResource.header("x-ms-version", API_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter;
import com.microsoft.windowsazure.services.table.EdmValueConverter;
import com.microsoft.windowsazure.services.table.models.EdmType;
import com.sun.jersey.core.util.Base64;

public class DefaultEdmValueConterter implements EdmValueConverter {

Expand All @@ -41,6 +42,9 @@ public String serialize(String edmType, Object value) {
if (value instanceof Date) {
serializedValue = iso8601DateConverter.shortFormat((Date) value);
}
else if (value instanceof byte[]) {
serializedValue = new String(Base64.encode((byte[]) value));
}
else {
serializedValue = value.toString();
}
Expand Down Expand Up @@ -73,6 +77,9 @@ else if (EdmType.INT32.equals(edmType)) {
else if (EdmType.INT64.equals(edmType)) {
return Long.parseLong(value);
}
else if (EdmType.BINARY.equals(edmType)) {
return Base64.decode(value);
}

return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ private WebResource.Builder addIfMatchHeader(WebResource.Builder builder, String

private WebResource getResource(TableServiceOptions options) {
WebResource webResource = channel.resource(url).path("/");
webResource = addOptionalQueryParam(webResource, "timeout", options.getTimeout());
for (ServiceFilter filter : filters) {
webResource.addFilter(new ClientFilterAdapter(filter));
}
Expand Down Expand Up @@ -282,6 +281,9 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser
@Override
public void setServiceProperties(ServiceProperties serviceProperties, TableServiceOptions options)
throws ServiceException {
if (serviceProperties == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path("/").queryParam("resType", "service")
.queryParam("comp", "properties");

Expand All @@ -297,6 +299,9 @@ public GetTableResult getTable(String table) throws ServiceException {

@Override
public GetTableResult getTable(String table, TableServiceOptions options) throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path("Tables" + "('" + table + "')");

WebResource.Builder builder = webResource.getRequestBuilder();
Expand Down Expand Up @@ -369,6 +374,9 @@ public void createTable(String table) throws ServiceException {

@Override
public void createTable(String table, TableServiceOptions options) throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path("Tables");

WebResource.Builder builder = webResource.getRequestBuilder();
Expand All @@ -387,6 +395,9 @@ public void deleteTable(String table) throws ServiceException {

@Override
public void deleteTable(String table, TableServiceOptions options) throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path("Tables" + "('" + table + "')");

WebResource.Builder builder = webResource.getRequestBuilder();
Expand All @@ -405,6 +416,9 @@ public InsertEntityResult insertEntity(String table, Entity entity) throws Servi
@Override
public InsertEntityResult insertEntity(String table, Entity entity, TableServiceOptions options)
throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(table);

WebResource.Builder builder = webResource.getRequestBuilder();
Expand Down Expand Up @@ -434,7 +448,7 @@ public UpdateEntityResult updateEntity(String table, Entity entity, TableService

@Override
public UpdateEntityResult mergeEntity(String table, Entity entity) throws ServiceException {
return updateEntity(table, entity, new TableServiceOptions());
return mergeEntity(table, entity, new TableServiceOptions());
}

@Override
Expand All @@ -456,7 +470,7 @@ public UpdateEntityResult insertOrReplaceEntity(String table, Entity entity, Tab

@Override
public UpdateEntityResult insertOrMergeEntity(String table, Entity entity) throws ServiceException {
return insertOrReplaceEntity(table, entity, new TableServiceOptions());
return insertOrMergeEntity(table, entity, new TableServiceOptions());
}

@Override
Expand All @@ -467,6 +481,9 @@ public UpdateEntityResult insertOrMergeEntity(String table, Entity entity, Table

private UpdateEntityResult putOrMergeEntityCore(String table, Entity entity, String verb, boolean includeEtag,
TableServiceOptions options) throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(
getEntityPath(table, entity.getPartitionKey(), entity.getRowKey()));

Expand Down Expand Up @@ -499,6 +516,9 @@ public void deleteEntity(String table, String partitionKey, String rowKey) throw
@Override
public void deleteEntity(String table, String partitionKey, String rowKey, DeleteEntityOptions options)
throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(getEntityPath(table, partitionKey, rowKey));

WebResource.Builder builder = webResource.getRequestBuilder();
Expand All @@ -517,6 +537,9 @@ public GetEntityResult getEntity(String table, String partitionKey, String rowKe
@Override
public GetEntityResult getEntity(String table, String partitionKey, String rowKey, TableServiceOptions options)
throws ServiceException {
if (table == null)
throw new NullPointerException();

WebResource webResource = getResource(options).path(getEntityPath(table, partitionKey, rowKey));

WebResource.Builder builder = webResource.getRequestBuilder();
Expand All @@ -538,6 +561,11 @@ public QueryEntitiesResult queryEntities(String table) throws ServiceException {

@Override
public QueryEntitiesResult queryEntities(String table, QueryEntitiesOptions options) throws ServiceException {
if (table == null)
throw new NullPointerException();
if (options == null)
options = new QueryEntitiesOptions();

WebResource webResource = getResource(options).path(table);
webResource = addOptionalQuery(webResource, options.getQuery());
webResource = addOptionalQueryParam(webResource, "NextPartitionKey",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
public class DeleteEntityOptions extends TableServiceOptions {
private String etag;

@Override
public DeleteEntityOptions setTimeout(Integer timeout) {
super.setTimeout(timeout);
return this;
}

public String getEtag() {
return etag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ public class QueryEntitiesOptions extends TableServiceOptions {
public String nextPartitionKey;
public String nextRowKey;

@Override
public QueryEntitiesOptions setTimeout(Integer timeout) {
super.setTimeout(timeout);
return this;
}

public Query getQuery() {
return query;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ public class QueryTablesOptions extends TableServiceOptions {
private Query query;
private String prefix;

@Override
public QueryTablesOptions setTimeout(Integer timeout) {
super.setTimeout(timeout);
return this;
}

public Query getQuery() {
return query;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public void setMetrics(Metrics metrics) {

public static class Logging {
private String version;
private Boolean delete;
private Boolean read;
private Boolean write;
private boolean delete;
private boolean read;
private boolean write;
private RetentionPolicy retentionPolicy;

@XmlElement(name = "RetentionPolicy")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,4 @@
package com.microsoft.windowsazure.services.table.models;

public class TableServiceOptions {
// Nullable because it is optional
private Integer timeout;

public Integer getTimeout() {
return timeout;
}

public TableServiceOptions setTimeout(Integer timeout) {
this.timeout = timeout;
return this;
}
}
Loading