From 3a65eab679db17ffe8d3c43cded12c09bc1ef870 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 17:12:02 -0800 Subject: [PATCH 01/29] Skeleton QueueService implementation --- .../services/queue/CreateMessageOptions.java | 22 +++ .../services/queue/CreateQueueOptions.java | 21 +++ .../queue/GetQueueMetadataResult.java | 24 +++ .../services/queue/ListMessagesOptions.java | 24 +++ .../services/queue/ListMessagesResult.java | 94 +++++++++++ .../services/queue/ListQueuesOptions.java | 46 +++++ .../services/queue/ListQueuesResult.java | 111 ++++++++++++ .../services/queue/PeekMessagesOptions.java | 14 ++ .../services/queue/PeekMessagesResult.java | 74 ++++++++ .../services/queue/QueueListingDetails.java | 36 ++++ .../azure/services/queue/QueueService.java | 64 +++++++ .../services/queue/QueueServiceOptions.java | 15 ++ .../services/queue/ServiceProperties.java | 158 ++++++++++++++++++ .../services/queue/UpdateMessageResult.java | 24 +++ 14 files changed, 727 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java new file mode 100644 index 0000000000000..a15c7850eba2f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java @@ -0,0 +1,22 @@ +package com.microsoft.azure.services.queue; + +public class CreateMessageOptions extends QueueServiceOptions { + private Integer visibilityTimeoutInSeconds; + private Integer timeToLiveInSeconds; + + public Integer getVisibilityTimeoutInSeconds() { + return visibilityTimeoutInSeconds; + } + + public void setVisibilityTimeoutInSeconds(Integer visibilityTimeoutInSeconds) { + this.visibilityTimeoutInSeconds = visibilityTimeoutInSeconds; + } + + public Integer getTimeToLiveInSeconds() { + return timeToLiveInSeconds; + } + + public void setTimeToLiveInSeconds(Integer timeToLiveInSeconds) { + this.timeToLiveInSeconds = timeToLiveInSeconds; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java new file mode 100644 index 0000000000000..1bc35cdaf16ea --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java @@ -0,0 +1,21 @@ +package com.microsoft.azure.services.queue; + +import java.util.HashMap; + +public class CreateQueueOptions extends QueueServiceOptions { + private HashMap metadata = new HashMap(); + + public HashMap getMetadata() { + return metadata; + } + + public CreateQueueOptions setMetadata(HashMap metadata) { + this.metadata = metadata; + return this; + } + + public CreateQueueOptions addMetadata(String key, String value) { + this.metadata.put(key, value); + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java new file mode 100644 index 0000000000000..1c382082ec4bd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.queue; + +import java.util.HashMap; + +public class GetQueueMetadataResult { + private long approximateMessageCount; + private HashMap metadata; + + public long getApproximateMessageCount() { + return approximateMessageCount; + } + + public void setApproximateMessageCount(long approximateMessageCount) { + this.approximateMessageCount = approximateMessageCount; + } + + public HashMap getMetadata() { + return metadata; + } + + public void setMetadata(HashMap metadata) { + this.metadata = metadata; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java new file mode 100644 index 0000000000000..167bef1fe09a8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.queue; + +public class ListMessagesOptions extends QueueServiceOptions { + private Integer numberOfMessages; + private Integer visibilityTimeoutInSeconds; + + public Integer getNumberOfMessages() { + return numberOfMessages; + } + + public ListMessagesOptions setNumberOfMessages(Integer numberOfMessages) { + this.numberOfMessages = numberOfMessages; + return this; + } + + public Integer getVisibilityTimeoutInSeconds() { + return visibilityTimeoutInSeconds; + } + + public ListMessagesOptions setVisibilityTimeoutInSeconds(Integer visibilityTimeoutInSeconds) { + this.visibilityTimeoutInSeconds = visibilityTimeoutInSeconds; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java new file mode 100644 index 0000000000000..91be63000d32d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java @@ -0,0 +1,94 @@ +package com.microsoft.azure.services.queue; + +import java.util.Date; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "QueueMessagesList") +public class ListMessagesResult { + private List messages; + + @XmlElement(name = "QueueMessage") + public List getMessages() { + return messages; + } + + public void setMessages(List messages) { + this.messages = messages; + } + + public static class QueueMessage { + private String id; + private Date insertionDate; + private Date expirationDate; + private String popReceipt; + private Date timeNextVisible; + private int dequeueCount; + private String text; + + @XmlElement(name = "MessageId") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlElement(name = "InsertionTime") + public Date getInsertionDate() { + return insertionDate; + } + + public void setInsertionDate(Date insertionDate) { + this.insertionDate = insertionDate; + } + + @XmlElement(name = "ExpirationTime") + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + @XmlElement(name = "PopReceipt") + public String getPopReceipt() { + return popReceipt; + } + + public void setPopReceipt(String popReceipt) { + this.popReceipt = popReceipt; + } + + @XmlElement(name = "TimeNextVisible") + public Date getTimeNextVisible() { + return timeNextVisible; + } + + public void setTimeNextVisible(Date timeNextVisible) { + this.timeNextVisible = timeNextVisible; + } + + @XmlElement(name = "DequeueCount") + public int getDequeueCount() { + return dequeueCount; + } + + public void setDequeueCount(int dequeueCount) { + this.dequeueCount = dequeueCount; + } + + @XmlElement(name = "MessageText") + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java new file mode 100644 index 0000000000000..abee05d8b4681 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java @@ -0,0 +1,46 @@ +package com.microsoft.azure.services.queue; + +import java.util.EnumSet; + +public class ListQueuesOptions extends QueueServiceOptions { + private String prefix; + private String marker; + private int maxResults; + private EnumSet listingDetails = EnumSet.noneOf(QueueListingDetails.class); + + public String getPrefix() { + return prefix; + } + + public ListQueuesOptions setPrefix(String prefix) { + this.prefix = prefix; + return this; + } + + public String getMarker() { + return marker; + } + + public ListQueuesOptions setMarker(String marker) { + this.marker = marker; + return this; + } + + public int getMaxResults() { + return maxResults; + } + + public ListQueuesOptions setMaxResults(int maxResults) { + this.maxResults = maxResults; + return this; + } + + public EnumSet getListingDetails() { + return listingDetails; + } + + public ListQueuesOptions setListingDetails(EnumSet listingDetails) { + this.listingDetails = listingDetails; + return this; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java new file mode 100644 index 0000000000000..3bdb611cee2ad --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java @@ -0,0 +1,111 @@ +package com.microsoft.azure.services.queue; + +import java.util.HashMap; +import java.util.List; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.azure.services.blob.implementation.MetadataAdapter; + +@XmlRootElement(name = "EnumerationResults") +public class ListQueuesResult { + private List queues; + private String accountName; + private String prefix; + private String marker; + private String nextMarker; + private int maxResults; + + @XmlElementWrapper(name = "Queues") + @XmlElement(name = "Queue") + public List getQueues() { + return queues; + } + + public void setQueues(List value) { + this.queues = value; + } + + @XmlAttribute(name = "AccountName") + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + @XmlElement(name = "Prefix") + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + @XmlElement(name = "Marker") + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + @XmlElement(name = "NextMarker") + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + @XmlElement(name = "MaxResults") + public int getMaxResults() { + return maxResults; + } + + public void setMaxResults(int maxResults) { + this.maxResults = maxResults; + } + + public static class Queue { + private String name; + private String url; + private HashMap metadata = new HashMap(); + + @XmlElement(name = "Name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElement(name = "Url") + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @XmlElement(name = "Metadata") + @XmlJavaTypeAdapter(MetadataAdapter.class) + public HashMap getMetadata() { + return metadata; + } + + public void setMetadata(HashMap metadata) { + this.metadata = metadata; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java new file mode 100644 index 0000000000000..56e310bfd3775 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java @@ -0,0 +1,14 @@ +package com.microsoft.azure.services.queue; + +public class PeekMessagesOptions extends QueueServiceOptions { + private Integer numberOfMessages; + + public Integer getNumberOfMessages() { + return numberOfMessages; + } + + public PeekMessagesOptions setNumberOfMessages(Integer numberOfMessages) { + this.numberOfMessages = numberOfMessages; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java new file mode 100644 index 0000000000000..00147241c6067 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java @@ -0,0 +1,74 @@ +package com.microsoft.azure.services.queue; + +import java.util.Date; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "QueueMessagesList") +public class PeekMessagesResult { + private List messages; + + @XmlElement(name = "QueueMessage") + public List getMessages() { + return messages; + } + + public void setMessages(List messages) { + this.messages = messages; + } + + public static class QueueMessage { + private String id; + private Date insertionDate; + private Date expirationDate; + private int dequeueCount; + private String text; + + @XmlElement(name = "MessageId") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlElement(name = "InsertionTime") + public Date getInsertionDate() { + return insertionDate; + } + + public void setInsertionDate(Date insertionDate) { + this.insertionDate = insertionDate; + } + + @XmlElement(name = "ExpirationTime") + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + @XmlElement(name = "DequeueCount") + public int getDequeueCount() { + return dequeueCount; + } + + public void setDequeueCount(int dequeueCount) { + this.dequeueCount = dequeueCount; + } + + @XmlElement(name = "MessageText") + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java new file mode 100644 index 0000000000000..9d12b14c61b17 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java @@ -0,0 +1,36 @@ +package com.microsoft.azure.services.queue; + +/** + * TODO: Make this a bool? + * + * Specifies which details to include when listing the containers in this + * storage account. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum QueueListingDetails { + /** + * Specifies including no additional details. + */ + NONE(0), + + /** + * Specifies including container metadata. + */ + METADATA(1); + + /** + * Returns the value of this enum. + */ + int value; + + /** + * Sets the value of this enum. + * + * @param val + * The value being assigned. + */ + QueueListingDetails(int val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java new file mode 100644 index 0000000000000..64930773e3c2d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java @@ -0,0 +1,64 @@ +package com.microsoft.azure.services.queue; + +import java.util.HashMap; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.http.ServiceFilter; + +public interface QueueService { + QueueService withFilter(ServiceFilter filter); + + ServiceProperties getServiceProperties() throws ServiceException; + + ServiceProperties getServiceProperties(ServiceProperties properties, QueueServiceOptions options) throws ServiceException; + + void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; + + void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException; + + void createQueue(String queue) throws ServiceException; + + void createQueue(String queue, CreateQueueOptions options) throws ServiceException; + + void deleteQueue(String queue) throws ServiceException; + + void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException; + + ListQueuesResult listQueues() throws ServiceException; + + ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException; + + GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException; + + GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException; + + void setQueueMetadata(String queue, HashMap metadata) throws ServiceException; + + void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException; + + void createMessage(String queue, String message) throws ServiceException; + + void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException; + + UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) throws ServiceException; + + UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds, QueueServiceOptions options) + throws ServiceException; + + ListMessagesResult listMessages(String queue) throws ServiceException; + + ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException; + + PeekMessagesResult peekMessages(String queue) throws ServiceException; + + PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException; + + void deleteMessage(String queue, String message, String popReceipt) throws ServiceException; + + void deleteMessage(String queue, String message, String popReceipt, QueueServiceOptions options) throws ServiceException; + + void clearMessages(String queue) throws ServiceException; + + void clearMessages(String queue, QueueServiceOptions options) throws ServiceException; + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java new file mode 100644 index 0000000000000..3e323db78bb42 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java @@ -0,0 +1,15 @@ +package com.microsoft.azure.services.queue; + +public class QueueServiceOptions { + // Nullable because it is optional + private Integer timeout; + + public Integer getTimeout() { + return timeout; + } + + public QueueServiceOptions setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java new file mode 100644 index 0000000000000..f928a8839084c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java @@ -0,0 +1,158 @@ +package com.microsoft.azure.services.queue; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "StorageServiceProperties") +public class ServiceProperties { + //TODO: What should the default value be (null or new Logging())? + private Logging logging; + private Metrics metrics; + private String defaultServiceVersion; + + @XmlElement(name = "Logging") + public Logging getLogging() { + return logging; + } + + public void setLogging(Logging logging) { + this.logging = logging; + } + + @XmlElement(name = "Metrics") + public Metrics getMetrics() { + return metrics; + } + + public void setMetrics(Metrics metrics) { + this.metrics = metrics; + } + + @XmlElement(name = "DefaultServiceVersion") + public String getDefaultServiceVersion() { + return defaultServiceVersion; + } + + public void setDefaultServiceVersion(String defaultServiceVersion) { + this.defaultServiceVersion = defaultServiceVersion; + } + + public static class Logging { + private String version; + private Boolean delete; + private Boolean read; + private Boolean write; + private RetentionPolicy retentionPolicy; + + @XmlElement(name = "RetentionPolicy") + public RetentionPolicy getRetentionPolicy() { + return retentionPolicy; + } + + public void setRetentionPolicy(RetentionPolicy retentionPolicy) { + this.retentionPolicy = retentionPolicy; + } + + @XmlElement(name = "Write") + public boolean isWrite() { + return write; + } + + public void setWrite(boolean write) { + this.write = write; + } + + @XmlElement(name = "Read") + public boolean isRead() { + return read; + } + + public void setRead(boolean read) { + this.read = read; + } + + @XmlElement(name = "Delete") + public boolean isDelete() { + return delete; + } + + public void setDelete(boolean delete) { + this.delete = delete; + } + + @XmlElement(name = "Version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + } + + public static class Metrics { + private String version; + private boolean enabled; + private Boolean includeAPIs; + private RetentionPolicy retentionPolicy; + + @XmlElement(name = "RetentionPolicy") + public RetentionPolicy getRetentionPolicy() { + return retentionPolicy; + } + + public void setRetentionPolicy(RetentionPolicy retentionPolicy) { + this.retentionPolicy = retentionPolicy; + } + + @XmlElement(name = "IncludeAPIs") + public Boolean isIncludeAPIs() { + return includeAPIs; + } + + public void setIncludeAPIs(Boolean includeAPIs) { + this.includeAPIs = includeAPIs; + } + + @XmlElement(name = "Enabled") + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + @XmlElement(name = "Version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + } + + public static class RetentionPolicy { + private boolean enabled; + private Integer days; // nullable, because optional if "enabled" is false + + @XmlElement(name = "Days") + public Integer getDays() { + return days; + } + + public void setDays(Integer days) { + this.days = days; + } + + @XmlElement(name = "Enabled") + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java new file mode 100644 index 0000000000000..ccd7b3f2dc82e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.queue; + +import java.util.Date; + +public class UpdateMessageResult { + private String popReceipt; + private Date timeNextVisible; + + public String getPopReceipt() { + return popReceipt; + } + + public void setPopReceipt(String popReceipt) { + this.popReceipt = popReceipt; + } + + public Date getTimeNextVisible() { + return timeNextVisible; + } + + public void setTimeNextVisible(Date timeNextVisible) { + this.timeNextVisible = timeNextVisible; + } +} From c5ba7aedc1998322589c6987b6e438c4c319ba8c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 17:25:08 -0800 Subject: [PATCH 02/29] Rename namespace to "windowsazure" --- .../services/queue/CreateMessageOptions.java | 2 +- .../services/queue/CreateQueueOptions.java | 2 +- .../services/queue/GetQueueMetadataResult.java | 2 +- .../services/queue/ListMessagesOptions.java | 2 +- .../services/queue/ListMessagesResult.java | 2 +- .../services/queue/ListQueuesOptions.java | 2 +- .../services/queue/ListQueuesResult.java | 4 ++-- .../services/queue/PeekMessagesOptions.java | 2 +- .../services/queue/PeekMessagesResult.java | 2 +- .../services/queue/QueueListingDetails.java | 2 +- .../services/queue/QueueService.java | 6 +++--- .../services/queue/QueueServiceOptions.java | 2 +- .../services/queue/ServiceProperties.java | 2 +- .../services/queue/UpdateMessageResult.java | 2 +- 14 files changed, 17 insertions(+), 17 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/CreateMessageOptions.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/CreateQueueOptions.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/GetQueueMetadataResult.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/ListMessagesOptions.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/ListMessagesResult.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/ListQueuesOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/ListQueuesResult.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/PeekMessagesOptions.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/PeekMessagesResult.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/QueueListingDetails.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/QueueService.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/QueueServiceOptions.java (85%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/ServiceProperties.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/queue/UpdateMessageResult.java (90%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateMessageOptions.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateMessageOptions.java index a15c7850eba2f..63caaf3c0689e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateMessageOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; public class CreateMessageOptions extends QueueServiceOptions { private Integer visibilityTimeoutInSeconds; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateQueueOptions.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateQueueOptions.java index 1bc35cdaf16ea..c49dc92dc8ca4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/CreateQueueOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateQueueOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/GetQueueMetadataResult.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/GetQueueMetadataResult.java index 1c382082ec4bd..825ad083e201b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/GetQueueMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/GetQueueMetadataResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesOptions.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesOptions.java index 167bef1fe09a8..fd04285236aef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; public class ListMessagesOptions extends QueueServiceOptions { private Integer numberOfMessages; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesResult.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesResult.java index 91be63000d32d..3c40277ae18ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.Date; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesOptions.java index abee05d8b4681..16bf0113451b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesResult.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesResult.java index 3bdb611cee2ad..c3d74c22e29bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.HashMap; import java.util.List; @@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.MetadataAdapter; +import com.microsoft.windowsazure.services.blob.implementation.MetadataAdapter; @XmlRootElement(name = "EnumerationResults") public class ListQueuesResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesOptions.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesOptions.java index 56e310bfd3775..d1ad2185eb5ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; public class PeekMessagesOptions extends QueueServiceOptions { private Integer numberOfMessages; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesResult.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesResult.java index 00147241c6067..c41b78317af78 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/PeekMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.Date; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueListingDetails.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueListingDetails.java index 9d12b14c61b17..12c19829ae8a6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueListingDetails.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; /** * TODO: Make this a bool? diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java index 64930773e3c2d..04134d12ef3c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java @@ -1,9 +1,9 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.HashMap; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.http.ServiceFilter; public interface QueueService { QueueService withFilter(ServiceFilter filter); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceOptions.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceOptions.java index 3e323db78bb42..f6896bb07dee1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/QueueServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; public class QueueServiceOptions { // Nullable because it is optional diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ServiceProperties.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ServiceProperties.java index f928a8839084c..86ccf546aec05 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ServiceProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/UpdateMessageResult.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/UpdateMessageResult.java index ccd7b3f2dc82e..206825f24d2a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/queue/UpdateMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/UpdateMessageResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.queue; +package com.microsoft.windowsazure.services.queue; import java.util.Date; From 7a69e2983aa586ee35c2f2992e4fe10e19cc1e75 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 17:28:00 -0800 Subject: [PATCH 03/29] Move data classes to ".models" package --- .../services/queue/QueueConfiguration.java | 7 +++++++ ...eService.java => QueueServiceContract.java} | 18 +++++++++++++++--- .../{ => models}/CreateMessageOptions.java | 3 ++- .../queue/{ => models}/CreateQueueOptions.java | 2 +- .../{ => models}/GetQueueMetadataResult.java | 2 +- .../{ => models}/ListMessagesOptions.java | 2 +- .../queue/{ => models}/ListMessagesResult.java | 2 +- .../queue/{ => models}/ListQueuesOptions.java | 2 +- .../queue/{ => models}/ListQueuesResult.java | 2 +- .../{ => models}/PeekMessagesOptions.java | 2 +- .../queue/{ => models}/PeekMessagesResult.java | 2 +- .../{ => models}/QueueListingDetails.java | 2 +- .../{ => models}/QueueServiceOptions.java | 2 +- .../queue/{ => models}/ServiceProperties.java | 2 +- .../{ => models}/UpdateMessageResult.java | 2 +- 15 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueConfiguration.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{QueueService.java => QueueServiceContract.java} (73%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/CreateMessageOptions.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/CreateQueueOptions.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/GetQueueMetadataResult.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/ListMessagesOptions.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/ListMessagesResult.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/ListQueuesOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/ListQueuesResult.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/PeekMessagesOptions.java (85%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/PeekMessagesResult.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/QueueListingDetails.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/QueueServiceOptions.java (83%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/ServiceProperties.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{ => models}/UpdateMessageResult.java (89%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueConfiguration.java new file mode 100644 index 0000000000000..416de1f33adac --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueConfiguration.java @@ -0,0 +1,7 @@ +package com.microsoft.windowsazure.services.queue; + +public class QueueConfiguration { + public final static String ACCOUNT_NAME = "queue.accountName"; + public final static String ACCOUNT_KEY = "queue.accountKey"; + public final static String URL = "queue.url"; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java similarity index 73% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java index 04134d12ef3c5..f67f4b0def5ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java @@ -4,9 +4,21 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; - -public interface QueueService { - QueueService withFilter(ServiceFilter filter); +import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; +import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; +import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; +import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; +import com.microsoft.windowsazure.services.queue.models.ListQueuesResult; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; +import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; +import com.microsoft.windowsazure.services.queue.models.ServiceProperties; +import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; + +public interface QueueServiceContract { + QueueServiceContract withFilter(ServiceFilter filter); ServiceProperties getServiceProperties() throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java index 63caaf3c0689e..a63f176723a4f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; + public class CreateMessageOptions extends QueueServiceOptions { private Integer visibilityTimeoutInSeconds; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateQueueOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java index c49dc92dc8ca4..6decb3b2be33a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/CreateQueueOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/GetQueueMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/GetQueueMetadataResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java index 825ad083e201b..7d44c071192d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/GetQueueMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java index fd04285236aef..e7bbd55fc3d39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; public class ListMessagesOptions extends QueueServiceOptions { private Integer numberOfMessages; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java index 3c40277ae18ed..6af2be8ac4ae5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.Date; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java index 16bf0113451b8..3c7f4018da7cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java index c3d74c22e29bd..6568f642c4c5c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.HashMap; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java index d1ad2185eb5ef..5bdde6fcbd5cd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; public class PeekMessagesOptions extends QueueServiceOptions { private Integer numberOfMessages; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java index c41b78317af78..d4e8e44ca7430 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/PeekMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.Date; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueListingDetails.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java index 12c19829ae8a6..0f62eaff465a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; /** * TODO: Make this a bool? diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java index f6896bb07dee1..e75c243729f17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; public class QueueServiceOptions { // Nullable because it is optional diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ServiceProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java index 86ccf546aec05..ac313ea228a9c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/UpdateMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/UpdateMessageResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java index 206825f24d2a2..fbf13dd87dd89 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/UpdateMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.queue; +package com.microsoft.windowsazure.services.queue.models; import java.util.Date; From fe8c691a43bf3b95461e2ce1b223c379dc8292d0 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 19:33:10 -0800 Subject: [PATCH 04/29] Add support for get/setServiceProperties --- .../windowsazure/services/queue/Exports.java | 14 + .../services/queue/QueueServiceContract.java | 10 +- .../implementation/QueueServiceForJersey.java | 313 +++++++++++++++ .../implementation/QueueServiceImpl.java | 365 ++++++++++++++++++ ...rties.java => QueueServiceProperties.java} | 2 +- .../services/queue/IntegrationTestBase.java | 56 +++ .../queue/QueueServiceIntegrationTest.java | 65 ++++ 7 files changed, 819 insertions(+), 6 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/{ServiceProperties.java => QueueServiceProperties.java} (99%) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java new file mode 100644 index 0000000000000..0e2dd47445adb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java @@ -0,0 +1,14 @@ +package com.microsoft.windowsazure.services.queue; + +import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; +import com.microsoft.windowsazure.services.queue.implementation.QueueServiceForJersey; +import com.microsoft.windowsazure.services.queue.implementation.QueueServiceImpl; + +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { + registry.add(QueueServiceContract.class, QueueServiceImpl.class); + registry.add(QueueServiceForJersey.class); + registry.add(SharedKeyLiteFilter.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java index f67f4b0def5ff..ceec3ae101a77 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java @@ -14,19 +14,19 @@ import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; -import com.microsoft.windowsazure.services.queue.models.ServiceProperties; +import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; public interface QueueServiceContract { QueueServiceContract withFilter(ServiceFilter filter); - ServiceProperties getServiceProperties() throws ServiceException; + QueueServiceProperties getServiceProperties() throws ServiceException; - ServiceProperties getServiceProperties(ServiceProperties properties, QueueServiceOptions options) throws ServiceException; + QueueServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException; - void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; + void setServiceProperties(QueueServiceProperties serviceProperties) throws ServiceException; - void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException; + void setServiceProperties(QueueServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException; void createQueue(String queue) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java new file mode 100644 index 0000000000000..68d5117678807 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -0,0 +1,313 @@ +package com.microsoft.windowsazure.services.queue.implementation; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.http.ClientFilterAdapter; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; +import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; +import com.microsoft.windowsazure.services.queue.QueueConfiguration; +import com.microsoft.windowsazure.services.queue.QueueServiceContract; +import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; +import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; +import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; +import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; +import com.microsoft.windowsazure.services.queue.models.ListQueuesResult; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; +import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; +import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; +import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.UniformInterfaceException; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.WebResource.Builder; + +public class QueueServiceForJersey implements QueueServiceContract { + private static Log log = LogFactory.getLog(QueueServiceForJersey.class); + + private static final String API_VERSION = "2011-08-18"; + private final Client channel; + private final String accountName; + private final String url; + private final RFC1123DateConverter dateMapper; + private final ServiceFilter[] filters; + private final SharedKeyLiteFilter filter; + + /* + * TODO: How can we make "timeout" optional? TODO: How to make "filter" + * configurable though code? + */ + @Inject + public QueueServiceForJersey(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.URL) String url, + SharedKeyLiteFilter filter) { + + this.channel = channel; + this.accountName = accountName; + this.url = url; + this.filter = filter; + this.dateMapper = new RFC1123DateConverter(); + this.filters = new ServiceFilter[0]; + channel.addFilter(filter); + } + + public QueueServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, + RFC1123DateConverter dateMapper) { + + this.channel = channel; + this.filters = filters; + this.accountName = accountName; + this.url = url; + this.filter = filter; + this.dateMapper = dateMapper; + } + + public QueueServiceContract withFilter(ServiceFilter filter) { + ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); + newFilters[filters.length] = filter; + return new QueueServiceForJersey(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); + } + + private void ThrowIfError(ClientResponse r) { + if (r.getStatus() >= 300) { + throw new UniformInterfaceException(r); + } + } + + private class EnumCommaStringBuilder> { + private final StringBuilder sb = new StringBuilder(); + + public void addValue(EnumSet enumSet, E value, String representation) { + if (enumSet.contains(value)) { + if (sb.length() >= 0) { + sb.append(","); + } + sb.append(representation); + } + } + + @Override + public String toString() { + return sb.toString(); + } + } + + private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { + if (value != null) { + webResource = webResource.queryParam(key, value.toString()); + } + return webResource; + } + + private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { + if (value != defaultValue) { + webResource = webResource.queryParam(key, Integer.toString(value)); + } + return webResource; + } + + private Builder addOptionalHeader(Builder builder, String name, Object value) { + if (value != null) { + builder = builder.header(name, value); + } + return builder; + } + + private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { + for (Entry entry : metadata.entrySet()) { + builder = builder.header("x-ms-meta-" + entry.getKey(), entry.getValue()); + } + return builder; + } + + private HashMap getMetadataFromHeaders(ClientResponse response) { + HashMap metadata = new HashMap(); + for (Entry> entry : response.getHeaders().entrySet()) { + if (entry.getKey().startsWith("x-ms-meta-")) { + String name = entry.getKey().substring("x-ms-meta-".length()); + String value = entry.getValue().get(0); + metadata.put(name, value); + } + } + return metadata; + } + + private WebResource getResource(QueueServiceOptions options) { + WebResource webResource = channel.resource(url).path("/"); + webResource = addOptionalQueryParam(webResource, "timeout", options.getTimeout()); + for (ServiceFilter filter : filters) { + webResource.addFilter(new ClientFilterAdapter(filter)); + } + + return webResource; + } + + private WebResource setCanonicalizedResource(WebResource webResource, String operation) { + // Resource path + String value = "/" + this.accountName; + value += webResource.getURI().getPath(); + + // "comp" param + if (operation != null) { + value += "?comp=" + operation; + } + + webResource.setProperty("canonicalizedResource", value); + + return webResource; + } + + public QueueServiceProperties getServiceProperties() throws ServiceException { + return getServiceProperties(new QueueServiceOptions()); + } + + public QueueServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(QueueServiceProperties.class); + } + + public void setServiceProperties(QueueServiceProperties serviceProperties) throws ServiceException { + setServiceProperties(serviceProperties, new QueueServiceOptions()); + } + + public void setServiceProperties(QueueServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + + // Note: Add content type here to enable proper HMAC signing + builder.type("application/xml").put(serviceProperties); + } + + public void createQueue(String queue) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void deleteQueue(String queue) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { + // TODO Auto-generated method stub + + } + + public ListQueuesResult listQueues() throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public void setQueueMetadata(String queue, HashMap metadata) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void createMessage(String queue, String message) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException { + // TODO Auto-generated method stub + + } + + public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) + throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds, + QueueServiceOptions options) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public ListMessagesResult listMessages(String queue) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public PeekMessagesResult peekMessages(String queue) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public void deleteMessage(String queue, String message, String popReceipt) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void deleteMessage(String queue, String message, String popReceipt, QueueServiceOptions options) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void clearMessages(String queue) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { + // TODO Auto-generated method stub + + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java new file mode 100644 index 0000000000000..b5ef1a9eb0b4a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java @@ -0,0 +1,365 @@ +package com.microsoft.windowsazure.services.queue.implementation; + +import java.util.HashMap; + +import javax.inject.Inject; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.queue.QueueServiceContract; +import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; +import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; +import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; +import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; +import com.microsoft.windowsazure.services.queue.models.ListQueuesResult; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; +import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; +import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; +import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; +import com.microsoft.windowsazure.utils.ServiceExceptionFactory; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.UniformInterfaceException; + +public class QueueServiceImpl implements QueueServiceContract { + private static Log log = LogFactory.getLog(QueueServiceImpl.class); + private final QueueServiceContract service; + + @Inject + public QueueServiceImpl(QueueServiceForJersey service) { + this.service = service; + } + + public QueueServiceImpl(QueueServiceContract service) { + this.service = service; + } + + public QueueServiceContract withFilter(ServiceFilter filter) { + return new QueueServiceImpl(service.withFilter(filter)); + } + + private ServiceException processCatch(ServiceException e) { + log.warn(e.getMessage(), e.getCause()); + return ServiceExceptionFactory.process("blob", e); + } + + public QueueServiceProperties getServiceProperties() throws ServiceException { + try { + return service.getServiceProperties(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public QueueServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { + try { + return service.getServiceProperties(options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void setServiceProperties(QueueServiceProperties serviceProperties) throws ServiceException { + try { + service.setServiceProperties(serviceProperties); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void setServiceProperties(QueueServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + try { + service.setServiceProperties(serviceProperties, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void createQueue(String queue) throws ServiceException { + try { + service.createQueue(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { + try { + service.createQueue(queue, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteQueue(String queue) throws ServiceException { + try { + service.deleteQueue(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { + try { + service.deleteQueue(queue, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListQueuesResult listQueues() throws ServiceException { + try { + return service.listQueues(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { + try { + return service.listQueues(options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException { + try { + return service.getQueueMetadata(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { + try { + return service.getQueueMetadata(queue, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void setQueueMetadata(String queue, HashMap metadata) throws ServiceException { + try { + service.setQueueMetadata(queue, metadata); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { + try { + service.setQueueMetadata(queue, metadata, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void createMessage(String queue, String message) throws ServiceException { + try { + service.createMessage(queue, message); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException { + try { + service.createMessage(queue, message, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) + throws ServiceException { + try { + return service.updateMessage(queue, message, popReceipt, text, visibilityTimeoutInSeconds); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds, + QueueServiceOptions options) throws ServiceException { + try { + return service.updateMessage(queue, message, popReceipt, text, visibilityTimeoutInSeconds, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListMessagesResult listMessages(String queue) throws ServiceException { + try { + return service.listMessages(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { + try { + return service.listMessages(queue, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public PeekMessagesResult peekMessages(String queue) throws ServiceException { + try { + return service.peekMessages(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { + try { + return service.peekMessages(queue, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteMessage(String queue, String message, String popReceipt) throws ServiceException { + try { + service.deleteMessage(queue, message, popReceipt); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteMessage(String queue, String message, String popReceipt, QueueServiceOptions options) throws ServiceException { + try { + service.deleteMessage(queue, message, popReceipt, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void clearMessages(String queue) throws ServiceException { + try { + service.clearMessages(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { + try { + service.clearMessages(queue, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java index ac313ea228a9c..81ec0e146876f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java @@ -4,7 +4,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "StorageServiceProperties") -public class ServiceProperties { +public class QueueServiceProperties { //TODO: What should the default value be (null or new Logging())? private Logging logging; private Metrics metrics; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java new file mode 100644 index 0000000000000..afa9a3373d094 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java @@ -0,0 +1,56 @@ +package com.microsoft.windowsazure.services.queue; + +import java.util.Map; + +import org.junit.Before; +import org.junit.BeforeClass; + +import com.microsoft.windowsazure.configuration.Configuration; + +public abstract class IntegrationTestBase { + protected static Configuration createConfiguration() { + Configuration config = new Configuration(); + Map env = System.getenv(); + + // Storage emulator support + //setConfigValue(config, env, QueueConfiguration.ACCOUNT_NAME, "devstoreaccount1"); + //setConfigValue(config, env, QueueConfiguration.ACCOUNT_KEY, "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="); + //setConfigValue(config, env, QueueConfiguration.URL, "http://127.0.0.1:10001/devstoreaccount1"); + + // Storage account support + setConfigValue(config, env, QueueConfiguration.ACCOUNT_NAME, "xxx"); + setConfigValue(config, env, QueueConfiguration.ACCOUNT_KEY, "xxx"); + setConfigValue(config, env, QueueConfiguration.URL, "http://xxx.queue.core.windows.net"); + + // when mock running + // config.setProperty("serviceBus.uri", "http://localhost:8086"); + // config.setProperty("wrapClient.uri", + // "http://localhost:8081/WRAPv0.9"); + + return config; + } + + private static void setConfigValue(Configuration config, Map props, String key, String defaultValue) { + String value = props.get(key); + if (value == null) + value = defaultValue; + + config.setProperty(key, value); + } + + @BeforeClass + public static void initializeSystem() { + System.out.println("initialize"); + // System.setProperty("http.proxyHost", "itgproxy"); + // System.setProperty("http.proxyPort", "80"); + // System.setProperty("http.keepAlive", "false"); + } + + @Before + public void initialize() throws Exception { + System.out.println("initialize"); + // System.setProperty("http.proxyHost", "itgproxy"); + // System.setProperty("http.proxyPort", "80"); + // System.setProperty("http.keepAlive", "false"); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java new file mode 100644 index 0000000000000..6d95ab159ff98 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -0,0 +1,65 @@ +package com.microsoft.windowsazure.services.queue; + +import static org.junit.Assert.*; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; + +public class QueueServiceIntegrationTest extends IntegrationTestBase { + + @BeforeClass + public static void setup() throws Exception { + } + + @AfterClass + public static void cleanup() throws Exception { + } + + @Test + public void getServiceProppertiesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + QueueServiceProperties props = service.getServiceProperties(); + + // Assert + assertNotNull(props); + assertNotNull(props.getLogging()); + assertNotNull(props.getLogging().getRetentionPolicy()); + assertNotNull(props.getLogging().getVersion()); + assertNotNull(props.getMetrics().getRetentionPolicy()); + assertNotNull(props.getMetrics().getVersion()); + } + + @Test + public void setServiceProppertiesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + QueueServiceProperties props = service.getServiceProperties(); + + props.setDefaultServiceVersion("2009-09-19"); + props.getLogging().setRead(true); + service.setServiceProperties(props); + + props = service.getServiceProperties(); + + // Assert + assertNotNull(props); + assertEquals("2009-09-19", props.getDefaultServiceVersion()); + assertNotNull(props.getLogging()); + assertNotNull(props.getLogging().getRetentionPolicy()); + assertNotNull(props.getLogging().getVersion()); + assertTrue(props.getLogging().isRead()); + assertNotNull(props.getMetrics().getRetentionPolicy()); + assertNotNull(props.getMetrics().getVersion()); + } +} From d6188814df75c290a05c0ae7b745832ec7a3810a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 19:46:53 -0800 Subject: [PATCH 05/29] Fixing integration test --- .../implementation/SharedKeyLiteFilter.java | 2 +- .../windowsazure/services/queue/Exports.java | 2 +- .../implementation/QueueServiceForJersey.java | 1 - .../implementation/SharedKeyLiteFilter.java | 31 +++++++++++++++++++ ...zure.configuration.builder.Builder$Exports | 1 + .../services/queue/IntegrationTestBase.java | 6 ++-- 6 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java index 9566181381336..0fe80fe7e4eef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java @@ -52,7 +52,7 @@ private String nullEmpty(String value) { * StringToSign = VERB + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + * Date + "\n" + CanonicalizedHeaders + CanonicalizedResource; */ - private void sign(ClientRequest cr) { + public void sign(ClientRequest cr) { // gather signed material String requestMethod = cr.getMethod(); String contentMD5 = getHeader(cr, "Content-MD5"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java index 0e2dd47445adb..8998a2fca38a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java @@ -1,9 +1,9 @@ package com.microsoft.windowsazure.services.queue; import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; import com.microsoft.windowsazure.services.queue.implementation.QueueServiceForJersey; import com.microsoft.windowsazure.services.queue.implementation.QueueServiceImpl; +import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index 68d5117678807..eef26e8beb564 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -17,7 +17,6 @@ import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; -import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; import com.microsoft.windowsazure.services.queue.QueueConfiguration; import com.microsoft.windowsazure.services.queue.QueueServiceContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java new file mode 100644 index 0000000000000..cdc28ca45f9d9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java @@ -0,0 +1,31 @@ +package com.microsoft.windowsazure.services.queue.implementation; + +import javax.inject.Named; + +import com.microsoft.windowsazure.services.queue.QueueConfiguration; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientRequest; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.filter.ClientFilter; + +/* + * TODO: Should the "full" shared key signing? + */ +public class SharedKeyLiteFilter extends ClientFilter { + private final com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter blobSharedKeyFilter; + + public SharedKeyLiteFilter(@Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.ACCOUNT_KEY) String accountKey) { + blobSharedKeyFilter = new com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter(accountName, accountKey); + } + + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + + // Only sign if no other filter has done it yet + if (cr.getHeaders().getFirst("Authorization") == null) { + blobSharedKeyFilter.sign(cr); + } + + return this.getNext().handle(cr); + } +} diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports index 0b1087c7d616d..ce9f1f862db41 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports @@ -1,5 +1,6 @@ com.microsoft.windowsazure.auth.wrap.Exports com.microsoft.windowsazure.configuration.jersey.Exports com.microsoft.windowsazure.services.blob.Exports +com.microsoft.windowsazure.services.queue.Exports com.microsoft.windowsazure.services.serviceBus.Exports com.microsoft.windowsazure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java index afa9a3373d094..6602dc78d496a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java @@ -18,9 +18,9 @@ protected static Configuration createConfiguration() { //setConfigValue(config, env, QueueConfiguration.URL, "http://127.0.0.1:10001/devstoreaccount1"); // Storage account support - setConfigValue(config, env, QueueConfiguration.ACCOUNT_NAME, "xxx"); - setConfigValue(config, env, QueueConfiguration.ACCOUNT_KEY, "xxx"); - setConfigValue(config, env, QueueConfiguration.URL, "http://xxx.queue.core.windows.net"); + setConfigValue(config, env, QueueConfiguration.ACCOUNT_NAME, "onesdktest"); + setConfigValue(config, env, QueueConfiguration.ACCOUNT_KEY, "rKIHg9krRmIOA5JHf63WuolShpuMN0sZszkdCAIZx/PUQtoZf4Oi+YZiXwruIeOnuDfqJFpHsMibm8hjeft94w=="); + setConfigValue(config, env, QueueConfiguration.URL, "http://onesdktest.queue.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); From 3a137dfd14dc466d76b4f44b218194c9544c8102 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 19:54:39 -0800 Subject: [PATCH 06/29] Remove blob specific service properties --- .../services/queue/models/QueueServiceProperties.java | 9 --------- .../services/queue/QueueServiceIntegrationTest.java | 2 -- 2 files changed, 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java index 81ec0e146876f..e00ee53130920 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java @@ -28,15 +28,6 @@ public void setMetrics(Metrics metrics) { this.metrics = metrics; } - @XmlElement(name = "DefaultServiceVersion") - public String getDefaultServiceVersion() { - return defaultServiceVersion; - } - - public void setDefaultServiceVersion(String defaultServiceVersion) { - this.defaultServiceVersion = defaultServiceVersion; - } - public static class Logging { private String version; private Boolean delete; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 6d95ab159ff98..eac3a96bc708c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -46,7 +46,6 @@ public void setServiceProppertiesWorks() throws Exception { // Act QueueServiceProperties props = service.getServiceProperties(); - props.setDefaultServiceVersion("2009-09-19"); props.getLogging().setRead(true); service.setServiceProperties(props); @@ -54,7 +53,6 @@ public void setServiceProppertiesWorks() throws Exception { // Assert assertNotNull(props); - assertEquals("2009-09-19", props.getDefaultServiceVersion()); assertNotNull(props.getLogging()); assertNotNull(props.getLogging().getRetentionPolicy()); assertNotNull(props.getLogging().getVersion()); From beb07819c06fcfc4f1c90c6ce022425939eb00c2 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 19:56:24 -0800 Subject: [PATCH 07/29] Removing account information --- .../windowsazure/services/queue/IntegrationTestBase.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java index 6602dc78d496a..afa9a3373d094 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java @@ -18,9 +18,9 @@ protected static Configuration createConfiguration() { //setConfigValue(config, env, QueueConfiguration.URL, "http://127.0.0.1:10001/devstoreaccount1"); // Storage account support - setConfigValue(config, env, QueueConfiguration.ACCOUNT_NAME, "onesdktest"); - setConfigValue(config, env, QueueConfiguration.ACCOUNT_KEY, "rKIHg9krRmIOA5JHf63WuolShpuMN0sZszkdCAIZx/PUQtoZf4Oi+YZiXwruIeOnuDfqJFpHsMibm8hjeft94w=="); - setConfigValue(config, env, QueueConfiguration.URL, "http://onesdktest.queue.core.windows.net"); + setConfigValue(config, env, QueueConfiguration.ACCOUNT_NAME, "xxx"); + setConfigValue(config, env, QueueConfiguration.ACCOUNT_KEY, "xxx"); + setConfigValue(config, env, QueueConfiguration.URL, "http://xxx.queue.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); From fc307732a1c90377ac1ed24094a0e0bbdf8f8071 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 20:08:41 -0800 Subject: [PATCH 08/29] Rename class --- .../services/queue/QueueServiceContract.java | 10 +++++----- .../queue/implementation/QueueServiceForJersey.java | 12 ++++++------ .../queue/implementation/QueueServiceImpl.java | 10 +++++----- ...ServiceProperties.java => ServiceProperties.java} | 3 +-- .../services/queue/QueueServiceIntegrationTest.java | 6 +++--- 5 files changed, 20 insertions(+), 21 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/{QueueServiceProperties.java => ServiceProperties.java} (97%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java index ceec3ae101a77..465f20d97614b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java @@ -14,19 +14,19 @@ import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; -import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; +import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; public interface QueueServiceContract { QueueServiceContract withFilter(ServiceFilter filter); - QueueServiceProperties getServiceProperties() throws ServiceException; + ServiceProperties getServiceProperties() throws ServiceException; - QueueServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException; + ServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException; - void setServiceProperties(QueueServiceProperties serviceProperties) throws ServiceException; + void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; - void setServiceProperties(QueueServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException; + void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException; void createQueue(String queue) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index eef26e8beb564..d79468d27f68b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -29,7 +29,7 @@ import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; -import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; +import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -171,24 +171,24 @@ private WebResource setCanonicalizedResource(WebResource webResource, String ope return webResource; } - public QueueServiceProperties getServiceProperties() throws ServiceException { + public ServiceProperties getServiceProperties() throws ServiceException { return getServiceProperties(new QueueServiceOptions()); } - public QueueServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { + public ServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - return builder.get(QueueServiceProperties.class); + return builder.get(ServiceProperties.class); } - public void setServiceProperties(QueueServiceProperties serviceProperties) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { setServiceProperties(serviceProperties, new QueueServiceOptions()); } - public void setServiceProperties(QueueServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, "properties"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java index b5ef1a9eb0b4a..89ec0f58ac90c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java @@ -20,7 +20,7 @@ import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; -import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; +import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; @@ -48,7 +48,7 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("blob", e); } - public QueueServiceProperties getServiceProperties() throws ServiceException { + public ServiceProperties getServiceProperties() throws ServiceException { try { return service.getServiceProperties(); } @@ -60,7 +60,7 @@ public QueueServiceProperties getServiceProperties() throws ServiceException { } } - public QueueServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { + public ServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { try { return service.getServiceProperties(options); } @@ -72,7 +72,7 @@ public QueueServiceProperties getServiceProperties(QueueServiceOptions options) } } - public void setServiceProperties(QueueServiceProperties serviceProperties) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { try { service.setServiceProperties(serviceProperties); } @@ -84,7 +84,7 @@ public void setServiceProperties(QueueServiceProperties serviceProperties) throw } } - public void setServiceProperties(QueueServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { try { service.setServiceProperties(serviceProperties, options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java index e00ee53130920..42504b51edf07 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java @@ -4,11 +4,10 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "StorageServiceProperties") -public class QueueServiceProperties { +public class ServiceProperties { //TODO: What should the default value be (null or new Logging())? private Logging logging; private Metrics metrics; - private String defaultServiceVersion; @XmlElement(name = "Logging") public Logging getLogging() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index eac3a96bc708c..3e2c6d70e5be8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.services.queue.models.QueueServiceProperties; +import com.microsoft.windowsazure.services.queue.models.ServiceProperties; public class QueueServiceIntegrationTest extends IntegrationTestBase { @@ -26,7 +26,7 @@ public void getServiceProppertiesWorks() throws Exception { QueueServiceContract service = config.create(QueueServiceContract.class); // Act - QueueServiceProperties props = service.getServiceProperties(); + ServiceProperties props = service.getServiceProperties(); // Assert assertNotNull(props); @@ -44,7 +44,7 @@ public void setServiceProppertiesWorks() throws Exception { QueueServiceContract service = config.create(QueueServiceContract.class); // Act - QueueServiceProperties props = service.getServiceProperties(); + ServiceProperties props = service.getServiceProperties(); props.getLogging().setRead(true); service.setServiceProperties(props); From 9042cc060c3ec2529c651290afb8eb217cb222f7 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 21:10:28 -0800 Subject: [PATCH 09/29] Add support for "create/deleteQueue" + "getQueueMetadata" --- .../implementation/QueueServiceForJersey.java | 37 ++++++++--- .../queue/QueueServiceIntegrationTest.java | 64 ++++++++++++++++++- 2 files changed, 90 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index d79468d27f68b..aa83a406a8bea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -199,23 +199,32 @@ public void setServiceProperties(ServiceProperties serviceProperties, QueueServi } public void createQueue(String queue) throws ServiceException { - // TODO Auto-generated method stub + createQueue(queue, new CreateQueueOptions()); } public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { - // TODO Auto-generated method stub + WebResource webResource = getResource(options).path(queue); + webResource = setCanonicalizedResource(webResource, null); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); } public void deleteQueue(String queue) throws ServiceException { - // TODO Auto-generated method stub - + deleteQueue(queue, new QueueServiceOptions()); } public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { - // TODO Auto-generated method stub + WebResource webResource = getResource(options).path(queue); + webResource = setCanonicalizedResource(webResource, null); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder.delete(); } public ListQueuesResult listQueues() throws ServiceException { @@ -229,13 +238,23 @@ public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceExce } public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException { - // TODO Auto-generated method stub - return null; + return getQueueMetadata(queue, new QueueServiceOptions()); } public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource webResource = getResource(options).path(queue).queryParam("comp", "metadata"); + webResource = setCanonicalizedResource(webResource, "metadata"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + GetQueueMetadataResult result = new GetQueueMetadataResult(); + result.setApproximateMessageCount(Integer.parseInt(response.getHeaders().getFirst("x-ms-approximate-messages-count"))); + result.setMetadata(getMetadataFromHeaders(response)); + + return result; } public void setQueueMetadata(String queue, HashMap metadata) throws ServiceException { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 3e2c6d70e5be8..695b625eaf4f7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -6,10 +6,17 @@ import org.junit.BeforeClass; import org.junit.Test; +import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; +import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; public class QueueServiceIntegrationTest extends IntegrationTestBase { + //private static final String testContainersPrefix = "sdktest-"; + private static final String createableQueuesPrefix = "csdktest-"; + private static final String CREATABLE_QUEUE_1 = createableQueuesPrefix + "1"; + private static final String CREATABLE_QUEUE_2 = createableQueuesPrefix + "2"; @BeforeClass public static void setup() throws Exception { @@ -17,10 +24,25 @@ public static void setup() throws Exception { @AfterClass public static void cleanup() throws Exception { + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + try { + service.deleteQueue(CREATABLE_QUEUE_1); + } + catch (ServiceException e) { + // Queue might not exist + } + try { + service.deleteQueue(CREATABLE_QUEUE_2); + } + catch (ServiceException e) { + // Queue might not exist + } } @Test - public void getServiceProppertiesWorks() throws Exception { + public void getServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); QueueServiceContract service = config.create(QueueServiceContract.class); @@ -38,7 +60,7 @@ public void getServiceProppertiesWorks() throws Exception { } @Test - public void setServiceProppertiesWorks() throws Exception { + public void setServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); QueueServiceContract service = config.create(QueueServiceContract.class); @@ -60,4 +82,42 @@ public void setServiceProppertiesWorks() throws Exception { assertNotNull(props.getMetrics().getRetentionPolicy()); assertNotNull(props.getMetrics().getVersion()); } + + @Test + public void createQueueWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + service.createQueue(CREATABLE_QUEUE_1); + GetQueueMetadataResult result = service.getQueueMetadata(CREATABLE_QUEUE_1); + service.deleteQueue(CREATABLE_QUEUE_1); + + // Assert + assertNotNull(result); + assertEquals(0, result.getApproximateMessageCount()); + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + } + + @Test + public void createQueueWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + service.createQueue(CREATABLE_QUEUE_2, new CreateQueueOptions().addMetadata("foo", "bar").addMetadata("test", "blah")); + GetQueueMetadataResult result = service.getQueueMetadata(CREATABLE_QUEUE_2); + service.deleteQueue(CREATABLE_QUEUE_2); + + // Assert + assertNotNull(result); + assertEquals(0, result.getApproximateMessageCount()); + assertNotNull(result.getMetadata()); + assertEquals(2, result.getMetadata().size()); + assertEquals("bar", result.getMetadata().get("foo")); + assertEquals("blah", result.getMetadata().get("test")); + } } From 1ac5515d68f8fb4bff4422d20ca4aa9312a080dd Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 10:15:11 -0800 Subject: [PATCH 10/29] Implemente "listQueues", "setQueueMetadata", "createMessage", "listMessage" --- .../implementation/BlobServiceForJersey.java | 3 +- .../queue/implementation/QueueMessage.java | 19 ++ .../implementation/QueueServiceForJersey.java | 56 +++- .../queue/models/ListMessagesResult.java | 6 + .../queue/models/ListQueuesOptions.java | 12 +- .../queue/models/QueueListingDetails.java | 36 --- .../queue/QueueServiceIntegrationTest.java | 239 +++++++++++++++++- 7 files changed, 299 insertions(+), 72 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueMessage.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index cc53d3a47bcfd..14bf67811b500 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -75,8 +75,7 @@ public class BlobServiceForJersey implements BlobService { private final SharedKeyLiteFilter filter; /* - * TODO: How can we make "timeout" optional? TODO: How to make "filter" - * configurable though code? + * TODO: How to make "filter" configurable though code? */ @Inject public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueMessage.java new file mode 100644 index 0000000000000..d19228e959420 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueMessage.java @@ -0,0 +1,19 @@ +package com.microsoft.windowsazure.services.queue.implementation; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "QueueMessage") +public class QueueMessage { + private String messageText; + + @XmlElement(name = "MessageText") + public String getMessageText() { + return messageText; + } + + public void setMessageText(String messageText) { + this.messageText = messageText; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index aa83a406a8bea..87089e01a705d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -228,13 +228,22 @@ public void deleteQueue(String queue, QueueServiceOptions options) throws Servic } public ListQueuesResult listQueues() throws ServiceException { - // TODO Auto-generated method stub - return null; + return listQueues(new ListQueuesOptions()); } public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); + webResource = setCanonicalizedResource(webResource, "list"); + webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); + webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); + webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); + if (options.isIncludeMetadata()) { + webResource = webResource.queryParam("include", "metadata"); + } + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ListQueuesResult.class); } public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException { @@ -258,23 +267,37 @@ public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions } public void setQueueMetadata(String queue, HashMap metadata) throws ServiceException { - // TODO Auto-generated method stub - + setQueueMetadata(queue, metadata, new QueueServiceOptions()); } public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { - // TODO Auto-generated method stub + WebResource webResource = getResource(options).path(queue).queryParam("comp", "metadata"); + webResource = setCanonicalizedResource(webResource, "metadata"); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalMetadataHeader(builder, metadata); + + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); } public void createMessage(String queue, String message) throws ServiceException { - // TODO Auto-generated method stub - + createMessage(queue, message, new CreateMessageOptions()); } public void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException { - // TODO Auto-generated method stub + WebResource webResource = getResource(options).path(queue).path("messages"); + webResource = setCanonicalizedResource(webResource, null); + webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds()); + webResource = addOptionalQueryParam(webResource, "messagettl", options.getTimeToLiveInSeconds()); + Builder builder = webResource.header("x-ms-version", API_VERSION); + + QueueMessage queueMessage = new QueueMessage(); + queueMessage.setMessageText(message); + + // Note: Add content type here to enable proper HMAC signing + builder.type("application/xml").post(queueMessage); } public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) @@ -290,13 +313,18 @@ public UpdateMessageResult updateMessage(String queue, String message, String po } public ListMessagesResult listMessages(String queue) throws ServiceException { - // TODO Auto-generated method stub - return null; + return listMessages(queue, new ListMessagesOptions()); } public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource webResource = getResource(options).path(queue).path("messages"); + webResource = setCanonicalizedResource(webResource, null); + webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds()); + webResource = addOptionalQueryParam(webResource, "numofmessages", options.getNumberOfMessages()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ListMessagesResult.class); } public PeekMessagesResult peekMessages(String queue) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java index 6af2be8ac4ae5..cc8a84b481591 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java @@ -5,6 +5,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "QueueMessagesList") public class ListMessagesResult { @@ -38,6 +41,7 @@ public void setId(String id) { } @XmlElement(name = "InsertionTime") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getInsertionDate() { return insertionDate; } @@ -47,6 +51,7 @@ public void setInsertionDate(Date insertionDate) { } @XmlElement(name = "ExpirationTime") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getExpirationDate() { return expirationDate; } @@ -65,6 +70,7 @@ public void setPopReceipt(String popReceipt) { } @XmlElement(name = "TimeNextVisible") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getTimeNextVisible() { return timeNextVisible; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java index 3c7f4018da7cf..0d44721c235fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java @@ -1,12 +1,10 @@ package com.microsoft.windowsazure.services.queue.models; -import java.util.EnumSet; - public class ListQueuesOptions extends QueueServiceOptions { private String prefix; private String marker; private int maxResults; - private EnumSet listingDetails = EnumSet.noneOf(QueueListingDetails.class); + private boolean includeMetadata; public String getPrefix() { return prefix; @@ -35,12 +33,12 @@ public ListQueuesOptions setMaxResults(int maxResults) { return this; } - public EnumSet getListingDetails() { - return listingDetails; + public boolean isIncludeMetadata() { + return includeMetadata; } - public ListQueuesOptions setListingDetails(EnumSet listingDetails) { - this.listingDetails = listingDetails; + public ListQueuesOptions setIncludeMetadata(boolean includeMetadata) { + this.includeMetadata = includeMetadata; return this; } } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java deleted file mode 100644 index 0f62eaff465a2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueListingDetails.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.microsoft.windowsazure.services.queue.models; - -/** - * TODO: Make this a bool? - * - * Specifies which details to include when listing the containers in this - * storage account. - * - * Copyright (c)2011 Microsoft. All rights reserved. - */ -public enum QueueListingDetails { - /** - * Specifies including no additional details. - */ - NONE(0), - - /** - * Specifies including container metadata. - */ - METADATA(1); - - /** - * Returns the value of this enum. - */ - int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - QueueListingDetails(int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 695b625eaf4f7..7f8702227c128 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -2,6 +2,11 @@ import static org.junit.Assert.*; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.TimeZone; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -10,16 +15,57 @@ import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; +import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; +import com.microsoft.windowsazure.services.queue.models.ListQueuesResult; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; public class QueueServiceIntegrationTest extends IntegrationTestBase { - //private static final String testContainersPrefix = "sdktest-"; + private static final String testQueuesPrefix = "sdktest-"; private static final String createableQueuesPrefix = "csdktest-"; - private static final String CREATABLE_QUEUE_1 = createableQueuesPrefix + "1"; - private static final String CREATABLE_QUEUE_2 = createableQueuesPrefix + "2"; + private static String TEST_QUEUE_FOR_MESSAGES; + private static String TEST_QUEUE_FOR_MESSAGES_2; + private static String TEST_QUEUE_FOR_MESSAGES_3; + private static String CREATABLE_QUEUE_1; + private static String CREATABLE_QUEUE_2; + private static String CREATABLE_QUEUE_3; + private static String[] creatableQueues; + private static String[] testQueues; @BeforeClass public static void setup() throws Exception { + // Setup container names array (list of container names used by + // integration tests) + testQueues = new String[10]; + for (int i = 0; i < testQueues.length; i++) { + testQueues[i] = String.format("%s%d", testQueuesPrefix, i + 1); + } + + creatableQueues = new String[10]; + for (int i = 0; i < creatableQueues.length; i++) { + creatableQueues[i] = String.format("%s%d", createableQueuesPrefix, i + 1); + } + + TEST_QUEUE_FOR_MESSAGES = testQueues[0]; + TEST_QUEUE_FOR_MESSAGES_2 = testQueues[1]; + TEST_QUEUE_FOR_MESSAGES_3 = testQueues[2]; + + CREATABLE_QUEUE_1 = creatableQueues[0]; + CREATABLE_QUEUE_2 = creatableQueues[1]; + CREATABLE_QUEUE_3 = creatableQueues[2]; + + // Create all test containers and their content + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + for (int i = 0; i < testQueues.length; i++) { + try { + service.createQueue(testQueues[i]); + } + catch (ServiceException e) { + // Ignore exception as the containers might not exists + } + } } @AfterClass @@ -27,17 +73,22 @@ public static void cleanup() throws Exception { Configuration config = createConfiguration(); QueueServiceContract service = config.create(QueueServiceContract.class); - try { - service.deleteQueue(CREATABLE_QUEUE_1); - } - catch (ServiceException e) { - // Queue might not exist + for (int i = 0; i < testQueues.length; i++) { + try { + service.deleteQueue(testQueues[i]); + } + catch (ServiceException e) { + // Ignore exception as the containers might not exists + } } - try { - service.deleteQueue(CREATABLE_QUEUE_2); - } - catch (ServiceException e) { - // Queue might not exist + + for (int i = 0; i < creatableQueues.length; i++) { + try { + service.deleteQueue(creatableQueues[i]); + } + catch (ServiceException e) { + // Ignore exception as the containers might not exists + } } } @@ -120,4 +171,166 @@ public void createQueueWithOptionsWorks() throws Exception { assertEquals("bar", result.getMetadata().get("foo")); assertEquals("blah", result.getMetadata().get("test")); } + + @Test + public void listQueuesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + ListQueuesResult result = service.listQueues(); + + // Assert + assertNotNull(result); + assertNotNull(result.getQueues()); + assertNotNull(result.getAccountName()); + assertNull(result.getMarker()); + assertEquals(0, result.getMaxResults()); + assertTrue(testQueues.length <= result.getQueues().size()); + } + + @Test + public void listQueuesWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + ListQueuesResult result = service.listQueues(new ListQueuesOptions().setMaxResults(3).setPrefix(testQueuesPrefix)); + ListQueuesResult result2 = service.listQueues(new ListQueuesOptions().setMarker(result.getNextMarker()).setPrefix(testQueuesPrefix) + .setIncludeMetadata(true)); + + // Assert + assertNotNull(result); + assertNotNull(result.getQueues()); + assertEquals(3, result.getQueues().size()); + assertEquals(3, result.getMaxResults()); + assertNotNull(result.getAccountName()); + assertNull(result.getMarker()); + assertNotNull(result.getQueues().get(0)); + assertNotNull(result.getQueues().get(0).getMetadata()); + assertNotNull(result.getQueues().get(0).getName()); + assertNotNull(result.getQueues().get(0).getUrl()); + + assertNotNull(result2); + assertNotNull(result2.getQueues()); + assertTrue(testQueues.length - 3 <= result2.getQueues().size()); + assertEquals(0, result2.getMaxResults()); + assertNotNull(result2.getAccountName()); + assertEquals(result.getNextMarker(), result2.getMarker()); + assertNotNull(result2.getQueues().get(0)); + assertNotNull(result2.getQueues().get(0).getMetadata()); + assertNotNull(result2.getQueues().get(0).getName()); + assertNotNull(result2.getQueues().get(0).getUrl()); + } + + @Test + public void setQueueMetadataWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + service.createQueue(CREATABLE_QUEUE_3); + + HashMap metadata = new HashMap(); + metadata.put("foo", "bar"); + metadata.put("test", "blah"); + service.setQueueMetadata(CREATABLE_QUEUE_3, metadata); + + GetQueueMetadataResult result = service.getQueueMetadata(CREATABLE_QUEUE_3); + + service.deleteQueue(CREATABLE_QUEUE_3); + + // Assert + assertNotNull(result); + assertEquals(0, result.getApproximateMessageCount()); + assertNotNull(result.getMetadata()); + assertEquals(2, result.getMetadata().size()); + assertEquals("bar", result.getMetadata().get("foo")); + assertEquals("blah", result.getMetadata().get("test")); + } + + @Test + public void createMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES, "message4"); + + // Assert + } + + @Test + public void listMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + calendar.set(2010, 01, 01); + Date year2010 = calendar.getTime(); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_2, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_2, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_2, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_2, "message4"); + ListMessagesResult result = service.listMessages(TEST_QUEUE_FOR_MESSAGES_2); + + // Assert + assertNotNull(result); + assertEquals(1, result.getMessages().size()); + assertNotNull(result.getMessages().get(0).getId()); + assertNotNull(result.getMessages().get(0).getText()); + assertNotNull(result.getMessages().get(0).getExpirationDate()); + assertTrue(year2010.before(result.getMessages().get(0).getExpirationDate())); + assertNotNull(result.getMessages().get(0).getInsertionDate()); + assertTrue(year2010.before(result.getMessages().get(0).getInsertionDate())); + assertNotNull(result.getMessages().get(0).getPopReceipt()); + assertNotNull(result.getMessages().get(0).getTimeNextVisible()); + assertTrue(year2010.before(result.getMessages().get(0).getTimeNextVisible())); + assertTrue(1 <= result.getMessages().get(0).getDequeueCount()); + } + + @Test + public void listMessageWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + calendar.set(2010, 01, 01); + Date year2010 = calendar.getTime(); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_3, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_3, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_3, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_3, "message4"); + ListMessagesResult result = service.listMessages(TEST_QUEUE_FOR_MESSAGES_3, new ListMessagesOptions().setNumberOfMessages(4) + .setVisibilityTimeoutInSeconds(20)); + + // Assert + assertNotNull(result); + assertEquals(4, result.getMessages().size()); + for (int i = 0; i < 4; i++) { + assertNotNull(result.getMessages().get(1).getId()); + assertNotNull(result.getMessages().get(1).getText()); + assertNotNull(result.getMessages().get(1).getExpirationDate()); + assertTrue(year2010.before(result.getMessages().get(1).getExpirationDate())); + assertNotNull(result.getMessages().get(1).getInsertionDate()); + assertTrue(year2010.before(result.getMessages().get(1).getInsertionDate())); + assertNotNull(result.getMessages().get(1).getPopReceipt()); + assertNotNull(result.getMessages().get(1).getTimeNextVisible()); + assertTrue(0 <= result.getMessages().get(1).getTimeNextVisible().getTime()); + assertTrue(1 <= result.getMessages().get(1).getDequeueCount()); + } + } } From b22b01b9334966470334e1418999da4c1905da79 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 10:16:10 -0800 Subject: [PATCH 11/29] Fix unit test --- .../queue/QueueServiceIntegrationTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 7f8702227c128..83b51c926dec2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -321,16 +321,16 @@ public void listMessageWithOptionsWorks() throws Exception { assertNotNull(result); assertEquals(4, result.getMessages().size()); for (int i = 0; i < 4; i++) { - assertNotNull(result.getMessages().get(1).getId()); - assertNotNull(result.getMessages().get(1).getText()); - assertNotNull(result.getMessages().get(1).getExpirationDate()); - assertTrue(year2010.before(result.getMessages().get(1).getExpirationDate())); - assertNotNull(result.getMessages().get(1).getInsertionDate()); - assertTrue(year2010.before(result.getMessages().get(1).getInsertionDate())); - assertNotNull(result.getMessages().get(1).getPopReceipt()); - assertNotNull(result.getMessages().get(1).getTimeNextVisible()); - assertTrue(0 <= result.getMessages().get(1).getTimeNextVisible().getTime()); - assertTrue(1 <= result.getMessages().get(1).getDequeueCount()); + assertNotNull(result.getMessages().get(i).getId()); + assertNotNull(result.getMessages().get(i).getText()); + assertNotNull(result.getMessages().get(i).getExpirationDate()); + assertTrue(year2010.before(result.getMessages().get(i).getExpirationDate())); + assertNotNull(result.getMessages().get(i).getInsertionDate()); + assertTrue(year2010.before(result.getMessages().get(i).getInsertionDate())); + assertNotNull(result.getMessages().get(i).getPopReceipt()); + assertNotNull(result.getMessages().get(i).getTimeNextVisible()); + assertTrue(0 <= result.getMessages().get(i).getTimeNextVisible().getTime()); + assertTrue(1 <= result.getMessages().get(i).getDequeueCount()); } } } From 3ec55ca6d067d85a77b82211173aa8a8be372ead Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 10:39:38 -0800 Subject: [PATCH 12/29] Implement "peekMessages" --- .../services/queue/QueueServiceContract.java | 12 +- .../implementation/QueueServiceForJersey.java | 50 +++---- .../implementation/QueueServiceImpl.java | 25 ++-- .../queue/models/ListMessagesResult.java | 12 +- .../queue/models/PeekMessagesResult.java | 17 ++- .../queue/QueueServiceIntegrationTest.java | 135 ++++++++++++++---- 6 files changed, 163 insertions(+), 88 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java index 465f20d97614b..7e2f38a346c01 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java @@ -48,13 +48,13 @@ public interface QueueServiceContract { void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException; - void createMessage(String queue, String message) throws ServiceException; + void createMessage(String queue, String messageText) throws ServiceException; - void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException; + void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException; - UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) throws ServiceException; + UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) throws ServiceException; - UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds, QueueServiceOptions options) + UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException; ListMessagesResult listMessages(String queue) throws ServiceException; @@ -65,9 +65,9 @@ UpdateMessageResult updateMessage(String queue, String message, String popReceip PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException; - void deleteMessage(String queue, String message, String popReceipt) throws ServiceException; + void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException; - void deleteMessage(String queue, String message, String popReceipt, QueueServiceOptions options) throws ServiceException; + void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException; void clearMessages(String queue) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index 87089e01a705d..3daa92f6e4fac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -1,7 +1,6 @@ package com.microsoft.windowsazure.services.queue.implementation; import java.util.Arrays; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,8 +48,7 @@ public class QueueServiceForJersey implements QueueServiceContract { private final SharedKeyLiteFilter filter; /* - * TODO: How can we make "timeout" optional? TODO: How to make "filter" - * configurable though code? + * TODO: How to make "filter" configurable though code? */ @Inject public QueueServiceForJersey(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.URL) String url, @@ -88,24 +86,6 @@ private void ThrowIfError(ClientResponse r) { } } - private class EnumCommaStringBuilder> { - private final StringBuilder sb = new StringBuilder(); - - public void addValue(EnumSet enumSet, E value, String representation) { - if (enumSet.contains(value)) { - if (sb.length() >= 0) { - sb.append(","); - } - sb.append(representation); - } - } - - @Override - public String toString() { - return sb.toString(); - } - } - private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { if (value != null) { webResource = webResource.queryParam(key, value.toString()); @@ -281,11 +261,11 @@ public void setQueueMetadata(String queue, HashMap metadata, Que builder.type("text/plain").put(""); } - public void createMessage(String queue, String message) throws ServiceException { - createMessage(queue, message, new CreateMessageOptions()); + public void createMessage(String queue, String messageText) throws ServiceException { + createMessage(queue, messageText, new CreateMessageOptions()); } - public void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException { + public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { WebResource webResource = getResource(options).path(queue).path("messages"); webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds()); @@ -294,19 +274,19 @@ public void createMessage(String queue, String message, CreateMessageOptions opt Builder builder = webResource.header("x-ms-version", API_VERSION); QueueMessage queueMessage = new QueueMessage(); - queueMessage.setMessageText(message); + queueMessage.setMessageText(messageText); // Note: Add content type here to enable proper HMAC signing builder.type("application/xml").post(queueMessage); } - public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) throws ServiceException { // TODO Auto-generated method stub return null; } - public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds, + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { // TODO Auto-generated method stub return null; @@ -328,21 +308,25 @@ public ListMessagesResult listMessages(String queue, ListMessagesOptions options } public PeekMessagesResult peekMessages(String queue) throws ServiceException { - // TODO Auto-generated method stub - return null; + return peekMessages(queue, new PeekMessagesOptions()); } public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource webResource = getResource(options).path(queue).path("messages").queryParam("peekonly", "true"); + webResource = setCanonicalizedResource(webResource, null); + webResource = addOptionalQueryParam(webResource, "numofmessages", options.getNumberOfMessages()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(PeekMessagesResult.class); } - public void deleteMessage(String queue, String message, String popReceipt) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException { // TODO Auto-generated method stub } - public void deleteMessage(String queue, String message, String popReceipt, QueueServiceOptions options) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { // TODO Auto-generated method stub } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java index 89ec0f58ac90c..3b26c801f7ca4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java @@ -216,9 +216,9 @@ public void setQueueMetadata(String queue, HashMap metadata, Que } } - public void createMessage(String queue, String message) throws ServiceException { + public void createMessage(String queue, String messageText) throws ServiceException { try { - service.createMessage(queue, message); + service.createMessage(queue, messageText); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -228,9 +228,9 @@ public void createMessage(String queue, String message) throws ServiceException } } - public void createMessage(String queue, String message, CreateMessageOptions options) throws ServiceException { + public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { try { - service.createMessage(queue, message, options); + service.createMessage(queue, messageText, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -240,10 +240,10 @@ public void createMessage(String queue, String message, CreateMessageOptions opt } } - public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds) + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) throws ServiceException { try { - return service.updateMessage(queue, message, popReceipt, text, visibilityTimeoutInSeconds); + return service.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -253,10 +253,10 @@ public UpdateMessageResult updateMessage(String queue, String message, String po } } - public UpdateMessageResult updateMessage(String queue, String message, String popReceipt, String text, int visibilityTimeoutInSeconds, + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { try { - return service.updateMessage(queue, message, popReceipt, text, visibilityTimeoutInSeconds, options); + return service.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -314,9 +314,9 @@ public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options } } - public void deleteMessage(String queue, String message, String popReceipt) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException { try { - service.deleteMessage(queue, message, popReceipt); + service.deleteMessage(queue, messageId, popReceipt); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -326,9 +326,9 @@ public void deleteMessage(String queue, String message, String popReceipt) throw } } - public void deleteMessage(String queue, String message, String popReceipt, QueueServiceOptions options) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { try { - service.deleteMessage(queue, message, popReceipt, options); + service.deleteMessage(queue, messageId, popReceipt, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -361,5 +361,4 @@ public void clearMessages(String queue, QueueServiceOptions options) throws Serv throw processCatch(new ServiceException(e)); } } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java index cc8a84b481591..add37c9dce4d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java @@ -11,18 +11,18 @@ @XmlRootElement(name = "QueueMessagesList") public class ListMessagesResult { - private List messages; + private List entries; @XmlElement(name = "QueueMessage") - public List getMessages() { - return messages; + public List getEntries() { + return entries; } - public void setMessages(List messages) { - this.messages = messages; + public void setEntries(List entries) { + this.entries = entries; } - public static class QueueMessage { + public static class Entry { private String id; private Date insertionDate; private Date expirationDate; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java index d4e8e44ca7430..1ec031bc8c6a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java @@ -5,21 +5,24 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "QueueMessagesList") public class PeekMessagesResult { - private List messages; + private List entries; @XmlElement(name = "QueueMessage") - public List getMessages() { - return messages; + public List getEntries() { + return entries; } - public void setMessages(List messages) { - this.messages = messages; + public void setEntries(List entries) { + this.entries = entries; } - public static class QueueMessage { + public static class Entry { private String id; private Date insertionDate; private Date expirationDate; @@ -36,6 +39,7 @@ public void setId(String id) { } @XmlElement(name = "InsertionTime") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getInsertionDate() { return insertionDate; } @@ -45,6 +49,7 @@ public void setInsertionDate(Date insertionDate) { } @XmlElement(name = "ExpirationTime") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getExpirationDate() { return expirationDate; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 83b51c926dec2..6eaabc38a7ded 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -17,8 +17,11 @@ import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; +import com.microsoft.windowsazure.services.queue.models.ListMessagesResult.Entry; import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; import com.microsoft.windowsazure.services.queue.models.ListQueuesResult; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; +import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; public class QueueServiceIntegrationTest extends IntegrationTestBase { @@ -27,6 +30,8 @@ public class QueueServiceIntegrationTest extends IntegrationTestBase { private static String TEST_QUEUE_FOR_MESSAGES; private static String TEST_QUEUE_FOR_MESSAGES_2; private static String TEST_QUEUE_FOR_MESSAGES_3; + private static String TEST_QUEUE_FOR_MESSAGES_4; + private static String TEST_QUEUE_FOR_MESSAGES_5; private static String CREATABLE_QUEUE_1; private static String CREATABLE_QUEUE_2; private static String CREATABLE_QUEUE_3; @@ -50,6 +55,8 @@ public static void setup() throws Exception { TEST_QUEUE_FOR_MESSAGES = testQueues[0]; TEST_QUEUE_FOR_MESSAGES_2 = testQueues[1]; TEST_QUEUE_FOR_MESSAGES_3 = testQueues[2]; + TEST_QUEUE_FOR_MESSAGES_4 = testQueues[3]; + TEST_QUEUE_FOR_MESSAGES_5 = testQueues[4]; CREATABLE_QUEUE_1 = creatableQueues[0]; CREATABLE_QUEUE_2 = creatableQueues[1]; @@ -268,7 +275,7 @@ public void createMessageWorks() throws Exception { } @Test - public void listMessageWorks() throws Exception { + public void listMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); QueueServiceContract service = config.create(QueueServiceContract.class); @@ -286,21 +293,27 @@ public void listMessageWorks() throws Exception { // Assert assertNotNull(result); - assertEquals(1, result.getMessages().size()); - assertNotNull(result.getMessages().get(0).getId()); - assertNotNull(result.getMessages().get(0).getText()); - assertNotNull(result.getMessages().get(0).getExpirationDate()); - assertTrue(year2010.before(result.getMessages().get(0).getExpirationDate())); - assertNotNull(result.getMessages().get(0).getInsertionDate()); - assertTrue(year2010.before(result.getMessages().get(0).getInsertionDate())); - assertNotNull(result.getMessages().get(0).getPopReceipt()); - assertNotNull(result.getMessages().get(0).getTimeNextVisible()); - assertTrue(year2010.before(result.getMessages().get(0).getTimeNextVisible())); - assertTrue(1 <= result.getMessages().get(0).getDequeueCount()); + assertEquals(1, result.getEntries().size()); + + Entry entry = result.getEntries().get(0); + + assertNotNull(entry.getId()); + assertNotNull(entry.getText()); + assertNotNull(entry.getPopReceipt()); + assertEquals(1, entry.getDequeueCount()); + + assertNotNull(entry.getExpirationDate()); + assertTrue(year2010.before(entry.getExpirationDate())); + + assertNotNull(entry.getInsertionDate()); + assertTrue(year2010.before(entry.getInsertionDate())); + + assertNotNull(entry.getTimeNextVisible()); + assertTrue(year2010.before(entry.getTimeNextVisible())); } @Test - public void listMessageWithOptionsWorks() throws Exception { + public void listMessagesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); QueueServiceContract service = config.create(QueueServiceContract.class); @@ -319,18 +332,92 @@ public void listMessageWithOptionsWorks() throws Exception { // Assert assertNotNull(result); - assertEquals(4, result.getMessages().size()); + assertEquals(4, result.getEntries().size()); + for (int i = 0; i < 4; i++) { + Entry entry = result.getEntries().get(i); + + assertNotNull(entry.getId()); + assertNotNull(entry.getText()); + assertNotNull(entry.getPopReceipt()); + assertEquals(1, entry.getDequeueCount()); + + assertNotNull(entry.getExpirationDate()); + assertTrue(year2010.before(entry.getExpirationDate())); + + assertNotNull(entry.getInsertionDate()); + assertTrue(year2010.before(entry.getInsertionDate())); + + assertNotNull(entry.getTimeNextVisible()); + assertTrue(year2010.before(entry.getTimeNextVisible())); + } + } + + @Test + public void peekMessagesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + calendar.set(2010, 01, 01); + Date year2010 = calendar.getTime(); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_4, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_4, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_4, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_4, "message4"); + PeekMessagesResult result = service.peekMessages(TEST_QUEUE_FOR_MESSAGES_4); + + // Assert + assertNotNull(result); + assertEquals(1, result.getEntries().size()); + + com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.Entry entry = result.getEntries().get(0); + + assertNotNull(entry.getId()); + assertNotNull(entry.getText()); + assertEquals(0, entry.getDequeueCount()); + + assertNotNull(entry.getExpirationDate()); + assertTrue(year2010.before(entry.getExpirationDate())); + + assertNotNull(entry.getInsertionDate()); + assertTrue(year2010.before(entry.getInsertionDate())); + } + + @Test + public void peekMessagesWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + calendar.set(2010, 01, 01); + Date year2010 = calendar.getTime(); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_5, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_5, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_5, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_5, "message4"); + PeekMessagesResult result = service.peekMessages(TEST_QUEUE_FOR_MESSAGES_5, new PeekMessagesOptions().setNumberOfMessages(4)); + + // Assert + assertNotNull(result); + assertEquals(4, result.getEntries().size()); for (int i = 0; i < 4; i++) { - assertNotNull(result.getMessages().get(i).getId()); - assertNotNull(result.getMessages().get(i).getText()); - assertNotNull(result.getMessages().get(i).getExpirationDate()); - assertTrue(year2010.before(result.getMessages().get(i).getExpirationDate())); - assertNotNull(result.getMessages().get(i).getInsertionDate()); - assertTrue(year2010.before(result.getMessages().get(i).getInsertionDate())); - assertNotNull(result.getMessages().get(i).getPopReceipt()); - assertNotNull(result.getMessages().get(i).getTimeNextVisible()); - assertTrue(0 <= result.getMessages().get(i).getTimeNextVisible().getTime()); - assertTrue(1 <= result.getMessages().get(i).getDequeueCount()); + com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.Entry entry = result.getEntries().get(i); + + assertNotNull(entry.getId()); + assertNotNull(entry.getText()); + assertEquals(0, entry.getDequeueCount()); + + assertNotNull(entry.getExpirationDate()); + assertTrue(year2010.before(entry.getExpirationDate())); + + assertNotNull(entry.getInsertionDate()); + assertTrue(year2010.before(entry.getInsertionDate())); } } } From dcbd4dd8bf3f4c67cc5f20a99a2c7c3fddc09c10 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 11:01:18 -0800 Subject: [PATCH 13/29] Implement "clearMessages" --- .../implementation/QueueServiceForJersey.java | 9 +++-- .../queue/models/ListMessagesResult.java | 13 +++--- .../queue/models/ListQueuesResult.java | 3 +- .../queue/models/PeekMessagesResult.java | 13 +++--- .../queue/QueueServiceIntegrationTest.java | 40 ++++++++++++++----- 5 files changed, 53 insertions(+), 25 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index 3daa92f6e4fac..b044a3c73366b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -332,12 +332,15 @@ public void deleteMessage(String queue, String messageId, String popReceipt, Que } public void clearMessages(String queue) throws ServiceException { - // TODO Auto-generated method stub - + clearMessages(queue, new QueueServiceOptions()); } public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { - // TODO Auto-generated method stub + WebResource webResource = getResource(options).path(queue).path("messages"); + webResource = setCanonicalizedResource(webResource, null); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder.delete(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java index add37c9dce4d0..208c6f12fe1e9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java @@ -1,5 +1,6 @@ package com.microsoft.windowsazure.services.queue.models; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -11,18 +12,18 @@ @XmlRootElement(name = "QueueMessagesList") public class ListMessagesResult { - private List entries; + private List queueMessages = new ArrayList(); @XmlElement(name = "QueueMessage") - public List getEntries() { - return entries; + public List getQueueMessages() { + return queueMessages; } - public void setEntries(List entries) { - this.entries = entries; + public void setQueueMessages(List queueMessages) { + this.queueMessages = queueMessages; } - public static class Entry { + public static class QueueMessage { private String id; private Date insertionDate; private Date expirationDate; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java index 6568f642c4c5c..b550126aec2a6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java @@ -1,5 +1,6 @@ package com.microsoft.windowsazure.services.queue.models; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -13,7 +14,7 @@ @XmlRootElement(name = "EnumerationResults") public class ListQueuesResult { - private List queues; + private List queues = new ArrayList(); private String accountName; private String prefix; private String marker; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java index 1ec031bc8c6a2..afb4a0d3d5c6b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java @@ -1,5 +1,6 @@ package com.microsoft.windowsazure.services.queue.models; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -11,18 +12,18 @@ @XmlRootElement(name = "QueueMessagesList") public class PeekMessagesResult { - private List entries; + private List queueMessages = new ArrayList(); @XmlElement(name = "QueueMessage") - public List getEntries() { - return entries; + public List getQueueMessages() { + return queueMessages; } - public void setEntries(List entries) { - this.entries = entries; + public void setQueueMessages(List queueMessages) { + this.queueMessages = queueMessages; } - public static class Entry { + public static class QueueMessage { private String id; private Date insertionDate; private Date expirationDate; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 6eaabc38a7ded..50fab925a98a5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -17,7 +17,7 @@ import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; -import com.microsoft.windowsazure.services.queue.models.ListMessagesResult.Entry; +import com.microsoft.windowsazure.services.queue.models.ListMessagesResult.QueueMessage; import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; import com.microsoft.windowsazure.services.queue.models.ListQueuesResult; import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; @@ -32,6 +32,7 @@ public class QueueServiceIntegrationTest extends IntegrationTestBase { private static String TEST_QUEUE_FOR_MESSAGES_3; private static String TEST_QUEUE_FOR_MESSAGES_4; private static String TEST_QUEUE_FOR_MESSAGES_5; + private static String TEST_QUEUE_FOR_MESSAGES_6; private static String CREATABLE_QUEUE_1; private static String CREATABLE_QUEUE_2; private static String CREATABLE_QUEUE_3; @@ -57,6 +58,7 @@ public static void setup() throws Exception { TEST_QUEUE_FOR_MESSAGES_3 = testQueues[2]; TEST_QUEUE_FOR_MESSAGES_4 = testQueues[3]; TEST_QUEUE_FOR_MESSAGES_5 = testQueues[4]; + TEST_QUEUE_FOR_MESSAGES_6 = testQueues[5]; CREATABLE_QUEUE_1 = creatableQueues[0]; CREATABLE_QUEUE_2 = creatableQueues[1]; @@ -293,9 +295,9 @@ public void listMessagesWorks() throws Exception { // Assert assertNotNull(result); - assertEquals(1, result.getEntries().size()); + assertEquals(1, result.getQueueMessages().size()); - Entry entry = result.getEntries().get(0); + QueueMessage entry = result.getQueueMessages().get(0); assertNotNull(entry.getId()); assertNotNull(entry.getText()); @@ -332,9 +334,9 @@ public void listMessagesWithOptionsWorks() throws Exception { // Assert assertNotNull(result); - assertEquals(4, result.getEntries().size()); + assertEquals(4, result.getQueueMessages().size()); for (int i = 0; i < 4; i++) { - Entry entry = result.getEntries().get(i); + QueueMessage entry = result.getQueueMessages().get(i); assertNotNull(entry.getId()); assertNotNull(entry.getText()); @@ -371,9 +373,9 @@ public void peekMessagesWorks() throws Exception { // Assert assertNotNull(result); - assertEquals(1, result.getEntries().size()); + assertEquals(1, result.getQueueMessages().size()); - com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.Entry entry = result.getEntries().get(0); + com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result.getQueueMessages().get(0); assertNotNull(entry.getId()); assertNotNull(entry.getText()); @@ -405,9 +407,9 @@ public void peekMessagesWithOptionsWorks() throws Exception { // Assert assertNotNull(result); - assertEquals(4, result.getEntries().size()); + assertEquals(4, result.getQueueMessages().size()); for (int i = 0; i < 4; i++) { - com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.Entry entry = result.getEntries().get(i); + com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result.getQueueMessages().get(i); assertNotNull(entry.getId()); assertNotNull(entry.getText()); @@ -420,4 +422,24 @@ public void peekMessagesWithOptionsWorks() throws Exception { assertTrue(year2010.before(entry.getInsertionDate())); } } + + @Test + public void clearMessagesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_6, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_6, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_6, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_6, "message4"); + service.clearMessages(TEST_QUEUE_FOR_MESSAGES_6); + + PeekMessagesResult result = service.peekMessages(TEST_QUEUE_FOR_MESSAGES_6); + + // Assert + assertNotNull(result); + assertEquals(0, result.getQueueMessages().size()); + } } From b7b67e3007c452589f1c6017434cc060b5fb65c1 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 11:55:41 -0800 Subject: [PATCH 14/29] Implement "deleteMessage" and "updateMessage" --- .../implementation/QueueServiceForJersey.java | 33 +++++-- .../queue/models/ListMessagesResult.java | 20 ++--- .../queue/models/PeekMessagesResult.java | 20 ++--- .../queue/QueueServiceIntegrationTest.java | 85 +++++++++++++++++-- 4 files changed, 123 insertions(+), 35 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index b044a3c73366b..55ced89349f5d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -282,14 +282,29 @@ public void createMessage(String queue, String messageText, CreateMessageOptions public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) throws ServiceException { - // TODO Auto-generated method stub - return null; + return updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, new QueueServiceOptions()); } public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource webResource = getResource(options).path(queue).path("messages").path(messageId); + webResource = setCanonicalizedResource(webResource, null); + webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt); + webResource = addOptionalQueryParam(webResource, "visibilitytimeout", visibilityTimeoutInSeconds); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + QueueMessage queueMessage = new QueueMessage(); + queueMessage.setMessageText(messageText); + + // Note: Add content type here to enable proper HMAC signing + ClientResponse response = builder.type("application/xml").put(ClientResponse.class, queueMessage); + ThrowIfError(response); + + UpdateMessageResult result = new UpdateMessageResult(); + result.setPopReceipt(response.getHeaders().getFirst("x-ms-popreceipt")); + result.setTimeNextVisible(dateMapper.parseNoThrow(response.getHeaders().getFirst("x-ms-time-next-visible"))); + return result; } public ListMessagesResult listMessages(String queue) throws ServiceException { @@ -322,13 +337,17 @@ public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options } public void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException { - // TODO Auto-generated method stub - + deleteMessage(queue, messageId, popReceipt, new QueueServiceOptions()); } public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { - // TODO Auto-generated method stub + WebResource webResource = getResource(options).path(queue).path("messages").path(messageId); + webResource = setCanonicalizedResource(webResource, null); + webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder.delete(); } public void clearMessages(String queue) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java index 208c6f12fe1e9..a6c15fa584b11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java @@ -24,21 +24,21 @@ public void setQueueMessages(List queueMessages) { } public static class QueueMessage { - private String id; + private String messageId; private Date insertionDate; private Date expirationDate; private String popReceipt; private Date timeNextVisible; private int dequeueCount; - private String text; + private String messageText; @XmlElement(name = "MessageId") - public String getId() { - return id; + public String getMessageId() { + return messageId; } - public void setId(String id) { - this.id = id; + public void setMessageId(String messageId) { + this.messageId = messageId; } @XmlElement(name = "InsertionTime") @@ -90,12 +90,12 @@ public void setDequeueCount(int dequeueCount) { } @XmlElement(name = "MessageText") - public String getText() { - return text; + public String getMessageText() { + return messageText; } - public void setText(String text) { - this.text = text; + public void setMessageText(String messageText) { + this.messageText = messageText; } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java index afb4a0d3d5c6b..6a4a49b760975 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java @@ -24,19 +24,19 @@ public void setQueueMessages(List queueMessages) { } public static class QueueMessage { - private String id; + private String messageId; private Date insertionDate; private Date expirationDate; private int dequeueCount; - private String text; + private String messageText; @XmlElement(name = "MessageId") - public String getId() { - return id; + public String getMessageId() { + return messageId; } - public void setId(String id) { - this.id = id; + public void setMessageId(String messageId) { + this.messageId = messageId; } @XmlElement(name = "InsertionTime") @@ -69,12 +69,12 @@ public void setDequeueCount(int dequeueCount) { } @XmlElement(name = "MessageText") - public String getText() { - return text; + public String getMessageText() { + return messageText; } - public void setText(String text) { - this.text = text; + public void setMessageText(String messageText) { + this.messageText = messageText; } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 50fab925a98a5..fd181af9fedb0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -23,6 +23,7 @@ import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; +import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; public class QueueServiceIntegrationTest extends IntegrationTestBase { private static final String testQueuesPrefix = "sdktest-"; @@ -33,6 +34,8 @@ public class QueueServiceIntegrationTest extends IntegrationTestBase { private static String TEST_QUEUE_FOR_MESSAGES_4; private static String TEST_QUEUE_FOR_MESSAGES_5; private static String TEST_QUEUE_FOR_MESSAGES_6; + private static String TEST_QUEUE_FOR_MESSAGES_7; + private static String TEST_QUEUE_FOR_MESSAGES_8; private static String CREATABLE_QUEUE_1; private static String CREATABLE_QUEUE_2; private static String CREATABLE_QUEUE_3; @@ -59,6 +62,8 @@ public static void setup() throws Exception { TEST_QUEUE_FOR_MESSAGES_4 = testQueues[3]; TEST_QUEUE_FOR_MESSAGES_5 = testQueues[4]; TEST_QUEUE_FOR_MESSAGES_6 = testQueues[5]; + TEST_QUEUE_FOR_MESSAGES_7 = testQueues[6]; + TEST_QUEUE_FOR_MESSAGES_8 = testQueues[7]; CREATABLE_QUEUE_1 = creatableQueues[0]; CREATABLE_QUEUE_2 = creatableQueues[1]; @@ -299,8 +304,8 @@ public void listMessagesWorks() throws Exception { QueueMessage entry = result.getQueueMessages().get(0); - assertNotNull(entry.getId()); - assertNotNull(entry.getText()); + assertNotNull(entry.getMessageId()); + assertNotNull(entry.getMessageText()); assertNotNull(entry.getPopReceipt()); assertEquals(1, entry.getDequeueCount()); @@ -338,8 +343,8 @@ public void listMessagesWithOptionsWorks() throws Exception { for (int i = 0; i < 4; i++) { QueueMessage entry = result.getQueueMessages().get(i); - assertNotNull(entry.getId()); - assertNotNull(entry.getText()); + assertNotNull(entry.getMessageId()); + assertNotNull(entry.getMessageText()); assertNotNull(entry.getPopReceipt()); assertEquals(1, entry.getDequeueCount()); @@ -377,8 +382,8 @@ public void peekMessagesWorks() throws Exception { com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result.getQueueMessages().get(0); - assertNotNull(entry.getId()); - assertNotNull(entry.getText()); + assertNotNull(entry.getMessageId()); + assertNotNull(entry.getMessageText()); assertEquals(0, entry.getDequeueCount()); assertNotNull(entry.getExpirationDate()); @@ -411,8 +416,8 @@ public void peekMessagesWithOptionsWorks() throws Exception { for (int i = 0; i < 4; i++) { com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result.getQueueMessages().get(i); - assertNotNull(entry.getId()); - assertNotNull(entry.getText()); + assertNotNull(entry.getMessageId()); + assertNotNull(entry.getMessageText()); assertEquals(0, entry.getDequeueCount()); assertNotNull(entry.getExpirationDate()); @@ -442,4 +447,68 @@ public void clearMessagesWorks() throws Exception { assertNotNull(result); assertEquals(0, result.getQueueMessages().size()); } + + @Test + public void deleteMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_7, "message1"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_7, "message2"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_7, "message3"); + service.createMessage(TEST_QUEUE_FOR_MESSAGES_7, "message4"); + + ListMessagesResult result = service.listMessages(TEST_QUEUE_FOR_MESSAGES_7); + service.deleteMessage(TEST_QUEUE_FOR_MESSAGES_7, result.getQueueMessages().get(0).getMessageId(), result.getQueueMessages().get(0).getPopReceipt()); + ListMessagesResult result2 = service.listMessages(TEST_QUEUE_FOR_MESSAGES_7, new ListMessagesOptions().setNumberOfMessages(32)); + + // Assert + assertNotNull(result2); + assertEquals(3, result2.getQueueMessages().size()); + } + + @Test + public void updateMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueServiceContract service = config.create(QueueServiceContract.class); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + calendar.set(2010, 01, 01); + Date year2010 = calendar.getTime(); + + // Act + service.createMessage(TEST_QUEUE_FOR_MESSAGES_8, "message1"); + + ListMessagesResult listResult1 = service.listMessages(TEST_QUEUE_FOR_MESSAGES_8); + UpdateMessageResult updateResult = service.updateMessage(TEST_QUEUE_FOR_MESSAGES_8, listResult1.getQueueMessages().get(0).getMessageId(), listResult1 + .getQueueMessages().get(0).getPopReceipt(), "new text", 0); + ListMessagesResult listResult2 = service.listMessages(TEST_QUEUE_FOR_MESSAGES_8); + + // Assert + assertNotNull(updateResult); + assertNotNull(updateResult.getPopReceipt()); + assertNotNull(updateResult.getTimeNextVisible()); + assertTrue(year2010.before(updateResult.getTimeNextVisible())); + + assertNotNull(listResult2); + QueueMessage entry = listResult2.getQueueMessages().get(0); + + assertEquals(listResult1.getQueueMessages().get(0).getMessageId(), entry.getMessageId()); + assertEquals("new text", entry.getMessageText()); + assertNotNull(entry.getPopReceipt()); + assertEquals(2, entry.getDequeueCount()); + + assertNotNull(entry.getExpirationDate()); + assertTrue(year2010.before(entry.getExpirationDate())); + + assertNotNull(entry.getInsertionDate()); + assertTrue(year2010.before(entry.getInsertionDate())); + + assertNotNull(entry.getTimeNextVisible()); + assertTrue(year2010.before(entry.getTimeNextVisible())); + + } } From ec4c012e6457f3c8c6ad68d1844f64906ee79a50 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 12:27:07 -0800 Subject: [PATCH 15/29] Moving shared code to "JerseyHelpers" --- .../implementation/BlobServiceForJersey.java | 113 ++------------ .../blob/implementation/JerseyHelpers.java | 138 ++++++++++++++++++ .../implementation/QueueServiceForJersey.java | 45 +----- 3 files changed, 159 insertions(+), 137 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index 14bf67811b500..6357f8c542ac9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -2,11 +2,8 @@ import java.io.InputStream; import java.util.Arrays; -import java.util.EnumSet; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; import javax.inject.Inject; import javax.inject.Named; @@ -15,7 +12,6 @@ import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.blob.AccessCondition; -import com.microsoft.windowsazure.services.blob.AccessConditionHeaderType; import com.microsoft.windowsazure.services.blob.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.BlobListingDetails; @@ -56,9 +52,9 @@ import com.microsoft.windowsazure.services.blob.SetBlobPropertiesOptions; import com.microsoft.windowsazure.services.blob.SetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.SetContainerMetadataOptions; +import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.core.util.Base64; @@ -108,97 +104,39 @@ public BlobService withFilter(ServiceFilter filter) { } private void ThrowIfError(ClientResponse r) { - if (r.getStatus() >= 300) { - throw new UniformInterfaceException(r); - } - } - - private class EnumCommaStringBuilder> { - private final StringBuilder sb = new StringBuilder(); - - public void addValue(EnumSet enumSet, E value, String representation) { - if (enumSet.contains(value)) { - if (sb.length() >= 0) { - sb.append(","); - } - sb.append(representation); - } - } - - @Override - public String toString() { - return sb.toString(); - } + JerseyHelpers.ThrowIfError(r); } private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - if (value != null) { - webResource = webResource.queryParam(key, value.toString()); - } - return webResource; + return JerseyHelpers.addOptionalQueryParam(webResource, key, value); } private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - if (value != defaultValue) { - webResource = webResource.queryParam(key, Integer.toString(value)); - } - return webResource; + return JerseyHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); } private Builder addOptionalHeader(Builder builder, String name, Object value) { - if (value != null) { - builder = builder.header(name, value); - } - return builder; + return JerseyHelpers.addOptionalHeader(builder, name, value); } private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - for (Entry entry : metadata.entrySet()) { - builder = builder.header("x-ms-meta-" + entry.getKey(), entry.getValue()); - } - return builder; + return JerseyHelpers.addOptionalMetadataHeader(builder, metadata); } private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { - if (rangeStart != null) { - String range = rangeStart.toString() + "-"; - if (rangeEnd != null) { - range += rangeEnd.toString(); - } - builder = addOptionalHeader(builder, "Range", "bytes=" + range); - } - return builder; + return JerseyHelpers.addOptionalRangeHeader(builder, rangeStart, rangeEnd); } private Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - if (accessCondition != null) { - if (accessCondition.getHeader() != AccessConditionHeaderType.NONE) { - builder = addOptionalHeader(builder, accessCondition.getHeader().toString(), accessCondition.getValue()); - } - } - return builder; + return JerseyHelpers.addOptionalAccessContitionHeader(builder, accessCondition); } private Builder addOptionalSourceAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - if (accessCondition != null) { - if (accessCondition.getHeader() != AccessConditionHeaderType.NONE) { - String headerName; - switch (accessCondition.getHeader()) { - case IF_MATCH: - headerName = "x-ms-source-if-match"; - case IF_UNMODIFIED_SINCE: - headerName = "x-ms-source-if-unmodified-since"; - case IF_MODIFIED_SINCE: - headerName = "x-ms-source-if-modified-since"; - case IF_NONE_MATCH: - headerName = "x-ms-source-if-none-match"; - default: - headerName = ""; - } - builder = addOptionalHeader(builder, headerName, accessCondition.getValue()); - } - } - return builder; + return JerseyHelpers.addOptionalSourceAccessContitionHeader(builder, accessCondition); + } + + private HashMap getMetadataFromHeaders(ClientResponse response) { + return JerseyHelpers.getMetadataFromHeaders(response); } private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { @@ -250,18 +188,6 @@ private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { return properties; } - private HashMap getMetadataFromHeaders(ClientResponse response) { - HashMap metadata = new HashMap(); - for (Entry> entry : response.getHeaders().entrySet()) { - if (entry.getKey().startsWith("x-ms-meta-")) { - String name = entry.getKey().substring("x-ms-meta-".length()); - String value = entry.getValue().get(0); - metadata.put(name, value); - } - } - return metadata; - } - private WebResource getResource(BlobOptions options) { WebResource webResource = channel.resource(url).path("/"); webResource = addOptionalQueryParam(webResource, "timeout", options.getTimeout()); @@ -273,18 +199,7 @@ private WebResource getResource(BlobOptions options) { } private WebResource setCanonicalizedResource(WebResource webResource, String operation) { - // Resource path - String value = "/" + this.accountName; - value += webResource.getURI().getPath(); - - // "comp" param - if (operation != null) { - value += "?comp=" + operation; - } - - webResource.setProperty("canonicalizedResource", value); - - return webResource; + return JerseyHelpers.setCanonicalizedResource(webResource, this.accountName, operation); } private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java new file mode 100644 index 0000000000000..a04cd08a38b67 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java @@ -0,0 +1,138 @@ +package com.microsoft.windowsazure.services.blob.implementation; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.services.blob.AccessCondition; +import com.microsoft.windowsazure.services.blob.AccessConditionHeaderType; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.UniformInterfaceException; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.WebResource.Builder; + +public class JerseyHelpers { + public static void ThrowIfError(ClientResponse r) { + if (r.getStatus() >= 300) { + throw new UniformInterfaceException(r); + } + } + + public static WebResource setCanonicalizedResource(WebResource webResource, String accountName, String operation) { + // Resource path + String value = "/" + accountName; + value += webResource.getURI().getPath(); + + // "comp" param + if (operation != null) { + value += "?comp=" + operation; + } + + webResource.setProperty("canonicalizedResource", value); + + return webResource; + } + + public static class EnumCommaStringBuilder> { + private final StringBuilder sb = new StringBuilder(); + + public void addValue(EnumSet enumSet, E value, String representation) { + if (enumSet.contains(value)) { + if (sb.length() >= 0) { + sb.append(","); + } + sb.append(representation); + } + } + + @Override + public String toString() { + return sb.toString(); + } + } + + public static WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { + if (value != null) { + webResource = webResource.queryParam(key, value.toString()); + } + return webResource; + } + + public static WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { + if (value != defaultValue) { + webResource = webResource.queryParam(key, Integer.toString(value)); + } + return webResource; + } + + public static Builder addOptionalHeader(Builder builder, String name, Object value) { + if (value != null) { + builder = builder.header(name, value); + } + return builder; + } + + public static Builder addOptionalMetadataHeader(Builder builder, Map metadata) { + for (Entry entry : metadata.entrySet()) { + builder = builder.header("x-ms-meta-" + entry.getKey(), entry.getValue()); + } + return builder; + } + + public static Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { + if (rangeStart != null) { + String range = rangeStart.toString() + "-"; + if (rangeEnd != null) { + range += rangeEnd.toString(); + } + builder = addOptionalHeader(builder, "Range", "bytes=" + range); + } + return builder; + } + + public static Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { + if (accessCondition != null) { + if (accessCondition.getHeader() != AccessConditionHeaderType.NONE) { + builder = addOptionalHeader(builder, accessCondition.getHeader().toString(), accessCondition.getValue()); + } + } + return builder; + } + + public static Builder addOptionalSourceAccessContitionHeader(Builder builder, AccessCondition accessCondition) { + if (accessCondition != null) { + if (accessCondition.getHeader() != AccessConditionHeaderType.NONE) { + String headerName; + switch (accessCondition.getHeader()) { + case IF_MATCH: + headerName = "x-ms-source-if-match"; + case IF_UNMODIFIED_SINCE: + headerName = "x-ms-source-if-unmodified-since"; + case IF_MODIFIED_SINCE: + headerName = "x-ms-source-if-modified-since"; + case IF_NONE_MATCH: + headerName = "x-ms-source-if-none-match"; + default: + headerName = ""; + } + builder = addOptionalHeader(builder, headerName, accessCondition.getValue()); + } + } + return builder; + } + + public static HashMap getMetadataFromHeaders(ClientResponse response) { + HashMap metadata = new HashMap(); + for (Entry> entry : response.getHeaders().entrySet()) { + if (entry.getKey().startsWith("x-ms-meta-")) { + String name = entry.getKey().substring("x-ms-meta-".length()); + String value = entry.getValue().get(0); + metadata.put(name, value); + } + } + return metadata; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index 55ced89349f5d..4ef1f2a0ec50f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -2,19 +2,15 @@ import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; import javax.inject.Inject; import javax.inject.Named; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers; import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; import com.microsoft.windowsazure.services.queue.QueueConfiguration; import com.microsoft.windowsazure.services.queue.QueueServiceContract; @@ -32,12 +28,11 @@ import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; public class QueueServiceForJersey implements QueueServiceContract { - private static Log log = LogFactory.getLog(QueueServiceForJersey.class); + //private static Log log = LogFactory.getLog(QueueServiceForJersey.class); private static final String API_VERSION = "2011-08-18"; private final Client channel; @@ -81,49 +76,23 @@ public QueueServiceContract withFilter(ServiceFilter filter) { } private void ThrowIfError(ClientResponse r) { - if (r.getStatus() >= 300) { - throw new UniformInterfaceException(r); - } + JerseyHelpers.ThrowIfError(r); } private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - if (value != null) { - webResource = webResource.queryParam(key, value.toString()); - } - return webResource; + return JerseyHelpers.addOptionalQueryParam(webResource, key, value); } private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - if (value != defaultValue) { - webResource = webResource.queryParam(key, Integer.toString(value)); - } - return webResource; - } - - private Builder addOptionalHeader(Builder builder, String name, Object value) { - if (value != null) { - builder = builder.header(name, value); - } - return builder; + return JerseyHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); } private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - for (Entry entry : metadata.entrySet()) { - builder = builder.header("x-ms-meta-" + entry.getKey(), entry.getValue()); - } - return builder; + return JerseyHelpers.addOptionalMetadataHeader(builder, metadata); } private HashMap getMetadataFromHeaders(ClientResponse response) { - HashMap metadata = new HashMap(); - for (Entry> entry : response.getHeaders().entrySet()) { - if (entry.getKey().startsWith("x-ms-meta-")) { - String name = entry.getKey().substring("x-ms-meta-".length()); - String value = entry.getValue().get(0); - metadata.put(name, value); - } - } - return metadata; + return JerseyHelpers.getMetadataFromHeaders(response); } private WebResource getResource(QueueServiceOptions options) { From 488b00edc6dcc01ff5dceba0784b661537b36e52 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 12:30:21 -0800 Subject: [PATCH 16/29] Move data classes to "models" package --- ...bService.java => BlobServiceContract.java} | 42 +++++- .../windowsazure/services/blob/Exports.java | 2 +- .../implementation/BlobServiceForJersey.java | 84 +++++------ .../blob/implementation/BlobServiceImpl.java | 82 +++++----- .../blob/implementation/JerseyHelpers.java | 4 +- .../blob/{ => models}/AccessCondition.java | 2 +- .../AccessConditionHeaderType.java | 2 +- .../{ => models}/AcquireLeaseOptions.java | 2 +- .../blob/{ => models}/BlobListingDetails.java | 2 +- .../blob/{ => models}/BlobOptions.java | 2 +- .../blob/{ => models}/BlobProperties.java | 2 +- .../blob/{ => models}/BlobSnapshot.java | 2 +- .../services/blob/{ => models}/BlockList.java | 2 +- .../{ => models}/CommitBlobBlocksOptions.java | 2 +- .../blob/{ => models}/ContainerACL.java | 2 +- .../{ => models}/ContainerListingDetails.java | 2 +- .../{ => models}/ContainerProperties.java | 2 +- .../blob/{ => models}/CopyBlobOptions.java | 2 +- .../{ => models}/CreateBlobBlockOptions.java | 2 +- .../blob/{ => models}/CreateBlobOptions.java | 2 +- .../{ => models}/CreateBlobPagesOptions.java | 2 +- .../{ => models}/CreateBlobPagesResult.java | 2 +- .../CreateBlobSnapshotOptions.java | 2 +- .../{ => models}/CreateContainerOptions.java | 2 +- .../blob/{ => models}/DeleteBlobOptions.java | 2 +- .../{ => models}/DeleteContainerOptions.java | 2 +- .../{ => models}/GetBlobMetadataOptions.java | 3 +- .../{ => models}/GetBlobMetadataResult.java | 2 +- .../blob/{ => models}/GetBlobOptions.java | 3 +- .../GetBlobPropertiesOptions.java | 3 +- .../blob/{ => models}/GetBlobResult.java | 3 +- .../{ => models}/ListBlobBlocksOptions.java | 3 +- .../{ => models}/ListBlobBlocksResult.java | 2 +- .../{ => models}/ListBlobRegionsOptions.java | 3 +- .../{ => models}/ListBlobRegionsResult.java | 2 +- .../blob/{ => models}/ListBlobsOptions.java | 3 +- .../blob/{ => models}/ListBlobsResult.java | 2 +- .../{ => models}/ListContainersOptions.java | 3 +- .../{ => models}/ListContainersResult.java | 2 +- .../blob/{ => models}/ServiceProperties.java | 2 +- .../{ => models}/SetBlobMetadataOptions.java | 3 +- .../{ => models}/SetBlobMetadataResult.java | 2 +- .../SetBlobPropertiesOptions.java | 3 +- .../{ => models}/SetBlobPropertiesResult.java | 2 +- .../SetContainerMetadataOptions.java | 3 +- .../blob/BlobServiceIntegrationTest.java | 140 +++++++++--------- 46 files changed, 246 insertions(+), 199 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{BlobService.java => BlobServiceContract.java} (71%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/AccessCondition.java (99%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/AccessConditionHeaderType.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/AcquireLeaseOptions.java (86%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/BlobListingDetails.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/BlobOptions.java (82%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/BlobProperties.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/BlobSnapshot.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/BlockList.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CommitBlobBlocksOptions.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ContainerACL.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ContainerListingDetails.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ContainerProperties.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CopyBlobOptions.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CreateBlobBlockOptions.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CreateBlobOptions.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CreateBlobPagesOptions.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CreateBlobPagesResult.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CreateBlobSnapshotOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/CreateContainerOptions.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/DeleteBlobOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/DeleteContainerOptions.java (86%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/GetBlobMetadataOptions.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/GetBlobMetadataResult.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/GetBlobOptions.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/GetBlobPropertiesOptions.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/GetBlobResult.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListBlobBlocksOptions.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListBlobBlocksResult.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListBlobRegionsOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListBlobRegionsResult.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListBlobsOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListBlobsResult.java (99%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListContainersOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ListContainersResult.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/ServiceProperties.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/SetBlobMetadataOptions.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/SetBlobMetadataResult.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/SetBlobPropertiesOptions.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/SetBlobPropertiesResult.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{ => models}/SetContainerMetadataOptions.java (86%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java similarity index 71% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java index 2ed07255c9509..ca8350474311e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java @@ -5,9 +5,45 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; - -public interface BlobService { - BlobService withFilter(ServiceFilter filter); +import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; +import com.microsoft.windowsazure.services.blob.models.BlobOptions; +import com.microsoft.windowsazure.services.blob.models.BlobProperties; +import com.microsoft.windowsazure.services.blob.models.BlobSnapshot; +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ContainerACL; +import com.microsoft.windowsazure.services.blob.models.ContainerProperties; +import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; +import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions; +import com.microsoft.windowsazure.services.blob.models.DeleteBlobOptions; +import com.microsoft.windowsazure.services.blob.models.DeleteContainerOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; +import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; +import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.ServiceProperties; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; +import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; + +public interface BlobServiceContract { + BlobServiceContract withFilter(ServiceFilter filter); ServiceProperties getServiceProperties() throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java index 7ddaa2dc3a72b..f921e376dee2f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java @@ -7,7 +7,7 @@ public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { - registry.add(BlobService.class, BlobServiceImpl.class); + registry.add(BlobServiceContract.class, BlobServiceImpl.class); registry.add(BlobServiceForJersey.class); registry.add(SharedKeyLiteFilter.class); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index 6357f8c542ac9..b7ff8b3ad7062 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -11,55 +11,55 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.blob.AccessCondition; -import com.microsoft.windowsazure.services.blob.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.BlobConfiguration; -import com.microsoft.windowsazure.services.blob.BlobListingDetails; -import com.microsoft.windowsazure.services.blob.BlobOptions; -import com.microsoft.windowsazure.services.blob.BlobProperties; -import com.microsoft.windowsazure.services.blob.BlobService; -import com.microsoft.windowsazure.services.blob.BlobSnapshot; -import com.microsoft.windowsazure.services.blob.BlockList; -import com.microsoft.windowsazure.services.blob.CommitBlobBlocksOptions; -import com.microsoft.windowsazure.services.blob.ContainerACL; -import com.microsoft.windowsazure.services.blob.ContainerListingDetails; -import com.microsoft.windowsazure.services.blob.ContainerProperties; -import com.microsoft.windowsazure.services.blob.CopyBlobOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobBlockOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobPagesOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobPagesResult; -import com.microsoft.windowsazure.services.blob.CreateBlobSnapshotOptions; -import com.microsoft.windowsazure.services.blob.CreateContainerOptions; -import com.microsoft.windowsazure.services.blob.DeleteBlobOptions; -import com.microsoft.windowsazure.services.blob.DeleteContainerOptions; -import com.microsoft.windowsazure.services.blob.GetBlobMetadataOptions; -import com.microsoft.windowsazure.services.blob.GetBlobMetadataResult; -import com.microsoft.windowsazure.services.blob.GetBlobOptions; -import com.microsoft.windowsazure.services.blob.GetBlobPropertiesOptions; -import com.microsoft.windowsazure.services.blob.GetBlobResult; -import com.microsoft.windowsazure.services.blob.ListBlobBlocksOptions; -import com.microsoft.windowsazure.services.blob.ListBlobBlocksResult; -import com.microsoft.windowsazure.services.blob.ListBlobRegionsOptions; -import com.microsoft.windowsazure.services.blob.ListBlobRegionsResult; -import com.microsoft.windowsazure.services.blob.ListBlobsOptions; -import com.microsoft.windowsazure.services.blob.ListBlobsResult; -import com.microsoft.windowsazure.services.blob.ListContainersOptions; -import com.microsoft.windowsazure.services.blob.ListContainersResult; -import com.microsoft.windowsazure.services.blob.ServiceProperties; -import com.microsoft.windowsazure.services.blob.SetBlobMetadataOptions; -import com.microsoft.windowsazure.services.blob.SetBlobMetadataResult; -import com.microsoft.windowsazure.services.blob.SetBlobPropertiesOptions; -import com.microsoft.windowsazure.services.blob.SetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.SetContainerMetadataOptions; +import com.microsoft.windowsazure.services.blob.BlobServiceContract; import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers.EnumCommaStringBuilder; +import com.microsoft.windowsazure.services.blob.models.AccessCondition; +import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; +import com.microsoft.windowsazure.services.blob.models.BlobListingDetails; +import com.microsoft.windowsazure.services.blob.models.BlobOptions; +import com.microsoft.windowsazure.services.blob.models.BlobProperties; +import com.microsoft.windowsazure.services.blob.models.BlobSnapshot; +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ContainerACL; +import com.microsoft.windowsazure.services.blob.models.ContainerListingDetails; +import com.microsoft.windowsazure.services.blob.models.ContainerProperties; +import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; +import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions; +import com.microsoft.windowsazure.services.blob.models.DeleteBlobOptions; +import com.microsoft.windowsazure.services.blob.models.DeleteContainerOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; +import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; +import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.ServiceProperties; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; +import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.core.util.Base64; -public class BlobServiceForJersey implements BlobService { +public class BlobServiceForJersey implements BlobServiceContract { // private static Log log = LogFactory.getLog(BlobServiceForJersey.class); private static final String API_VERSION = "2011-08-18"; @@ -97,7 +97,7 @@ public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String acco this.dateMapper = dateMapper; } - public BlobService withFilter(ServiceFilter filter) { + public BlobServiceContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; return new BlobServiceForJersey(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java index ae119143d7ac6..4137cdaeb79e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java @@ -10,61 +10,61 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.blob.AcquireLeaseOptions; -import com.microsoft.windowsazure.services.blob.BlobOptions; -import com.microsoft.windowsazure.services.blob.BlobProperties; -import com.microsoft.windowsazure.services.blob.BlobService; -import com.microsoft.windowsazure.services.blob.BlobSnapshot; -import com.microsoft.windowsazure.services.blob.BlockList; -import com.microsoft.windowsazure.services.blob.CommitBlobBlocksOptions; -import com.microsoft.windowsazure.services.blob.ContainerACL; -import com.microsoft.windowsazure.services.blob.ContainerProperties; -import com.microsoft.windowsazure.services.blob.CopyBlobOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobBlockOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobPagesOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobPagesResult; -import com.microsoft.windowsazure.services.blob.CreateBlobSnapshotOptions; -import com.microsoft.windowsazure.services.blob.CreateContainerOptions; -import com.microsoft.windowsazure.services.blob.DeleteBlobOptions; -import com.microsoft.windowsazure.services.blob.DeleteContainerOptions; -import com.microsoft.windowsazure.services.blob.GetBlobMetadataOptions; -import com.microsoft.windowsazure.services.blob.GetBlobMetadataResult; -import com.microsoft.windowsazure.services.blob.GetBlobOptions; -import com.microsoft.windowsazure.services.blob.GetBlobPropertiesOptions; -import com.microsoft.windowsazure.services.blob.GetBlobResult; -import com.microsoft.windowsazure.services.blob.ListBlobBlocksOptions; -import com.microsoft.windowsazure.services.blob.ListBlobBlocksResult; -import com.microsoft.windowsazure.services.blob.ListBlobRegionsOptions; -import com.microsoft.windowsazure.services.blob.ListBlobRegionsResult; -import com.microsoft.windowsazure.services.blob.ListBlobsOptions; -import com.microsoft.windowsazure.services.blob.ListBlobsResult; -import com.microsoft.windowsazure.services.blob.ListContainersOptions; -import com.microsoft.windowsazure.services.blob.ListContainersResult; -import com.microsoft.windowsazure.services.blob.ServiceProperties; -import com.microsoft.windowsazure.services.blob.SetBlobMetadataOptions; -import com.microsoft.windowsazure.services.blob.SetBlobMetadataResult; -import com.microsoft.windowsazure.services.blob.SetBlobPropertiesOptions; -import com.microsoft.windowsazure.services.blob.SetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.SetContainerMetadataOptions; +import com.microsoft.windowsazure.services.blob.BlobServiceContract; +import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; +import com.microsoft.windowsazure.services.blob.models.BlobOptions; +import com.microsoft.windowsazure.services.blob.models.BlobProperties; +import com.microsoft.windowsazure.services.blob.models.BlobSnapshot; +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ContainerACL; +import com.microsoft.windowsazure.services.blob.models.ContainerProperties; +import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; +import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions; +import com.microsoft.windowsazure.services.blob.models.DeleteBlobOptions; +import com.microsoft.windowsazure.services.blob.models.DeleteContainerOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; +import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; +import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.ServiceProperties; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; +import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; -public class BlobServiceImpl implements BlobService { +public class BlobServiceImpl implements BlobServiceContract { private static Log log = LogFactory.getLog(BlobServiceImpl.class); - private final BlobService service; + private final BlobServiceContract service; @Inject public BlobServiceImpl(BlobServiceForJersey service) { this.service = service; } - public BlobServiceImpl(BlobService service) { + public BlobServiceImpl(BlobServiceContract service) { this.service = service; } - public BlobService withFilter(ServiceFilter filter) { + public BlobServiceContract withFilter(ServiceFilter filter) { return new BlobServiceImpl(service.withFilter(filter)); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java index a04cd08a38b67..134b881c11f43 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java @@ -6,8 +6,8 @@ import java.util.Map; import java.util.Map.Entry; -import com.microsoft.windowsazure.services.blob.AccessCondition; -import com.microsoft.windowsazure.services.blob.AccessConditionHeaderType; +import com.microsoft.windowsazure.services.blob.models.AccessCondition; +import com.microsoft.windowsazure.services.blob.models.AccessConditionHeaderType; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessCondition.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java index 14584b02b235e..c53b2e6fdf792 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessConditionHeaderType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessConditionHeaderType.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java index d7853e9af2008..039cfe333b65d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessConditionHeaderType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; /** * Specifies the kinds of conditional headers that may be set for a request. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AcquireLeaseOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java index 1c8c12e0c7ce7..6bdd5a1f42fe7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AcquireLeaseOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; public class AcquireLeaseOptions extends BlobOptions { private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobListingDetails.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java index 89a47338fa333..e072f5461c956 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; /** * Specifies which items to include when listing a set of blobs. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobOptions.java similarity index 82% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobOptions.java index 33bdb70c4447d..3c8776fc2d31b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; public class BlobOptions { // Nullable because it is optional diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java index 5b2e4a7a3c91b..e353c29535a55 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobSnapshot.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobSnapshot.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobSnapshot.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobSnapshot.java index b899fc651eef5..dff571ea12d36 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobSnapshot.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobSnapshot.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlockList.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java index 6538b4e147f3e..2ef2c88a0a32b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CommitBlobBlocksOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java index f2361c346b712..697dfa35bf94a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerACL.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java index fd0e57145bfd2..6f4dd818f30be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerListingDetails.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java index e701554e2e637..50c98d2086f14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; /** * Specifies which details to include when listing the containers in this diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerProperties.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerProperties.java index ed609dbcc1c0c..0290ce7f0c321 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CopyBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java index a9fc887f5d35a..b9395f795863a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobBlockOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobBlockOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java index db6735b76c3ab..0f25894e62937 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobBlockOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; public class CreateBlobBlockOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java index 2832661fc240d..61d27d18b7735 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java index 6237569fa5a72..9872b4afdb74f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; public class CreateBlobPagesOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java index 23c9ab30ee740..62501762488ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobSnapshotOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java index a55d69c079679..830a37c5686be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateContainerOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java index dde34928563d0..ef71fdfd25790 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java index 64af6ad591b41..958107affc335 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; public class DeleteBlobOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteContainerOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java index 6f02b58a560e3..961cea84f6070 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; public class DeleteContainerOptions extends BlobOptions { private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java index 1b688fd5e2bb0..228817a339db1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class GetBlobMetadataOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java index c6182e85b70cf..85c0be6125871 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java index 3664c4fb9711c..3641660a31b6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class GetBlobOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobPropertiesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java index 01bac1ef65565..b9ea3376a02d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class GetBlobPropertiesOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java index 3771d9e8ea259..3d301d9457b95 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java @@ -1,7 +1,8 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.io.InputStream; + public class GetBlobResult { private InputStream contentStream; private BlobProperties properties; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java index 52f56a25ed531..c91ca2d721604 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class ListBlobBlocksOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java index 18247d2469bf2..952ef9a004686 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java index 6720f89692b55..402914579b0fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class ListBlobRegionsOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java index 54b311c0c3c9e..a6bee480a8f3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java index 87cfacec5ad9e..b023767002463 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java @@ -1,7 +1,8 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.EnumSet; + public class ListBlobsOptions extends BlobOptions { private String prefix; private String marker; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java index c78d44053cdcb..8b8f02cc0c8c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java index 57e05cdc3ed80..e0a008c050ed5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java @@ -1,7 +1,8 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.EnumSet; + public class ListContainersOptions extends BlobOptions { private String prefix; private String marker; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java index 5d391c711b21c..d55c9fde184e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ServiceProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java index 2ed57fbf7599c..4718fb59c34b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java index 890104b535136..592ab9c7ea08e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class SetBlobMetadataOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java index 3484a65d7ec26..0bde3e5734eb0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java index caf14d1a30be0..39bd2109712c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class SetBlobPropertiesOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java index 74a001310fbc1..49e2d7eaee7ce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetContainerMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetContainerMetadataOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java index 3ad16c234e6fa..3c9f4b7a6a277 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetContainerMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.blob; +package com.microsoft.windowsazure.services.blob.models; + public class SetContainerMetadataOptions extends BlobOptions { private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 6685c3caa4b74..6076a8478ab82 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -26,33 +26,33 @@ import com.microsoft.windowsazure.common.ExponentialRetryPolicyFilter; import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.blob.AccessCondition; -import com.microsoft.windowsazure.services.blob.BlobProperties; -import com.microsoft.windowsazure.services.blob.BlobService; -import com.microsoft.windowsazure.services.blob.BlobSnapshot; -import com.microsoft.windowsazure.services.blob.BlockList; -import com.microsoft.windowsazure.services.blob.ContainerACL; -import com.microsoft.windowsazure.services.blob.ContainerListingDetails; -import com.microsoft.windowsazure.services.blob.ContainerProperties; -import com.microsoft.windowsazure.services.blob.CreateBlobOptions; -import com.microsoft.windowsazure.services.blob.CreateBlobPagesResult; -import com.microsoft.windowsazure.services.blob.CreateBlobSnapshotOptions; -import com.microsoft.windowsazure.services.blob.CreateContainerOptions; -import com.microsoft.windowsazure.services.blob.GetBlobMetadataResult; -import com.microsoft.windowsazure.services.blob.GetBlobOptions; -import com.microsoft.windowsazure.services.blob.GetBlobPropertiesOptions; -import com.microsoft.windowsazure.services.blob.GetBlobResult; -import com.microsoft.windowsazure.services.blob.ListBlobBlocksOptions; -import com.microsoft.windowsazure.services.blob.ListBlobBlocksResult; -import com.microsoft.windowsazure.services.blob.ListBlobRegionsResult; -import com.microsoft.windowsazure.services.blob.ListBlobsOptions; -import com.microsoft.windowsazure.services.blob.ListBlobsResult; -import com.microsoft.windowsazure.services.blob.ListContainersOptions; -import com.microsoft.windowsazure.services.blob.ListContainersResult; -import com.microsoft.windowsazure.services.blob.ServiceProperties; -import com.microsoft.windowsazure.services.blob.SetBlobMetadataResult; -import com.microsoft.windowsazure.services.blob.SetBlobPropertiesOptions; -import com.microsoft.windowsazure.services.blob.SetBlobPropertiesResult; +import com.microsoft.windowsazure.services.blob.BlobServiceContract; +import com.microsoft.windowsazure.services.blob.models.AccessCondition; +import com.microsoft.windowsazure.services.blob.models.BlobProperties; +import com.microsoft.windowsazure.services.blob.models.BlobSnapshot; +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.ContainerACL; +import com.microsoft.windowsazure.services.blob.models.ContainerListingDetails; +import com.microsoft.windowsazure.services.blob.models.ContainerProperties; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; +import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions; +import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; +import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; +import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.ServiceProperties; +import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; public class BlobServiceIntegrationTest extends IntegrationTestBase { private static final String testContainersPrefix = "sdktest-"; @@ -92,7 +92,7 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); for (int i = 0; i < testContainers.length; i++) { try { service.createContainer(testContainers[i]); @@ -111,7 +111,7 @@ public static void setup() throws Exception { @AfterClass public static void cleanup() throws Exception { Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); for (int i = 0; i < testContainers.length; i++) { try { service.deleteContainer(testContainers[i]); @@ -135,7 +135,7 @@ public static void cleanup() throws Exception { public void getServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ServiceProperties props = service.getServiceProperties(); @@ -153,7 +153,7 @@ public void getServiceProppertiesWorks() throws Exception { public void setServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ServiceProperties props = service.getServiceProperties(); @@ -179,7 +179,7 @@ public void setServiceProppertiesWorks() throws Exception { public void createContainerWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createContainer(CREATEABLE_CONTAINER_1); @@ -191,7 +191,7 @@ public void createContainerWorks() throws Exception { public void createContainerWithMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createContainer(CREATEABLE_CONTAINER_2, @@ -242,7 +242,7 @@ public void createContainerWithMetadataWorks() throws Exception { public void setContainerMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createContainer(CREATEABLE_CONTAINER_3); @@ -269,7 +269,7 @@ public void setContainerMetadataWorks() throws Exception { public void setContainerACLWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); String container = CREATEABLE_CONTAINER_4; Date expiryStartDate = new GregorianCalendar(2010, 1, 1).getTime(); @@ -303,7 +303,7 @@ public void setContainerACLWorks() throws Exception { public void listContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ListContainersResult results = service.listContainers(); @@ -323,7 +323,7 @@ public void listContainersWorks() throws Exception { public void listContainersWithPaginationWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); @@ -345,7 +345,7 @@ public void listContainersWithPaginationWorks() throws Exception { public void listContainersWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix(testContainersPrefix).setMaxResults(3)); @@ -369,7 +369,7 @@ public void listContainersWithPrefixWorks() throws Exception { public void listBlobsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING); @@ -383,7 +383,7 @@ public void listBlobsWorks() throws Exception { public void listBlobsWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setPrefix("myblob")); @@ -397,7 +397,7 @@ public void listBlobsWithPrefixWorks() throws Exception { public void createPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512); @@ -409,7 +409,7 @@ public void createPageBlobWorks() throws Exception { public void createPageBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") @@ -440,7 +440,7 @@ public void createPageBlobWithOptionsWorks() throws Exception { public void clearBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -461,7 +461,7 @@ public void clearBlobPagesWorks() throws Exception { public void createBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -483,7 +483,7 @@ public void createBlobPagesWorks() throws Exception { public void listBlobRegionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -519,7 +519,7 @@ public void listBlobRegionsWorks() throws Exception { public void listBlobBlocksOnEmptyBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -544,7 +544,7 @@ public void listBlobBlocksOnEmptyBlobWorks() throws Exception { public void listBlobBlocksWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -577,7 +577,7 @@ public void listBlobBlocksWorks() throws Exception { public void commitBlobBlocksWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -617,7 +617,7 @@ public void commitBlobBlocksWorks() throws Exception { public void createBlobBlockWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -634,7 +634,7 @@ public void createBlobBlockWorks() throws Exception { public void createBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream("some content".getBytes())); @@ -646,7 +646,7 @@ public void createBlockBlobWorks() throws Exception { public void createBlockBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content"; @@ -678,7 +678,7 @@ public void createBlockBlobWithOptionsWorks() throws Exception { public void createBlobSnapshotWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -697,7 +697,7 @@ public void createBlobSnapshotWorks() throws Exception { public void createBlobSnapshotWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -722,7 +722,7 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { public void getBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content"; @@ -756,7 +756,7 @@ public void getBlockBlobWorks() throws Exception { public void getPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") @@ -789,7 +789,7 @@ public void getPageBlobWorks() throws Exception { public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -807,7 +807,7 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -826,7 +826,7 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -845,7 +845,7 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -881,7 +881,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception public void getBlobPropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -911,7 +911,7 @@ public void getBlobPropertiesWorks() throws Exception { public void getBlobMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -936,7 +936,7 @@ public void getBlobMetadataWorks() throws Exception { public void setBlobPropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -974,7 +974,7 @@ public void setBlobPropertiesWorks() throws Exception { public void setBlobMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1005,7 +1005,7 @@ public void setBlobMetadataWorks() throws Exception { public void deleteBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content"; @@ -1020,7 +1020,7 @@ public void deleteBlobWorks() throws Exception { public void copyBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content2"; @@ -1048,7 +1048,7 @@ public void copyBlobWorks() throws Exception { public void acquireLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content2"; @@ -1064,7 +1064,7 @@ public void acquireLeaseWorks() throws Exception { public void renewLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content2"; @@ -1082,7 +1082,7 @@ public void renewLeaseWorks() throws Exception { public void breakLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); // Act String content = "some content2"; @@ -1108,7 +1108,7 @@ public Response handle(Request request, Next next) { public void retryPolicyWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); @@ -1133,7 +1133,7 @@ public void retryPolicyWorks() throws Exception { public void retryPolicyCompositionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = config.create(BlobService.class); + BlobServiceContract service = config.create(BlobServiceContract.class); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); From 79ecbcee94d15eda64dc5e595a73700b04b5976b Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 12:47:14 -0800 Subject: [PATCH 17/29] Renaming a few classes to "xxxResult" to follow new pattern --- .../services/blob/BlobServiceContract.java | 53 +++++----- .../implementation/BlobServiceForJersey.java | 99 ++++++++++--------- .../blob/implementation/BlobServiceImpl.java | 51 +++++----- .../blob/models/AcquireLeaseOptions.java | 2 +- .../blob/models/AcquireLeaseResult.java | 13 +++ ...obOptions.java => BlobServiceOptions.java} | 4 +- .../blob/models/CommitBlobBlocksOptions.java | 2 +- .../services/blob/models/CopyBlobOptions.java | 2 +- .../blob/models/CreateBlobBlockOptions.java | 2 +- .../blob/models/CreateBlobOptions.java | 2 +- .../blob/models/CreateBlobPagesOptions.java | 2 +- .../models/CreateBlobSnapshotOptions.java | 2 +- .../blob/models/CreateContainerOptions.java | 2 +- .../blob/models/DeleteBlobOptions.java | 2 +- .../blob/models/DeleteContainerOptions.java | 2 +- .../blob/models/GetBlobMetadataOptions.java | 2 +- .../services/blob/models/GetBlobOptions.java | 2 +- .../blob/models/GetBlobPropertiesOptions.java | 2 +- ...ties.java => GetBlobPropertiesResult.java} | 2 +- .../services/blob/models/GetBlobResult.java | 6 +- ...apshot.java => GetBlobSnapshotResult.java} | 2 +- .../blob/models/GetContainerACLResult.java | 13 +++ ...java => GetContainerPropertiesResult.java} | 5 +- .../models/GetServicePropertiesResult.java | 13 +++ .../blob/models/ListBlobBlocksOptions.java | 2 +- .../blob/models/ListBlobRegionsOptions.java | 2 +- .../blob/models/ListBlobsOptions.java | 2 +- .../blob/models/ListContainersOptions.java | 2 +- .../blob/models/SetBlobMetadataOptions.java | 2 +- .../blob/models/SetBlobPropertiesOptions.java | 2 +- .../models/SetContainerMetadataOptions.java | 2 +- .../blob/BlobServiceIntegrationTest.java | 59 ++++++----- 32 files changed, 205 insertions(+), 155 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/{BlobOptions.java => BlobServiceOptions.java} (72%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/{BlobProperties.java => GetBlobPropertiesResult.java} (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/{BlobSnapshot.java => GetBlobSnapshotResult.java} (94%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerACLResult.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/{ContainerProperties.java => GetContainerPropertiesResult.java} (88%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java index ca8350474311e..c709647ce487c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java @@ -6,13 +6,11 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; -import com.microsoft.windowsazure.services.blob.models.BlobOptions; -import com.microsoft.windowsazure.services.blob.models.BlobProperties; -import com.microsoft.windowsazure.services.blob.models.BlobSnapshot; +import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; +import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; import com.microsoft.windowsazure.services.blob.models.BlockList; import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ContainerACL; -import com.microsoft.windowsazure.services.blob.models.ContainerProperties; import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; @@ -26,7 +24,12 @@ import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobSnapshotResult; +import com.microsoft.windowsazure.services.blob.models.GetContainerACLResult; +import com.microsoft.windowsazure.services.blob.models.GetContainerPropertiesResult; +import com.microsoft.windowsazure.services.blob.models.GetServicePropertiesResult; import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsOptions; @@ -45,13 +48,13 @@ public interface BlobServiceContract { BlobServiceContract withFilter(ServiceFilter filter); - ServiceProperties getServiceProperties() throws ServiceException; + GetServicePropertiesResult getServiceProperties() throws ServiceException; - ServiceProperties getServiceProperties(BlobOptions options) throws ServiceException; + GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException; void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; - void setServiceProperties(ServiceProperties serviceProperties, BlobOptions options) throws ServiceException; + void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException; ListContainersResult listContainers() throws ServiceException; @@ -65,21 +68,21 @@ public interface BlobServiceContract { void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException; - ContainerProperties getContainerProperties(String container) throws ServiceException; + GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException; - ContainerProperties getContainerProperties(String container, BlobOptions options) throws ServiceException; + GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException; - ContainerProperties getContainerMetadata(String container) throws ServiceException; + GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException; - ContainerProperties getContainerMetadata(String container, BlobOptions options) throws ServiceException; + GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException; - ContainerACL getContainerACL(String container) throws ServiceException; + GetContainerACLResult getContainerACL(String container) throws ServiceException; - ContainerACL getContainerACL(String container, BlobOptions options) throws ServiceException; + GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException; void setContainerACL(String container, ContainerACL acl) throws ServiceException; - void setContainerACL(String container, ContainerACL acl, BlobOptions options) throws ServiceException; + void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException; void setContainerMetadata(String container, HashMap metadata) throws ServiceException; @@ -97,12 +100,10 @@ public interface BlobServiceContract { void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException; - // TODO: Should we use "createPageBlobPages"? CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) throws ServiceException; CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) throws ServiceException; - // TODO: Should we use "updatePageBlobPages"? CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) throws ServiceException; @@ -121,9 +122,9 @@ CreateBlobPagesResult createBlobPages(String container, String blob, long rangeS ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException; - BlobProperties getBlobProperties(String container, String blob) throws ServiceException; + GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException; - BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException; + GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException; GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException; @@ -150,28 +151,28 @@ SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata = new HashMap(); private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java index ef71fdfd25790..7f7ceee8c31f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class CreateContainerOptions extends BlobOptions { +public class CreateContainerOptions extends BlobServiceOptions { private String publicAccess; private HashMap metadata = new HashMap(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java index 958107affc335..100c1704bea70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.blob.models; -public class DeleteBlobOptions extends BlobOptions { +public class DeleteBlobOptions extends BlobServiceOptions { private String snapshot; private String leaseId; private boolean deleteSnaphotsOnly; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java index 961cea84f6070..ced65b0ce1f36 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.blob.models; -public class DeleteContainerOptions extends BlobOptions { +public class DeleteContainerOptions extends BlobServiceOptions { private AccessCondition accessCondition; public AccessCondition getAccessCondition() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java index 228817a339db1..1adf62fffc0ba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class GetBlobMetadataOptions extends BlobOptions { +public class GetBlobMetadataOptions extends BlobServiceOptions { private String snapshot; private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java index 3641660a31b6e..b7d87465cb422 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class GetBlobOptions extends BlobOptions { +public class GetBlobOptions extends BlobServiceOptions { private String snapshot; private String leaseId; private boolean computeRangeMD5; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java index b9ea3376a02d7..b4a4181b3c07f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class GetBlobPropertiesOptions extends BlobOptions { +public class GetBlobPropertiesOptions extends BlobServiceOptions { private String snapshot; private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java index e353c29535a55..216a799a70e80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java @@ -9,7 +9,7 @@ import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; // TODO: Unify this with ListBlobsResults.BlobProperties -public class BlobProperties { +public class GetBlobPropertiesResult { private Date lastModified; private String etag; private String contentType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java index 3d301d9457b95..f26772819be5e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java @@ -5,7 +5,7 @@ public class GetBlobResult { private InputStream contentStream; - private BlobProperties properties; + private GetBlobPropertiesResult properties; public InputStream getContentStream() { return contentStream; @@ -15,11 +15,11 @@ public void setContentStream(InputStream contentStream) { this.contentStream = contentStream; } - public BlobProperties getProperties() { + public GetBlobPropertiesResult getProperties() { return properties; } - public void setProperties(BlobProperties properties) { + public void setProperties(GetBlobPropertiesResult properties) { this.properties = properties; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobSnapshot.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobSnapshotResult.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobSnapshot.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobSnapshotResult.java index dff571ea12d36..5eace6928ae6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobSnapshot.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobSnapshotResult.java @@ -5,7 +5,7 @@ /* * TODO: Rename to "CreateBlobSnapshotResult"? */ -public class BlobSnapshot { +public class GetBlobSnapshotResult { private String snapshot; private String etag; private Date lastModified; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerACLResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerACLResult.java new file mode 100644 index 0000000000000..a768b51344057 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerACLResult.java @@ -0,0 +1,13 @@ +package com.microsoft.windowsazure.services.blob.models; + +public class GetContainerACLResult { + private ContainerACL containerACL; + + public ContainerACL getContainerACL() { + return containerACL; + } + + public void setValue(ContainerACL containerACL) { + this.containerACL = containerACL; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java index 0290ce7f0c321..e899bfc7a8621 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java @@ -3,10 +3,7 @@ import java.util.Date; import java.util.HashMap; -/* - * TODO: Rename to "GetContainerPropertiesResult"? - */ -public class ContainerProperties { +public class GetContainerPropertiesResult { private String etag; private Date lastModified; private HashMap metadata; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java new file mode 100644 index 0000000000000..8bdcbca5c4443 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java @@ -0,0 +1,13 @@ +package com.microsoft.windowsazure.services.blob.models; + +public class GetServicePropertiesResult { + private ServiceProperties serviceProperties; + + public ServiceProperties getServiceProperties() { + return serviceProperties; + } + + public void setServiceProperties(ServiceProperties serviceProperties) { + this.serviceProperties = serviceProperties; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java index c91ca2d721604..33eb6b47e54d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class ListBlobBlocksOptions extends BlobOptions { +public class ListBlobBlocksOptions extends BlobServiceOptions { private String leaseId; private String snapshot; private String listType; // "committed", "uncommitted", "all" diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java index 402914579b0fa..263f1a3266020 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class ListBlobRegionsOptions extends BlobOptions { +public class ListBlobRegionsOptions extends BlobServiceOptions { private String leaseId; private String snapshot; private Long rangeStart; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java index b023767002463..2314d824515da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java @@ -3,7 +3,7 @@ import java.util.EnumSet; -public class ListBlobsOptions extends BlobOptions { +public class ListBlobsOptions extends BlobServiceOptions { private String prefix; private String marker; private int maxResults; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java index e0a008c050ed5..a28fb8966aec5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java @@ -3,7 +3,7 @@ import java.util.EnumSet; -public class ListContainersOptions extends BlobOptions { +public class ListContainersOptions extends BlobServiceOptions { private String prefix; private String marker; private int maxResults; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java index 592ab9c7ea08e..b09ae1027d9d9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class SetBlobMetadataOptions extends BlobOptions { +public class SetBlobMetadataOptions extends BlobServiceOptions { private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java index 39bd2109712c6..2e56aa7a634a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class SetBlobPropertiesOptions extends BlobOptions { +public class SetBlobPropertiesOptions extends BlobServiceOptions { private String leaseId; private String contentType; private Long contentLength; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java index 3c9f4b7a6a277..9d856e97c88ea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.blob.models; -public class SetContainerMetadataOptions extends BlobOptions { +public class SetContainerMetadataOptions extends BlobServiceOptions { private AccessCondition accessCondition; public AccessCondition getAccessCondition() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 6076a8478ab82..f8fcbb025bf57 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -26,14 +26,10 @@ import com.microsoft.windowsazure.common.ExponentialRetryPolicyFilter; import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.blob.BlobServiceContract; import com.microsoft.windowsazure.services.blob.models.AccessCondition; -import com.microsoft.windowsazure.services.blob.models.BlobProperties; -import com.microsoft.windowsazure.services.blob.models.BlobSnapshot; import com.microsoft.windowsazure.services.blob.models.BlockList; import com.microsoft.windowsazure.services.blob.models.ContainerACL; import com.microsoft.windowsazure.services.blob.models.ContainerListingDetails; -import com.microsoft.windowsazure.services.blob.models.ContainerProperties; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; @@ -41,7 +37,10 @@ import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; +import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobSnapshotResult; +import com.microsoft.windowsazure.services.blob.models.GetContainerPropertiesResult; import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; @@ -138,7 +137,7 @@ public void getServiceProppertiesWorks() throws Exception { BlobServiceContract service = config.create(BlobServiceContract.class); // Act - ServiceProperties props = service.getServiceProperties(); + ServiceProperties props = service.getServiceProperties().getServiceProperties(); // Assert assertNotNull(props); @@ -156,13 +155,13 @@ public void setServiceProppertiesWorks() throws Exception { BlobServiceContract service = config.create(BlobServiceContract.class); // Act - ServiceProperties props = service.getServiceProperties(); + ServiceProperties props = service.getServiceProperties().getServiceProperties(); props.setDefaultServiceVersion("2009-09-19"); props.getLogging().setRead(true); service.setServiceProperties(props); - props = service.getServiceProperties(); + props = service.getServiceProperties().getServiceProperties(); // Assert assertNotNull(props); @@ -197,9 +196,9 @@ public void createContainerWithMetadataWorks() throws Exception { service.createContainer(CREATEABLE_CONTAINER_2, new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); - ContainerProperties prop = service.getContainerMetadata(CREATEABLE_CONTAINER_2); - ContainerProperties prop2 = service.getContainerProperties(CREATEABLE_CONTAINER_2); - ContainerACL acl = service.getContainerACL(CREATEABLE_CONTAINER_2); + GetContainerPropertiesResult prop = service.getContainerMetadata(CREATEABLE_CONTAINER_2); + GetContainerPropertiesResult prop2 = service.getContainerProperties(CREATEABLE_CONTAINER_2); + ContainerACL acl = service.getContainerACL(CREATEABLE_CONTAINER_2).getContainerACL(); ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix(CREATEABLE_CONTAINER_2).setListingDetails( EnumSet.of(ContainerListingDetails.METADATA))); @@ -251,7 +250,7 @@ public void setContainerMetadataWorks() throws Exception { metadata.put("test", "bar"); metadata.put("blah", "bleah"); service.setContainerMetadata(CREATEABLE_CONTAINER_3, metadata); - ContainerProperties prop = service.getContainerMetadata(CREATEABLE_CONTAINER_3); + GetContainerPropertiesResult prop = service.getContainerMetadata(CREATEABLE_CONTAINER_3); // Assert assertNotNull(prop); @@ -283,7 +282,7 @@ public void setContainerACLWorks() throws Exception { acl.addSignedIdentifier("test", expiryStartDate, expiryEndDate, "rwd"); service.setContainerACL(container, acl); - ContainerACL acl2 = service.getContainerACL(container); + ContainerACL acl2 = service.getContainerACL(container).getContainerACL(); service.deleteContainer(container); // Assert @@ -417,7 +416,7 @@ public void createPageBlobWithOptionsWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); + GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); // Assert assertNotNull(props); @@ -655,7 +654,7 @@ public void createBlockBlobWithOptionsWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); + GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); // Assert assertNotNull(props); @@ -684,7 +683,7 @@ public void createBlobSnapshotWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - BlobSnapshot snapshot = service.createBlobSnapshot(container, blob); + GetBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob); // Assert assertNotNull(snapshot); @@ -703,10 +702,10 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - BlobSnapshot snapshot = service.createBlobSnapshot(container, blob, + GetBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); - BlobProperties props = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); + GetBlobPropertiesResult props = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); // Assert assertNotNull(props); @@ -732,7 +731,7 @@ public void getBlockBlobWorks() throws Exception { /* .setContentMD5("1234") */.setContentType("text/plain")); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); - BlobProperties props = blob.getProperties(); + GetBlobPropertiesResult props = blob.getProperties(); // Assert assertNotNull(props); @@ -765,7 +764,7 @@ public void getPageBlobWorks() throws Exception { /* .setContentMD5("1234") */.setContentType("text/plain")); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); - BlobProperties props = blob.getProperties(); + GetBlobPropertiesResult props = blob.getProperties(); // Assert assertNotNull(props); @@ -811,7 +810,7 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); - BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); + GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); try { service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); Assert.fail("getBlob should throw an exception"); @@ -830,7 +829,7 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); - BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); + GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); try { service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); Assert.fail("getBlob should throw an exception"); @@ -851,7 +850,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 4096); - BlobProperties props = service.getBlobProperties(container, blob); + GetBlobPropertiesResult props = service.getBlobProperties(container, blob); // To test for "IfNotModifiedSince", we need to make updates to the blob // until at least 1 second has passed since the blob creation @@ -887,7 +886,7 @@ public void getBlobPropertiesWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 4096); - BlobProperties props = service.getBlobProperties(container, blob); + GetBlobPropertiesResult props = service.getBlobProperties(container, blob); // Assert // Assert @@ -946,7 +945,7 @@ public void setBlobPropertiesWorks() throws Exception { new SetBlobPropertiesOptions().setCacheControl("test").setContentEncoding("UTF-8").setContentLanguage("en-us").setContentLength(512L) .setContentMD5(null).setContentType("text/plain").setSequenceNumberAction("increment")); - BlobProperties props = service.getBlobProperties(container, blob); + GetBlobPropertiesResult props = service.getBlobProperties(container, blob); // Assert assertNotNull(result); @@ -985,7 +984,7 @@ public void setBlobMetadataWorks() throws Exception { service.createPageBlob(container, blob, 4096); SetBlobMetadataResult result = service.setBlobMetadata(container, blob, metadata); - BlobProperties props = service.getBlobProperties(container, blob); + GetBlobPropertiesResult props = service.getBlobProperties(container, blob); // Assert assertNotNull(result); @@ -1028,7 +1027,7 @@ public void copyBlobWorks() throws Exception { service.copyBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5", TEST_CONTAINER_FOR_BLOBS, "test6"); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5"); - BlobProperties props = blob.getProperties(); + GetBlobPropertiesResult props = blob.getProperties(); // Assert assertNotNull(props); @@ -1053,7 +1052,7 @@ public void acquireLeaseWorks() throws Exception { // Act String content = "some content2"; service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6"); + String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6").getLeaseId(); service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert @@ -1069,8 +1068,8 @@ public void renewLeaseWorks() throws Exception { // Act String content = "some content2"; service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6"); - String leaseId2 = service.renewLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); + String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6").getLeaseId(); + String leaseId2 = service.renewLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId).getLeaseId(); service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert @@ -1087,7 +1086,7 @@ public void breakLeaseWorks() throws Exception { // Act String content = "some content2"; service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6"); + String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6").getLeaseId(); service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); From 8189ae1ca0196de8904345276ed99d8487056f3b Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 13:04:47 -0800 Subject: [PATCH 18/29] Replace enums with boolean options. --- .../implementation/BlobServiceForJersey.java | 24 +++++----- .../blob/implementation/JerseyHelpers.java | 7 ++- .../blob/models/BlobListingDetails.java | 46 ------------------- .../blob/models/ContainerListingDetails.java | 34 -------------- .../blob/models/ListBlobsOptions.java | 33 +++++++++---- .../blob/models/ListContainersOptions.java | 12 ++--- .../blob/BlobServiceIntegrationTest.java | 5 +- 7 files changed, 45 insertions(+), 116 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index 61761d1037059..4cf445b2f20ba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -17,12 +17,10 @@ import com.microsoft.windowsazure.services.blob.models.AccessCondition; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; -import com.microsoft.windowsazure.services.blob.models.BlobListingDetails; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; import com.microsoft.windowsazure.services.blob.models.BlockList; import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ContainerACL; -import com.microsoft.windowsazure.services.blob.models.ContainerListingDetails; import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; @@ -118,6 +116,15 @@ private WebResource addOptionalQueryParam(WebResource webResource, String key, i return JerseyHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); } + private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) { + EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); + sb.addValue(options.isIncludeSnapshots(), "snapshots"); + sb.addValue(options.isIncludeUncommittedBlobs(), "uncommittedblobs"); + sb.addValue(options.isIncludeMetadata(), "metadata"); + webResource = addOptionalQueryParam(webResource, "include", sb.toString()); + return webResource; + } + private Builder addOptionalHeader(Builder builder, String name, Object value) { return JerseyHelpers.addOptionalHeader(builder, name, value); } @@ -388,7 +395,7 @@ public ListContainersResult listContainers(ListContainersOptions options) throws webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); - if (options.getListingDetails().contains(ContainerListingDetails.METADATA)) { + if (options.isIncludeMetadata()) { webResource = webResource.queryParam("include", "metadata"); } @@ -407,16 +414,7 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) thr webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); - - if (options.getListingDetails().size() > 0) { - EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); - - sb.addValue(options.getListingDetails(), BlobListingDetails.SNAPSHOTS, "snapshots"); - sb.addValue(options.getListingDetails(), BlobListingDetails.UNCOMMITTED_BLOBS, "uncommittedblobs"); - sb.addValue(options.getListingDetails(), BlobListingDetails.METADATA, "metadata"); - - webResource = addOptionalQueryParam(webResource, "include", sb.toString()); - } + webResource = addOptionalBlobListingIncludeQueryParam(options, webResource); Builder builder = webResource.header("x-ms-version", API_VERSION); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java index 134b881c11f43..02693bc2c20ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.implementation; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -35,11 +34,11 @@ public static WebResource setCanonicalizedResource(WebResource webResource, Stri return webResource; } - public static class EnumCommaStringBuilder> { + public static class EnumCommaStringBuilder { private final StringBuilder sb = new StringBuilder(); - public void addValue(EnumSet enumSet, E value, String representation) { - if (enumSet.contains(value)) { + public void addValue(boolean value, String representation) { + if (value) { if (sb.length() >= 0) { sb.append(","); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java deleted file mode 100644 index e072f5461c956..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobListingDetails.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.microsoft.windowsazure.services.blob.models; - -/** - * Specifies which items to include when listing a set of blobs. - *

- * By default, committed blocks are always returned. Use the values in this enum to include snapshots, metadata, and/or - * uncommitted blocks. - * - * Copyright (c)2011 Microsoft. All rights reserved. - */ -public enum BlobListingDetails { - /** - * Specifies including no additional details. - */ - NONE(0), - - /** - * Specifies listing committed blobs and blob snapshots. - */ - SNAPSHOTS(1), - - /** - * Specifies listing blob metadata for each blob returned in the listing. - */ - METADATA(2), - - /** - * Specifies listing uncommitted blobs. - */ - UNCOMMITTED_BLOBS(4); - - /** - * Returns the value of this enum. - */ - public int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - BlobListingDetails(int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java deleted file mode 100644 index 50c98d2086f14..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerListingDetails.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.microsoft.windowsazure.services.blob.models; - -/** - * Specifies which details to include when listing the containers in this - * storage account. - * - * Copyright (c)2011 Microsoft. All rights reserved. - */ -public enum ContainerListingDetails { - /** - * Specifies including no additional details. - */ - NONE(0), - - /** - * Specifies including container metadata. - */ - METADATA(1); - - /** - * Returns the value of this enum. - */ - int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - ContainerListingDetails(int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java index 2314d824515da..f28765a27172f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java @@ -1,14 +1,13 @@ package com.microsoft.windowsazure.services.blob.models; -import java.util.EnumSet; - - public class ListBlobsOptions extends BlobServiceOptions { private String prefix; private String marker; private int maxResults; private String delimiter; - private EnumSet listingDetails = EnumSet.noneOf(BlobListingDetails.class); + private boolean includeMetadata; + private boolean includeSnapshots; + private boolean includeUncommittedBlobs; public String getPrefix() { return prefix; @@ -46,12 +45,30 @@ public ListBlobsOptions setDelimiter(String delimiter) { return this; } - public EnumSet getListingDetails() { - return listingDetails; + public boolean isIncludeMetadata() { + return includeMetadata; + } + + public ListBlobsOptions setIncludeMetadata(boolean includeMetadata) { + this.includeMetadata = includeMetadata; + return this; + } + + public boolean isIncludeSnapshots() { + return includeSnapshots; + } + + public ListBlobsOptions setIncludeSnapshots(boolean includeSnapshots) { + this.includeSnapshots = includeSnapshots; + return this; + } + + public boolean isIncludeUncommittedBlobs() { + return includeUncommittedBlobs; } - public ListBlobsOptions setListingDetails(EnumSet listingDetails) { - this.listingDetails = listingDetails; + public ListBlobsOptions setIncludeUncommittedBlobs(boolean includeUncommittedBlobs) { + this.includeUncommittedBlobs = includeUncommittedBlobs; return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java index a28fb8966aec5..6b3bf57b9eef2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java @@ -1,13 +1,11 @@ package com.microsoft.windowsazure.services.blob.models; -import java.util.EnumSet; - public class ListContainersOptions extends BlobServiceOptions { private String prefix; private String marker; private int maxResults; - private EnumSet listingDetails = EnumSet.noneOf(ContainerListingDetails.class); + private boolean includeMetadata; public String getPrefix() { return prefix; @@ -36,12 +34,12 @@ public ListContainersOptions setMaxResults(int maxResults) { return this; } - public EnumSet getListingDetails() { - return listingDetails; + public boolean isIncludeMetadata() { + return includeMetadata; } - public ListContainersOptions setListingDetails(EnumSet listingDetails) { - this.listingDetails = listingDetails; + public ListContainersOptions setIncludeMetadata(boolean includeMetadata) { + this.includeMetadata = includeMetadata; return this; } } \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index f8fcbb025bf57..639e0efc96cf6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -12,7 +12,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Date; -import java.util.EnumSet; import java.util.GregorianCalendar; import java.util.HashMap; @@ -29,7 +28,6 @@ import com.microsoft.windowsazure.services.blob.models.AccessCondition; import com.microsoft.windowsazure.services.blob.models.BlockList; import com.microsoft.windowsazure.services.blob.models.ContainerACL; -import com.microsoft.windowsazure.services.blob.models.ContainerListingDetails; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; @@ -200,8 +198,7 @@ public void createContainerWithMetadataWorks() throws Exception { GetContainerPropertiesResult prop2 = service.getContainerProperties(CREATEABLE_CONTAINER_2); ContainerACL acl = service.getContainerACL(CREATEABLE_CONTAINER_2).getContainerACL(); - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix(CREATEABLE_CONTAINER_2).setListingDetails( - EnumSet.of(ContainerListingDetails.METADATA))); + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix(CREATEABLE_CONTAINER_2).setIncludeMetadata(true)); service.deleteContainer(CREATEABLE_CONTAINER_2); From d846f683c5d0c4b7dd50d23d45cac9d2dfdb7b43 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 13:08:35 -0800 Subject: [PATCH 19/29] Refactor code slightly --- .../implementation/BlobServiceForJersey.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index 4cf445b2f20ba..dd83fb1f649c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -116,15 +116,6 @@ private WebResource addOptionalQueryParam(WebResource webResource, String key, i return JerseyHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); } - private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) { - EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); - sb.addValue(options.isIncludeSnapshots(), "snapshots"); - sb.addValue(options.isIncludeUncommittedBlobs(), "uncommittedblobs"); - sb.addValue(options.isIncludeMetadata(), "metadata"); - webResource = addOptionalQueryParam(webResource, "include", sb.toString()); - return webResource; - } - private Builder addOptionalHeader(Builder builder, String name, Object value) { return JerseyHelpers.addOptionalHeader(builder, name, value); } @@ -149,6 +140,22 @@ private HashMap getMetadataFromHeaders(ClientResponse response) return JerseyHelpers.getMetadataFromHeaders(response); } + private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) { + EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); + sb.addValue(options.isIncludeSnapshots(), "snapshots"); + sb.addValue(options.isIncludeUncommittedBlobs(), "uncommittedblobs"); + sb.addValue(options.isIncludeMetadata(), "metadata"); + webResource = addOptionalQueryParam(webResource, "include", sb.toString()); + return webResource; + } + + private WebResource addOptionalContainerIncludeQueryParam(ListContainersOptions options, WebResource webResource) { + EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); + sb.addValue(options.isIncludeMetadata(), "metadata"); + webResource = addOptionalQueryParam(webResource, "include", sb.toString()); + return webResource; + } + private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); if (options.getContentType() == null) { @@ -395,9 +402,7 @@ public ListContainersResult listContainers(ListContainersOptions options) throws webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); - if (options.isIncludeMetadata()) { - webResource = webResource.queryParam("include", "metadata"); - } + webResource = addOptionalContainerIncludeQueryParam(options, webResource); Builder builder = webResource.header("x-ms-version", API_VERSION); From f5e6cb10242676b9cf1908753884d465b7439f3e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 13:12:49 -0800 Subject: [PATCH 20/29] Fix unit test --- .../services/blob/implementation/JerseyHelpers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java index 02693bc2c20ed..d20473ac0f373 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java @@ -39,7 +39,7 @@ public static class EnumCommaStringBuilder { public void addValue(boolean value, String representation) { if (value) { - if (sb.length() >= 0) { + if (sb.length() > 0) { sb.append(","); } sb.append(representation); From 160590de447c28e01cef4a32fc141c79bb1507ab Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 14:15:32 -0800 Subject: [PATCH 21/29] Fix "include" param generation --- .../services/blob/implementation/BlobServiceForJersey.java | 5 +++-- .../services/blob/implementation/JerseyHelpers.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index dd83fb1f649c9..b10f1eadb7d8d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -145,14 +145,14 @@ private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions opt sb.addValue(options.isIncludeSnapshots(), "snapshots"); sb.addValue(options.isIncludeUncommittedBlobs(), "uncommittedblobs"); sb.addValue(options.isIncludeMetadata(), "metadata"); - webResource = addOptionalQueryParam(webResource, "include", sb.toString()); + webResource = addOptionalQueryParam(webResource, "include", sb.getValue()); return webResource; } private WebResource addOptionalContainerIncludeQueryParam(ListContainersOptions options, WebResource webResource) { EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); sb.addValue(options.isIncludeMetadata(), "metadata"); - webResource = addOptionalQueryParam(webResource, "include", sb.toString()); + webResource = addOptionalQueryParam(webResource, "include", sb.getValue()); return webResource; } @@ -419,6 +419,7 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) thr webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); + webResource = addOptionalQueryParam(webResource, "delimiter", options.getDelimiter()); webResource = addOptionalBlobListingIncludeQueryParam(options, webResource); Builder builder = webResource.header("x-ms-version", API_VERSION); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java index d20473ac0f373..046af8c0d3875 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java @@ -46,8 +46,9 @@ public void addValue(boolean value, String representation) { } } - @Override - public String toString() { + public String getValue() { + if (sb.length() == 0) + return null; return sb.toString(); } } From ded6e82507eb4f056fed929c87c8d81001049d20 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 14:17:05 -0800 Subject: [PATCH 22/29] Fix support for "BlobPrefix" with listing blobs --- .../services/blob/models/ListBlobsResult.java | 35 ++++-- .../blob/BlobServiceIntegrationTest.java | 107 ++++++++++++++++-- 2 files changed, 128 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java index 8b8f02cc0c8c3..ce733983e2184 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java @@ -6,6 +6,8 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -15,7 +17,7 @@ @XmlRootElement(name = "EnumerationResults") public class ListBlobsResult { - private List blobs; + private List entries; private String containerName; private String prefix; private String marker; @@ -24,13 +26,13 @@ public class ListBlobsResult { private int maxResults; @XmlElementWrapper(name = "Blobs") - @XmlElement(name = "Blob") - public List getBlobs() { - return blobs; + @XmlElementRefs({ @XmlElementRef(name = "BlobPrefix", type = BlobPrefix.class), @XmlElementRef(name = "Blob", type = Blob.class) }) + public List getEntries() { + return entries; } - public void setBlobs(List value) { - this.blobs = value; + public void setEntries(List entries) { + this.entries = entries; } @XmlElement(name = "Prefix") @@ -87,7 +89,26 @@ public void setContainerName(String containerName) { this.containerName = containerName; } - public static class Blob { + public static abstract class ListBlobsEntry { + + } + + @XmlRootElement(name = "BlobPrefix") + public static class BlobPrefix extends ListBlobsEntry { + private String name; + + @XmlElement(name = "Name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @XmlRootElement(name = "Blob") + public static class Blob extends ListBlobsEntry { private String name; private String url; private String snapshot; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 639e0efc96cf6..08c63746526ac 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -44,6 +44,8 @@ import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions; import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; +import com.microsoft.windowsazure.services.blob.models.ListBlobsResult.Blob; +import com.microsoft.windowsazure.services.blob.models.ListBlobsResult.BlobPrefix; import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; import com.microsoft.windowsazure.services.blob.models.ListContainersResult; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; @@ -98,11 +100,6 @@ public static void setup() throws Exception { // Ignore exception as the containers might not exists } } - - service.createPageBlob(TEST_CONTAINER_FOR_LISTING, "myblob1", 512); - service.createPageBlob(TEST_CONTAINER_FOR_LISTING, "myblob2", 512); - service.createPageBlob(TEST_CONTAINER_FOR_LISTING, "otherblob1", 512); - service.createPageBlob(TEST_CONTAINER_FOR_LISTING, "otherblob2", 512); } @AfterClass @@ -366,13 +363,25 @@ public void listBlobsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobServiceContract service = config.create(BlobServiceContract.class); + String[] blobNames = { "myblob1", "myblob2", "other-blob1", "other-blob2" }; + for (String blob : blobNames) { + service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); + } // Act ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING); + for (String blob : blobNames) { + service.deleteBlob(TEST_CONTAINER_FOR_LISTING, blob); + } + // Assert assertNotNull(results); - assertEquals(4, results.getBlobs().size()); + assertEquals(4, results.getEntries().size()); + assertTrue(results.getEntries().get(0) instanceof Blob); + assertTrue(results.getEntries().get(1) instanceof Blob); + assertTrue(results.getEntries().get(2) instanceof Blob); + assertTrue(results.getEntries().get(3) instanceof Blob); } @Test @@ -380,13 +389,97 @@ public void listBlobsWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobServiceContract service = config.create(BlobServiceContract.class); + String[] blobNames = { "myblob1", "myblob2", "otherblob1", "otherblob2" }; + for (String blob : blobNames) { + service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); + } // Act ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setPrefix("myblob")); + ListBlobsResult results2 = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setPrefix("o")); + + for (String blob : blobNames) { + service.deleteBlob(TEST_CONTAINER_FOR_LISTING, blob); + } // Assert assertNotNull(results); - assertEquals(2, results.getBlobs().size()); + assertEquals(2, results.getEntries().size()); + assertTrue(results.getEntries().get(0) instanceof Blob); + assertTrue(results.getEntries().get(1) instanceof Blob); + assertEquals("myblob1", ((Blob) results.getEntries().get(0)).getName()); + assertEquals("myblob2", ((Blob) results.getEntries().get(1)).getName()); + + assertNotNull(results2); + assertEquals(2, results2.getEntries().size()); + assertTrue(results2.getEntries().get(0) instanceof Blob); + assertTrue(results2.getEntries().get(1) instanceof Blob); + assertEquals("otherblob1", ((Blob) results2.getEntries().get(0)).getName()); + assertEquals("otherblob2", ((Blob) results2.getEntries().get(1)).getName()); + } + + @Test + public void listBlobsWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobServiceContract service = config.create(BlobServiceContract.class); + String[] blobNames = { "myblob1", "myblob2", "otherblob1", "otherblob2" }; + for (String blob : blobNames) { + service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); + } + + // Act + ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setIncludeMetadata(true) + .setIncludeSnapshots(true)); + + for (String blob : blobNames) { + service.deleteBlob(TEST_CONTAINER_FOR_LISTING, blob); + } + + // Assert + assertNotNull(results); + assertEquals(4, results.getEntries().size()); + } + + @Test + public void listBlobsWithDelimiterWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobServiceContract service = config.create(BlobServiceContract.class); + String[] blobNames = { "myblob1", "myblob2", "dir1-blob1", "dir1-blob2", "dir2-dir21-blob3", "dir2-dir22-blob3" }; + for (String blob : blobNames) { + service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); + } + + // Act + ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setDelimiter("-")); + ListBlobsResult results2 = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setDelimiter("-").setPrefix("dir1-")); + ListBlobsResult results3 = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setDelimiter("-").setPrefix("dir2-")); + ListBlobsResult results4 = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setDelimiter("-").setPrefix("dir2-dir21-")); + ListBlobsResult results5 = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setDelimiter("-").setPrefix("dir2-dir22-")); + ListBlobsResult results6 = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setDelimiter("-").setPrefix("dir2-dir44-")); + + for (String blob : blobNames) { + service.deleteBlob(TEST_CONTAINER_FOR_LISTING, blob); + } + + // Assert + assertNotNull(results); + assertEquals(4, results.getEntries().size()); + assertTrue(results.getEntries().get(0) instanceof BlobPrefix); + assertTrue(results.getEntries().get(1) instanceof BlobPrefix); + assertTrue(results.getEntries().get(2) instanceof Blob); + assertTrue(results.getEntries().get(3) instanceof Blob); + + assertEquals(2, results2.getEntries().size()); + + assertEquals(2, results3.getEntries().size()); + + assertEquals(1, results4.getEntries().size()); + + assertEquals(1, results5.getEntries().size()); + + assertEquals(0, results6.getEntries().size()); } @Test From 3c60746b09271c5c3a2c4ebd9630a43c9017fa8f Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 15:01:44 -0800 Subject: [PATCH 23/29] Better handle "BlobPrefix" and "Blob" in ListBlobsResult --- .../services/blob/models/ListBlobsResult.java | 36 +++++++++++--- .../blob/BlobServiceIntegrationTest.java | 48 ++++++++----------- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java index ce733983e2184..d9b6b76fb36be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java @@ -1,5 +1,6 @@ package com.microsoft.windowsazure.services.blob.models; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -17,7 +18,8 @@ @XmlRootElement(name = "EnumerationResults") public class ListBlobsResult { - private List entries; + private List blobPrefixes = new ArrayList(); + private List blobs = new ArrayList(); private String containerName; private String prefix; private String marker; @@ -26,13 +28,35 @@ public class ListBlobsResult { private int maxResults; @XmlElementWrapper(name = "Blobs") - @XmlElementRefs({ @XmlElementRef(name = "BlobPrefix", type = BlobPrefix.class), @XmlElementRef(name = "Blob", type = Blob.class) }) + @XmlElementRefs({ @XmlElementRef(name = "BlobPrefix", type = BlobPrefixEntry.class), @XmlElementRef(name = "Blob", type = BlobEntry.class) }) public List getEntries() { - return entries; + ArrayList result = new ArrayList(); + result.addAll(this.blobPrefixes); + result.addAll(this.blobs); + return result; } public void setEntries(List entries) { - this.entries = entries; + // Split collection into "blobs" and "blobPrefixes" collections + this.blobPrefixes = new ArrayList(); + this.blobs = new ArrayList(); + + for (ListBlobsEntry entry : entries) { + if (entry instanceof BlobPrefixEntry) { + this.blobPrefixes.add((BlobPrefixEntry) entry); + } + else if (entry instanceof BlobEntry) { + this.blobs.add((BlobEntry) entry); + } + } + } + + public List getBlobPrefixes() { + return this.blobPrefixes; + } + + public List getBlobs() { + return this.blobs; } @XmlElement(name = "Prefix") @@ -94,7 +118,7 @@ public static abstract class ListBlobsEntry { } @XmlRootElement(name = "BlobPrefix") - public static class BlobPrefix extends ListBlobsEntry { + public static class BlobPrefixEntry extends ListBlobsEntry { private String name; @XmlElement(name = "Name") @@ -108,7 +132,7 @@ public void setName(String name) { } @XmlRootElement(name = "Blob") - public static class Blob extends ListBlobsEntry { + public static class BlobEntry extends ListBlobsEntry { private String name; private String url; private String snapshot; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 08c63746526ac..2483342055871 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -44,8 +44,6 @@ import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult; import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions; import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; -import com.microsoft.windowsazure.services.blob.models.ListBlobsResult.Blob; -import com.microsoft.windowsazure.services.blob.models.ListBlobsResult.BlobPrefix; import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; import com.microsoft.windowsazure.services.blob.models.ListContainersResult; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; @@ -377,11 +375,7 @@ public void listBlobsWorks() throws Exception { // Assert assertNotNull(results); - assertEquals(4, results.getEntries().size()); - assertTrue(results.getEntries().get(0) instanceof Blob); - assertTrue(results.getEntries().get(1) instanceof Blob); - assertTrue(results.getEntries().get(2) instanceof Blob); - assertTrue(results.getEntries().get(3) instanceof Blob); + assertEquals(4, results.getBlobs().size()); } @Test @@ -404,18 +398,14 @@ public void listBlobsWithPrefixWorks() throws Exception { // Assert assertNotNull(results); - assertEquals(2, results.getEntries().size()); - assertTrue(results.getEntries().get(0) instanceof Blob); - assertTrue(results.getEntries().get(1) instanceof Blob); - assertEquals("myblob1", ((Blob) results.getEntries().get(0)).getName()); - assertEquals("myblob2", ((Blob) results.getEntries().get(1)).getName()); + assertEquals(2, results.getBlobs().size()); + assertEquals("myblob1", results.getBlobs().get(0).getName()); + assertEquals("myblob2", results.getBlobs().get(1).getName()); assertNotNull(results2); - assertEquals(2, results2.getEntries().size()); - assertTrue(results2.getEntries().get(0) instanceof Blob); - assertTrue(results2.getEntries().get(1) instanceof Blob); - assertEquals("otherblob1", ((Blob) results2.getEntries().get(0)).getName()); - assertEquals("otherblob2", ((Blob) results2.getEntries().get(1)).getName()); + assertEquals(2, results2.getBlobs().size()); + assertEquals("otherblob1", results2.getBlobs().get(0).getName()); + assertEquals("otherblob2", results2.getBlobs().get(1).getName()); } @Test @@ -438,7 +428,7 @@ public void listBlobsWithOptionsWorks() throws Exception { // Assert assertNotNull(results); - assertEquals(4, results.getEntries().size()); + assertEquals(4, results.getBlobs().size()); } @Test @@ -465,21 +455,23 @@ public void listBlobsWithDelimiterWorks() throws Exception { // Assert assertNotNull(results); - assertEquals(4, results.getEntries().size()); - assertTrue(results.getEntries().get(0) instanceof BlobPrefix); - assertTrue(results.getEntries().get(1) instanceof BlobPrefix); - assertTrue(results.getEntries().get(2) instanceof Blob); - assertTrue(results.getEntries().get(3) instanceof Blob); + assertEquals(2, results.getBlobs().size()); + assertEquals(2, results.getBlobPrefixes().size()); - assertEquals(2, results2.getEntries().size()); + assertEquals(2, results2.getBlobs().size()); + assertEquals(0, results2.getBlobPrefixes().size()); - assertEquals(2, results3.getEntries().size()); + assertEquals(0, results3.getBlobs().size()); + assertEquals(2, results3.getBlobPrefixes().size()); - assertEquals(1, results4.getEntries().size()); + assertEquals(1, results4.getBlobs().size()); + assertEquals(0, results4.getBlobPrefixes().size()); - assertEquals(1, results5.getEntries().size()); + assertEquals(1, results5.getBlobs().size()); + assertEquals(0, results5.getBlobPrefixes().size()); - assertEquals(0, results6.getEntries().size()); + assertEquals(0, results6.getBlobs().size()); + assertEquals(0, results6.getBlobPrefixes().size()); } @Test From 03ee3952ad2451b6029548ecea57fd25ded2549e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 15:30:38 -0800 Subject: [PATCH 24/29] Wrap (start, end) parameters in PageRange type --- .../services/blob/BlobServiceContract.java | 12 ++--- .../implementation/BlobServiceForJersey.java | 21 ++++----- .../blob/implementation/BlobServiceImpl.java | 18 ++++---- .../blob/models/ListBlobRegionsResult.java | 23 ---------- .../services/blob/models/PageRange.java | 45 +++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 14 +++--- 6 files changed, 79 insertions(+), 54 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/PageRange.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java index c709647ce487c..03f2cb1ca2d2f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java @@ -38,6 +38,7 @@ import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.PageRange; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataOptions; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; @@ -100,15 +101,14 @@ public interface BlobServiceContract { void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException; - CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) throws ServiceException; + CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException; - CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) throws ServiceException; + CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException; - CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) - throws ServiceException; + CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) throws ServiceException; - CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, - CreateBlobPagesOptions options) throws ServiceException; + CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) + throws ServiceException; void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index b10f1eadb7d8d..d8fce0ffb4ac8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -48,6 +48,7 @@ import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.PageRange; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataOptions; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; @@ -703,32 +704,32 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St return result; } - public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) throws ServiceException { - return clearBlobPages(container, blob, rangeStart, rangeEnd, new CreateBlobPagesOptions()); + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { + return clearBlobPages(container, blob, range, new CreateBlobPagesOptions()); } - public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException { - return updatePageBlobPagesImpl("clear", container, blob, rangeStart, rangeEnd, 0, null, options); + return updatePageBlobPagesImpl("clear", container, blob, range, 0, null, options); } - public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) throws ServiceException { - return createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, new CreateBlobPagesOptions()); + return createBlobPages(container, blob, range, length, contentStream, new CreateBlobPagesOptions()); } - public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { - return updatePageBlobPagesImpl("update", container, blob, rangeStart, rangeEnd, length, contentStream, options); + return updatePageBlobPagesImpl("update", container, blob, range, length, contentStream, options); } - private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, + private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "page"); webResource = setCanonicalizedResource(webResource, "page"); Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); + builder = addOptionalRangeHeader(builder, range.getStart(), range.getEnd()); builder = addOptionalHeader(builder, "Content-Length", length); builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java index dba203dc01afc..54aa5fabfd365 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java @@ -44,6 +44,7 @@ import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.PageRange; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataOptions; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; @@ -388,9 +389,9 @@ public void createBlockBlob(String container, String blob, InputStream contentSt } } - public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) throws ServiceException { + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { try { - return service.clearBlobPages(container, blob, rangeStart, rangeEnd); + return service.clearBlobPages(container, blob, range); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -400,10 +401,9 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, long } } - public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) - throws ServiceException { + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException { try { - return service.clearBlobPages(container, blob, rangeStart, rangeEnd, options); + return service.clearBlobPages(container, blob, range, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -413,10 +413,10 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, long } } - public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) throws ServiceException { try { - return service.createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream); + return service.createBlobPages(container, blob, range, length, contentStream); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -426,10 +426,10 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, long } } - public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { try { - return service.createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, options); + return service.createBlobPages(container, blob, range, length, contentStream, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java index a6bee480a8f3a..3887ca6c30cd9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java @@ -45,27 +45,4 @@ public List getPageRanges() { public void setPageRanges(List pageRanges) { this.pageRanges = pageRanges; } - - public static class PageRange { - private long start; - private long end; - - @XmlElement(name = "Start") - public long getStart() { - return start; - } - - public void setStart(long start) { - this.start = start; - } - - @XmlElement(name = "End") - public long getEnd() { - return end; - } - - public void setEnd(long end) { - this.end = end; - } - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/PageRange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/PageRange.java new file mode 100644 index 0000000000000..0491e45806822 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/PageRange.java @@ -0,0 +1,45 @@ +package com.microsoft.windowsazure.services.blob.models; + +import javax.xml.bind.annotation.XmlElement; + +public class PageRange { + private long start; + private long end; + + public PageRange() { + } + + public PageRange(long start, long end) { + this.start = start; + this.end = end; + } + + @XmlElement(name = "Start") + public long getStart() { + return start; + } + + public PageRange setStart(long start) { + this.start = start; + return this; + } + + @XmlElement(name = "End") + public long getEnd() { + return end; + } + + public PageRange setEnd(long end) { + this.end = end; + return this; + } + + public long getLength() { + return end - start + 1; + } + + public PageRange setLength(long value) { + this.end = this.start + value - 1; + return this; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 2483342055871..4dd5a81cf74a4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -46,6 +46,7 @@ import com.microsoft.windowsazure.services.blob.models.ListBlobsResult; import com.microsoft.windowsazure.services.blob.models.ListContainersOptions; import com.microsoft.windowsazure.services.blob.models.ListContainersResult; +import com.microsoft.windowsazure.services.blob.models.PageRange; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesOptions; @@ -528,7 +529,7 @@ public void clearBlobPagesWorks() throws Exception { String blob = "test"; service.createPageBlob(container, blob, 512); - CreateBlobPagesResult result = service.clearBlobPages(container, blob, 0, 511); + CreateBlobPagesResult result = service.clearBlobPages(container, blob, new PageRange(0, 511)); // Assert assertNotNull(result); @@ -550,7 +551,8 @@ public void createBlobPagesWorks() throws Exception { String content = new String(new char[512]); service.createPageBlob(container, blob, 512); - CreateBlobPagesResult result = service.createBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + CreateBlobPagesResult result = service.createBlobPages(container, blob, new PageRange(0, 511), content.length(), + new ByteArrayInputStream(content.getBytes("UTF-8"))); // Assert assertNotNull(result); @@ -572,10 +574,10 @@ public void listBlobRegionsWorks() throws Exception { String content = new String(new char[512]); service.createPageBlob(container, blob, 16384 + 512); - service.createBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.createBlobPages(container, blob, 1024, 1024 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.createBlobPages(container, blob, 8192, 8192 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.createBlobPages(container, blob, 16384, 16384 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlobPages(container, blob, new PageRange(0, 511), content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlobPages(container, blob, new PageRange(1024, 1024 + 511), content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlobPages(container, blob, new PageRange(8192, 8192 + 511), content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlobPages(container, blob, new PageRange(16384, 16384 + 511), content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); ListBlobRegionsResult result = service.listBlobRegions(container, blob); From 7b8381491cc167c74347b462a0b45e182bf95477 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 16:40:55 -0800 Subject: [PATCH 25/29] Update "GetServiceProperties" to follow naming pattern Add "FilterableService" interface --- .../windowsazure/http/FilterableService.java | 5 ++++ .../services/blob/BlobServiceContract.java | 6 ++--- .../implementation/BlobServiceForJersey.java | 2 +- .../models/GetServicePropertiesResult.java | 10 ++++---- .../services/queue/QueueServiceContract.java | 25 ++++++++++--------- .../implementation/QueueServiceForJersey.java | 9 ++++--- .../implementation/QueueServiceImpl.java | 5 ++-- .../models/GetServicePropertiesResult.java | 13 ++++++++++ .../blob/BlobServiceIntegrationTest.java | 6 ++--- .../queue/QueueServiceIntegrationTest.java | 6 ++--- 10 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/FilterableService.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/FilterableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/FilterableService.java new file mode 100644 index 0000000000000..d9c1c628dfe0a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/FilterableService.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.http; + +public interface FilterableService { + T withFilter(ServiceFilter filter); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java index 03f2cb1ca2d2f..162b1d6000239 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java @@ -4,7 +4,7 @@ import java.util.HashMap; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.http.FilterableService; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; @@ -46,9 +46,7 @@ import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; -public interface BlobServiceContract { - BlobServiceContract withFilter(ServiceFilter filter); - +public interface BlobServiceContract extends FilterableService { GetServicePropertiesResult getServiceProperties() throws ServiceException; GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index d8fce0ffb4ac8..feadc09022878 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -253,7 +253,7 @@ public GetServicePropertiesResult getServiceProperties(BlobServiceOptions option WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); GetServicePropertiesResult result = new GetServicePropertiesResult(); - result.setServiceProperties(builder.get(ServiceProperties.class)); + result.setValue(builder.get(ServiceProperties.class)); return result; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java index 8bdcbca5c4443..46285ac71fd62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java @@ -1,13 +1,13 @@ package com.microsoft.windowsazure.services.blob.models; public class GetServicePropertiesResult { - private ServiceProperties serviceProperties; + private ServiceProperties value; - public ServiceProperties getServiceProperties() { - return serviceProperties; + public ServiceProperties getValue() { + return value; } - public void setServiceProperties(ServiceProperties serviceProperties) { - this.serviceProperties = serviceProperties; + public void setValue(ServiceProperties value) { + this.value = value; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java index 7e2f38a346c01..6092ed7483511 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java @@ -3,10 +3,11 @@ import java.util.HashMap; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.http.FilterableService; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.GetServicePropertiesResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; @@ -17,12 +18,10 @@ import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; -public interface QueueServiceContract { - QueueServiceContract withFilter(ServiceFilter filter); +public interface QueueServiceContract extends FilterableService { + GetServicePropertiesResult getServiceProperties() throws ServiceException; - ServiceProperties getServiceProperties() throws ServiceException; - - ServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException; + GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException; void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; @@ -52,11 +51,17 @@ public interface QueueServiceContract { void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException; - UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) throws ServiceException; + UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) + throws ServiceException; - UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, QueueServiceOptions options) + UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, + QueueServiceOptions options) throws ServiceException; + void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException; + + void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException; + ListMessagesResult listMessages(String queue) throws ServiceException; ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException; @@ -65,10 +70,6 @@ UpdateMessageResult updateMessage(String queue, String messageId, String popRece PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException; - void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException; - - void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException; - void clearMessages(String queue) throws ServiceException; void clearMessages(String queue, QueueServiceOptions options) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index 4ef1f2a0ec50f..7f589e5b39ce4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -17,6 +17,7 @@ import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.GetServicePropertiesResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; @@ -120,17 +121,19 @@ private WebResource setCanonicalizedResource(WebResource webResource, String ope return webResource; } - public ServiceProperties getServiceProperties() throws ServiceException { + public GetServicePropertiesResult getServiceProperties() throws ServiceException { return getServiceProperties(new QueueServiceOptions()); } - public ServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { + public GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - return builder.get(ServiceProperties.class); + GetServicePropertiesResult result = new GetServicePropertiesResult(); + result.setValue(builder.get(ServiceProperties.class)); + return result; } public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java index 3b26c801f7ca4..b2710351c0c7d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java @@ -13,6 +13,7 @@ import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; +import com.microsoft.windowsazure.services.queue.models.GetServicePropertiesResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; import com.microsoft.windowsazure.services.queue.models.ListMessagesResult; import com.microsoft.windowsazure.services.queue.models.ListQueuesOptions; @@ -48,7 +49,7 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("blob", e); } - public ServiceProperties getServiceProperties() throws ServiceException { + public GetServicePropertiesResult getServiceProperties() throws ServiceException { try { return service.getServiceProperties(); } @@ -60,7 +61,7 @@ public ServiceProperties getServiceProperties() throws ServiceException { } } - public ServiceProperties getServiceProperties(QueueServiceOptions options) throws ServiceException { + public GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException { try { return service.getServiceProperties(options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java new file mode 100644 index 0000000000000..0d80af3228c6c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java @@ -0,0 +1,13 @@ +package com.microsoft.windowsazure.services.queue.models; + +public class GetServicePropertiesResult { + private ServiceProperties value; + + public ServiceProperties getValue() { + return value; + } + + public void setValue(ServiceProperties value) { + this.value = value; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 4dd5a81cf74a4..f7251430d91ca 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -131,7 +131,7 @@ public void getServiceProppertiesWorks() throws Exception { BlobServiceContract service = config.create(BlobServiceContract.class); // Act - ServiceProperties props = service.getServiceProperties().getServiceProperties(); + ServiceProperties props = service.getServiceProperties().getValue(); // Assert assertNotNull(props); @@ -149,13 +149,13 @@ public void setServiceProppertiesWorks() throws Exception { BlobServiceContract service = config.create(BlobServiceContract.class); // Act - ServiceProperties props = service.getServiceProperties().getServiceProperties(); + ServiceProperties props = service.getServiceProperties().getValue(); props.setDefaultServiceVersion("2009-09-19"); props.getLogging().setRead(true); service.setServiceProperties(props); - props = service.getServiceProperties().getServiceProperties(); + props = service.getServiceProperties().getValue(); // Assert assertNotNull(props); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index fd181af9fedb0..c6dcd331fda81 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -113,7 +113,7 @@ public void getServicePropertiesWorks() throws Exception { QueueServiceContract service = config.create(QueueServiceContract.class); // Act - ServiceProperties props = service.getServiceProperties(); + ServiceProperties props = service.getServiceProperties().getValue(); // Assert assertNotNull(props); @@ -131,12 +131,12 @@ public void setServicePropertiesWorks() throws Exception { QueueServiceContract service = config.create(QueueServiceContract.class); // Act - ServiceProperties props = service.getServiceProperties(); + ServiceProperties props = service.getServiceProperties().getValue(); props.getLogging().setRead(true); service.setServiceProperties(props); - props = service.getServiceProperties(); + props = service.getServiceProperties().getValue(); // Assert assertNotNull(props); From 6031c040f42dd1a366db0a3f787fa489ee7be4e5 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 18:43:09 -0800 Subject: [PATCH 26/29] Eclipse formatting options: force unwrapping lines --- microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs | 4 ++-- microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs index 7f276808d59fd..171b944f2d2ac 100644 --- a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs +++ b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Fri Nov 11 13:45:12 PST 2011 +#Sat Nov 12 18:37:54 PST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -270,7 +270,7 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constan org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=false -org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs index 92fc0239bfd40..0f7349dc40641 100644 --- a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs +++ b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,4 @@ -#Fri Nov 11 13:45:12 PST 2011 +#Sat Nov 12 18:37:54 PST 2011 cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -55,7 +55,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_OneSDK profile -formatter_settings_version=11 +formatter_settings_version=12 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true From 57789ff6200b3ca0df9b3104dde62c5766a88237 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 12 Nov 2011 18:43:32 -0800 Subject: [PATCH 27/29] Reformat files --- .../services/blob/implementation/BlobServiceForJersey.java | 6 ++---- .../windowsazure/services/queue/QueueServiceContract.java | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index feadc09022878..fdf199d3922fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -685,8 +685,7 @@ public void breakLease(String container, String blob, String leaseId, BlobServic } private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, - AccessCondition accessCondition) - throws ServiceException { + AccessCondition accessCondition) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "lease"); webResource = setCanonicalizedResource(webResource, "lease"); @@ -708,8 +707,7 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, PageR return clearBlobPages(container, blob, range, new CreateBlobPagesOptions()); } - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) - throws ServiceException { + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException { return updatePageBlobPagesImpl("clear", container, blob, range, 0, null, options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java index 6092ed7483511..f6cd3798b585a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java @@ -55,8 +55,7 @@ UpdateMessageResult updateMessage(String queue, String messageId, String popRece throws ServiceException; UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, - QueueServiceOptions options) - throws ServiceException; + QueueServiceOptions options) throws ServiceException; void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException; From 8a31ce4857138a5511f3068b990e793db5853c8a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 12:48:49 -0800 Subject: [PATCH 28/29] Added tests for using the root container --- .../blob/BlobServiceIntegrationTest.java | 87 ++++++++++++++++--- 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index f7251430d91ca..b51213337eca6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -55,6 +55,7 @@ public class BlobServiceIntegrationTest extends IntegrationTestBase { private static final String testContainersPrefix = "sdktest-"; private static final String createableContainersPrefix = "csdktest-"; + private static final String BLOB_FOR_ROOT_CONTAINER = "sdktestroot"; private static String CREATEABLE_CONTAINER_1; private static String CREATEABLE_CONTAINER_2; private static String CREATEABLE_CONTAINER_3; @@ -357,6 +358,73 @@ public void listContainersWithPrefixWorks() throws Exception { assertEquals(0, results2.getMaxResults()); } + @Test + public void workingWithRootContainersWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobServiceContract service = config.create(BlobServiceContract.class); + + // + // Ensure root container exists + // + ServiceException error = null; + try { + service.createContainer("$root"); + } + catch (ServiceException e) { + error = e; + } + + // Assert + assertTrue(error == null || error.getHttpStatusCode() == 409); + + // + // Work with root container explicitly ("$root") + // + { + // Act + service.createPageBlob("$root", BLOB_FOR_ROOT_CONTAINER, 512); + ListBlobsResult list = service.listBlobs("$root"); + GetBlobPropertiesResult properties = service.getBlobProperties("$root", BLOB_FOR_ROOT_CONTAINER); + GetBlobMetadataResult metadata = service.getBlobMetadata("$root", BLOB_FOR_ROOT_CONTAINER); + + // Assert + assertNotNull(list); + assertTrue(1 <= list.getBlobs().size()); + assertNotNull(properties); + assertNotNull(metadata); + + // Act + service.deleteBlob("$root", BLOB_FOR_ROOT_CONTAINER); + } + + // + // Work with root container implicitly ("") + // + { + // Act + service.createPageBlob("", BLOB_FOR_ROOT_CONTAINER, 512); + // "$root" must be explicit when listing blobs in the root container + ListBlobsResult list = service.listBlobs("$root"); + GetBlobPropertiesResult properties = service.getBlobProperties("", BLOB_FOR_ROOT_CONTAINER); + GetBlobMetadataResult metadata = service.getBlobMetadata("", BLOB_FOR_ROOT_CONTAINER); + + // Assert + assertNotNull(list); + assertTrue(1 <= list.getBlobs().size()); + assertNotNull(properties); + assertNotNull(metadata); + + // Act + service.deleteBlob("", BLOB_FOR_ROOT_CONTAINER); + } + + // If container was created, delete it + if (error == null) { + service.deleteContainer("$root"); + } + } + @Test public void listBlobsWorks() throws Exception { // Arrange @@ -420,8 +488,7 @@ public void listBlobsWithOptionsWorks() throws Exception { } // Act - ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setIncludeMetadata(true) - .setIncludeSnapshots(true)); + ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setIncludeMetadata(true).setIncludeSnapshots(true)); for (String blob : blobNames) { service.deleteBlob(TEST_CONTAINER_FOR_LISTING, blob); @@ -733,10 +800,10 @@ public void createBlockBlobWithOptionsWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), - new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") - /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") - /* .setContentMD5("1234") */.setContentType("text/plain")); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new CreateBlobOptions() + .setBlobCacheControl("test").setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); @@ -809,10 +876,10 @@ public void getBlockBlobWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), - new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") - /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") - /* .setContentMD5("1234") */.setContentType("text/plain")); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new CreateBlobOptions() + .setBlobCacheControl("test").setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); GetBlobPropertiesResult props = blob.getProperties(); From 7129f1d8deadf24cd508bddd4bb9209946cff127 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 13:37:49 -0800 Subject: [PATCH 29/29] Removing TODO comments Adding "BlobProperties" model --- .../services/blob/BlobServiceContract.java | 6 +- .../implementation/Base64StringAdapter.java | 2 - .../implementation/BlobServiceForJersey.java | 34 ++--- .../blob/implementation/BlobServiceImpl.java | 6 +- .../ContainerACLDateAdapter.java | 2 - .../ContainerACLDateConverter.java | 3 - .../blob/implementation/HmacSHA256Sign.java | 3 - .../implementation/RFC1123DateAdapter.java | 2 - .../implementation/RFC1123DateConverter.java | 3 - .../implementation/SharedKeyLiteFilter.java | 4 - .../models/AccessConditionHeaderType.java | 2 - .../services/blob/models/BlobProperties.java | 122 ++++++++++++++++++ .../blob/models/CreateBlobBlockOptions.java | 1 - ...ult.java => CreateBlobSnapshotResult.java} | 5 +- .../blob/models/GetBlobPropertiesResult.java | 119 +---------------- .../services/blob/models/ListBlobsResult.java | 116 ----------------- .../blob/models/ServiceProperties.java | 5 +- .../implementation/QueueServiceForJersey.java | 3 - .../implementation/SharedKeyLiteFilter.java | 3 - .../queue/models/ServiceProperties.java | 5 +- .../blob/BlobServiceIntegrationTest.java | 104 +++++++++------ 21 files changed, 221 insertions(+), 329 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/{GetBlobSnapshotResult.java => CreateBlobSnapshotResult.java} (87%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java index 162b1d6000239..fe1ce485a51d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java @@ -26,7 +26,7 @@ import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobSnapshotResult; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotResult; import com.microsoft.windowsazure.services.blob.models.GetContainerACLResult; import com.microsoft.windowsazure.services.blob.models.GetContainerPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetServicePropertiesResult; @@ -149,9 +149,9 @@ SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index fdf199d3922fc..9251166e19ae1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -17,6 +17,7 @@ import com.microsoft.windowsazure.services.blob.models.AccessCondition; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; +import com.microsoft.windowsazure.services.blob.models.BlobProperties; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; import com.microsoft.windowsazure.services.blob.models.BlockList; import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; @@ -27,6 +28,7 @@ import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotResult; import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions; import com.microsoft.windowsazure.services.blob.models.DeleteBlobOptions; import com.microsoft.windowsazure.services.blob.models.DeleteContainerOptions; @@ -36,7 +38,6 @@ import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobSnapshotResult; import com.microsoft.windowsazure.services.blob.models.GetContainerACLResult; import com.microsoft.windowsazure.services.blob.models.GetContainerPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetServicePropertiesResult; @@ -72,9 +73,6 @@ public class BlobServiceForJersey implements BlobServiceContract { private final ServiceFilter[] filters; private final SharedKeyLiteFilter filter; - /* - * TODO: How to make "filter" configurable though code? - */ @Inject public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, SharedKeyLiteFilter filter) { @@ -180,15 +178,9 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { } private GetBlobPropertiesResult getBlobPropertiesFromResponse(ClientResponse response) { - GetBlobPropertiesResult properties = new GetBlobPropertiesResult(); - - // Last-Modified + // Properties + BlobProperties properties = new BlobProperties(); properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - - HashMap metadata = getMetadataFromHeaders(response); - properties.setMetadata(metadata); - - // properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); @@ -201,9 +193,17 @@ private GetBlobPropertiesResult getBlobPropertiesFromResponse(ClientResponse res properties.setEtag(response.getHeaders().getFirst("Etag")); if (response.getHeaders().containsKey("x-ms-blob-sequence-number")) { - properties.setSequenceNUmber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + properties.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); } - return properties; + + // Metadata + HashMap metadata = getMetadataFromHeaders(response); + + // Result + GetBlobPropertiesResult result = new GetBlobPropertiesResult(); + result.setMetadata(metadata); + result.setProperties(properties); + return result; } private WebResource getResource(BlobServiceOptions options) { @@ -607,11 +607,11 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) builder.delete(); } - public GetBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); } - public GetBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob).queryParam("comp", "snapshot"); webResource = setCanonicalizedResource(webResource, "snapshot"); @@ -624,7 +624,7 @@ public GetBlobSnapshotResult createBlobSnapshot(String container, String blob, C ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); ThrowIfError(response); - GetBlobSnapshotResult blobSnapshot = new GetBlobSnapshotResult(); + CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); blobSnapshot.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java index 54aa5fabfd365..e4ad60d8c8f14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java @@ -32,7 +32,7 @@ import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobSnapshotResult; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotResult; import com.microsoft.windowsazure.services.blob.models.GetContainerACLResult; import com.microsoft.windowsazure.services.blob.models.GetContainerPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetServicePropertiesResult; @@ -681,7 +681,7 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) } } - public GetBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { try { return service.createBlobSnapshot(container, blob); } @@ -693,7 +693,7 @@ public GetBlobSnapshotResult createBlobSnapshot(String container, String blob) t } } - public GetBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { try { return service.createBlobSnapshot(container, blob, options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java index fc5f4a291f0ad..26315d2f2f40c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java @@ -5,8 +5,6 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; /* - * TODO: Move so some other common package? - * * JAXB adapter for a "not quite" ISO 8601 date time element */ public class ContainerACLDateAdapter extends XmlAdapter { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java index 24154ffcc2ebe..05cc5fb9b4c0f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java @@ -8,8 +8,6 @@ import java.util.TimeZone; /* - * TODO: Move to some other common package? - * * "not quite" ISO 8601 date time conversion routines */ public class ContainerACLDateConverter { @@ -29,7 +27,6 @@ public Date parseNoThrow(String date) { return parse(date); } catch (ParseException e) { - //TODO: Is it better to return null or throw a runtime exception? return null; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java index 5bb7810ccca81..3a41ac996ed19 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java @@ -5,9 +5,6 @@ import com.sun.jersey.core.util.Base64; -/* - * TODO: Move to some other common package? - */ public class HmacSHA256Sign { private final String accessKey; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java index 829eea95ad088..811042bb2cf63 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java @@ -5,8 +5,6 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; /* - * TODO: Move to some other common package? - * * JAXB adapter for RFC 1123 date element */ public class RFC1123DateAdapter extends XmlAdapter { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java index d379144bf4adf..48545adfcb5bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java @@ -8,8 +8,6 @@ import java.util.TimeZone; /* - * TODO: Move to some other common package? - * * RFC 1123 date to string conversion */ public class RFC1123DateConverter { @@ -28,7 +26,6 @@ public Date parseNoThrow(String date) { return parse(date); } catch (ParseException e) { - // TODO: Is it better to return null or throw a runtime exception? return null; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java index 0fe80fe7e4eef..92d21f6d6ae45 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java @@ -17,9 +17,6 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.filter.ClientFilter; -/* - * TODO: Should the "full" shared key signing? - */ public class SharedKeyLiteFilter extends ClientFilter { private static Log log = LogFactory.getLog(SharedKeyLiteFilter.class); @@ -29,7 +26,6 @@ public class SharedKeyLiteFilter extends ClientFilter { public SharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { this.accountName = accountName; - // TODO: How to make this configurable? this.signer = new HmacSHA256Sign(accountKey); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java index 039cfe333b65d..1479e9c862fd9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java @@ -32,8 +32,6 @@ public enum AccessConditionHeaderType { IF_NONE_MATCH; /** - * TODO: Should this be move somewhere else? - * * Returns a string representation of the current value, or an empty string if no value is assigned. * * @return A String that represents the currently assigned value. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java new file mode 100644 index 0000000000000..4bf3039443394 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java @@ -0,0 +1,122 @@ +package com.microsoft.windowsazure.services.blob.models; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; + +public class BlobProperties { + private Date lastModified; + private String etag; + private String contentType; + private long contentLength; + private String contentEncoding; + private String contentLanguage; + private String contentMD5; + private String cacheControl; + private String blobType; + private String leaseStatus; + private long sequenceNumber; + + @XmlElement(name = "Last-Modified") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + @XmlElement(name = "Etag") + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + @XmlElement(name = "Content-Type") + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + @XmlElement(name = "Content-Length") + public long getContentLength() { + return contentLength; + } + + public void setContentLength(long contentLength) { + this.contentLength = contentLength; + } + + @XmlElement(name = "Content-Encoding") + public String getContentEncoding() { + return contentEncoding; + } + + public void setContentEncoding(String contentEncoding) { + this.contentEncoding = contentEncoding; + } + + @XmlElement(name = "Content-Language") + public String getContentLanguage() { + return contentLanguage; + } + + public void setContentLanguage(String contentLanguage) { + this.contentLanguage = contentLanguage; + } + + @XmlElement(name = "Content-MD5") + public String getContentMD5() { + return contentMD5; + } + + public void setContentMD5(String contentMD5) { + this.contentMD5 = contentMD5; + } + + @XmlElement(name = "Cache-Control") + public String getCacheControl() { + return cacheControl; + } + + public void setCacheControl(String cacheControl) { + this.cacheControl = cacheControl; + } + + @XmlElement(name = "BlobType") + public String getBlobType() { + return blobType; + } + + public void setBlobType(String blobType) { + this.blobType = blobType; + } + + @XmlElement(name = "LeaseStatus") + public String getLeaseStatus() { + return leaseStatus; + } + + public void setLeaseStatus(String leaseStatus) { + this.leaseStatus = leaseStatus; + } + + @XmlElement(name = "x-ms-blob-sequence-number") + public long getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java index 713bd99d077b6..8db0409f202dd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java @@ -2,7 +2,6 @@ public class CreateBlobBlockOptions extends BlobServiceOptions { private String leaseId; - // TODO: Should the service layer support computing MD5 for the caller? private String contentMD5; public String getLeaseId() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobSnapshotResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobSnapshotResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java index 5eace6928ae6e..c7732292a56fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobSnapshotResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java @@ -2,10 +2,7 @@ import java.util.Date; -/* - * TODO: Rename to "CreateBlobSnapshotResult"? - */ -public class GetBlobSnapshotResult { +public class CreateBlobSnapshotResult { private String snapshot; private String etag; private Date lastModified; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java index 216a799a70e80..fca6449392624 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java @@ -1,126 +1,17 @@ package com.microsoft.windowsazure.services.blob.models; -import java.util.Date; import java.util.HashMap; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; - -// TODO: Unify this with ListBlobsResults.BlobProperties public class GetBlobPropertiesResult { - private Date lastModified; - private String etag; - private String contentType; - private long contentLength; - private String contentEncoding; - private String contentLanguage; - private String contentMD5; - private String cacheControl; - private String blobType; - private String leaseStatus; - private long sequenceNumber; + private BlobProperties properties; private HashMap metadata = new HashMap(); - @XmlElement(name = "Last-Modified") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - @XmlElement(name = "Etag") - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - @XmlElement(name = "Content-Type") - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - @XmlElement(name = "Content-Length") - public long getContentLength() { - return contentLength; - } - - public void setContentLength(long contentLength) { - this.contentLength = contentLength; - } - - @XmlElement(name = "Content-Encoding") - public String getContentEncoding() { - return contentEncoding; - } - - public void setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - } - - @XmlElement(name = "Content-Language") - public String getContentLanguage() { - return contentLanguage; - } - - public void setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - } - - @XmlElement(name = "Content-MD5") - public String getContentMD5() { - return contentMD5; - } - - public void setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - } - - @XmlElement(name = "Cache-Control") - public String getCacheControl() { - return cacheControl; - } - - public void setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - } - - @XmlElement(name = "BlobType") - public String getBlobType() { - return blobType; - } - - public void setBlobType(String blobType) { - this.blobType = blobType; - } - - @XmlElement(name = "LeaseStatus") - public String getLeaseStatus() { - return leaseStatus; - } - - public void setLeaseStatus(String leaseStatus) { - this.leaseStatus = leaseStatus; - } - - @XmlElement(name = "x-ms-blob-sequence-number") - public long getSequenceNumber() { - return sequenceNumber; + public BlobProperties getProperties() { + return properties; } - public void setSequenceNUmber(long sequenceNUmber) { - this.sequenceNumber = sequenceNUmber; + public void setProperties(BlobProperties properties) { + this.properties = properties; } public HashMap getMetadata() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java index d9b6b76fb36be..4e038f16154eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java @@ -1,7 +1,6 @@ package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; @@ -14,7 +13,6 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.microsoft.windowsazure.services.blob.implementation.MetadataAdapter; -import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") public class ListBlobsResult { @@ -185,118 +183,4 @@ public void setMetadata(HashMap metadata) { this.metadata = metadata; } } - - public static class BlobProperties { - private Date lastModified; - private String etag; - private String contentType; - private String contentLength; - private String contentEncoding; - private String contentLanguage; - private String contentMD5; - private String cacheControl; - private String blobType; - private String leaseStatus; - private String sequenceNUmber; - - @XmlElement(name = "Last-Modified") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - @XmlElement(name = "Etag") - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - @XmlElement(name = "Content-Type") - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - @XmlElement(name = "Content-Length") - public String getContentLength() { - return contentLength; - } - - public void setContentLength(String contentLength) { - this.contentLength = contentLength; - } - - @XmlElement(name = "Content-Encoding") - public String getContentEncoding() { - return contentEncoding; - } - - public void setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - } - - @XmlElement(name = "Content-Language") - public String getContentLanguage() { - return contentLanguage; - } - - public void setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - } - - @XmlElement(name = "Content-MD5") - public String getContentMD5() { - return contentMD5; - } - - public void setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - } - - @XmlElement(name = "Cache-Control") - public String getCacheControl() { - return cacheControl; - } - - public void setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - } - - @XmlElement(name = "BlobType") - public String getBlobType() { - return blobType; - } - - public void setBlobType(String blobType) { - this.blobType = blobType; - } - - @XmlElement(name = "LeaseStatus") - public String getLeaseStatus() { - return leaseStatus; - } - - public void setLeaseStatus(String leaseStatus) { - this.leaseStatus = leaseStatus; - } - - @XmlElement(name = "x-ms-blob-sequence-number") - public String getSequenceNUmber() { - return sequenceNUmber; - } - - public void setSequenceNUmber(String sequenceNUmber) { - this.sequenceNUmber = sequenceNUmber; - } - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java index 4718fb59c34b6..187a272bdccb8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java @@ -5,9 +5,8 @@ @XmlRootElement(name = "StorageServiceProperties") public class ServiceProperties { - //TODO: What should the default value be (null or new Logging())? - private Logging logging; - private Metrics metrics; + private Logging logging = new Logging(); + private Metrics metrics = new Metrics(); private String defaultServiceVersion; @XmlElement(name = "Logging") diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java index 7f589e5b39ce4..67392df8b4f06 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java @@ -43,9 +43,6 @@ public class QueueServiceForJersey implements QueueServiceContract { private final ServiceFilter[] filters; private final SharedKeyLiteFilter filter; - /* - * TODO: How to make "filter" configurable though code? - */ @Inject public QueueServiceForJersey(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.URL) String url, SharedKeyLiteFilter filter) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java index cdc28ca45f9d9..3c25464216964 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java @@ -8,9 +8,6 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.filter.ClientFilter; -/* - * TODO: Should the "full" shared key signing? - */ public class SharedKeyLiteFilter extends ClientFilter { private final com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter blobSharedKeyFilter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java index 42504b51edf07..78fd4cf5d5151 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java @@ -5,9 +5,8 @@ @XmlRootElement(name = "StorageServiceProperties") public class ServiceProperties { - //TODO: What should the default value be (null or new Logging())? - private Logging logging; - private Metrics metrics; + private Logging logging = new Logging(); + private Metrics metrics = new Metrics(); @XmlElement(name = "Logging") public Logging getLogging() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index b51213337eca6..7727c89aa5162 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -26,18 +26,19 @@ import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.blob.models.AccessCondition; +import com.microsoft.windowsazure.services.blob.models.BlobProperties; import com.microsoft.windowsazure.services.blob.models.BlockList; import com.microsoft.windowsazure.services.blob.models.ContainerACL; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotResult; import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult; import com.microsoft.windowsazure.services.blob.models.GetBlobOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions; import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobSnapshotResult; import com.microsoft.windowsazure.services.blob.models.GetContainerPropertiesResult; import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ListBlobBlocksResult; @@ -566,9 +567,15 @@ public void createPageBlobWithOptionsWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); + GetBlobPropertiesResult result = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); // Assert + assertNotNull(result); + + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + + BlobProperties props = result.getProperties(); assertNotNull(props); assertEquals("test", props.getCacheControl()); assertEquals("UTF-8", props.getContentEncoding()); @@ -577,8 +584,6 @@ public void createPageBlobWithOptionsWorks() throws Exception { assertEquals(512, props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("PageBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); @@ -805,9 +810,15 @@ public void createBlockBlobWithOptionsWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); + GetBlobPropertiesResult result = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); // Assert + assertNotNull(result); + + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + + BlobProperties props = result.getProperties(); assertNotNull(props); assertEquals("test", props.getCacheControl()); assertEquals("UTF-8", props.getContentEncoding()); @@ -816,8 +827,6 @@ public void createBlockBlobWithOptionsWorks() throws Exception { assertEquals(content.length(), props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("BlockBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); @@ -834,7 +843,7 @@ public void createBlobSnapshotWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - GetBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob); + CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob); // Assert assertNotNull(snapshot); @@ -853,19 +862,19 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - GetBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob, + CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); - GetBlobPropertiesResult props = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); + GetBlobPropertiesResult result = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); // Assert - assertNotNull(props); - assertEquals(snapshot.getEtag(), props.getEtag()); - assertEquals(snapshot.getLastModified(), props.getLastModified()); - assertTrue(props.getMetadata().containsKey("test")); - assertTrue(props.getMetadata().containsValue("bar")); - assertTrue(props.getMetadata().containsKey("blah")); - assertTrue(props.getMetadata().containsValue("bleah")); + assertNotNull(result); + assertEquals(snapshot.getEtag(), result.getProperties().getEtag()); + assertEquals(snapshot.getLastModified(), result.getProperties().getLastModified()); + assertTrue(result.getMetadata().containsKey("test")); + assertTrue(result.getMetadata().containsValue("bar")); + assertTrue(result.getMetadata().containsKey("blah")); + assertTrue(result.getMetadata().containsValue("bleah")); } @Test @@ -882,9 +891,15 @@ public void getBlockBlobWorks() throws Exception { /* .setContentMD5("1234") */.setContentType("text/plain")); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); - GetBlobPropertiesResult props = blob.getProperties(); + GetBlobPropertiesResult result = blob.getProperties(); // Assert + assertNotNull(result); + + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + + BlobProperties props = result.getProperties(); assertNotNull(props); assertEquals("test", props.getCacheControl()); assertEquals("UTF-8", props.getContentEncoding()); @@ -893,8 +908,6 @@ public void getBlockBlobWorks() throws Exception { assertEquals(content.length(), props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("BlockBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); @@ -915,10 +928,15 @@ public void getPageBlobWorks() throws Exception { /* .setContentMD5("1234") */.setContentType("text/plain")); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); - GetBlobPropertiesResult props = blob.getProperties(); + GetBlobPropertiesResult result = blob.getProperties(); // Assert - assertNotNull(props); + assertNotNull(result); + + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + + BlobProperties props = result.getProperties(); assertEquals("test", props.getCacheControl()); assertEquals("UTF-8", props.getContentEncoding()); assertEquals("en-us", props.getContentLanguage()); @@ -926,8 +944,6 @@ public void getPageBlobWorks() throws Exception { assertEquals(4096, props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("PageBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); @@ -963,7 +979,8 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); try { - service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); + service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", + new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getProperties().getEtag()))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -982,7 +999,8 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); GetBlobPropertiesResult props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); try { - service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); + service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", + new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getProperties().getLastModified()))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -1005,7 +1023,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception // To test for "IfNotModifiedSince", we need to make updates to the blob // until at least 1 second has passed since the blob creation - Date lastModifiedBase = (Date) props.getLastModified().clone(); + Date lastModifiedBase = (Date) props.getProperties().getLastModified().clone(); // +1 second Date lastModifiedNext = new Date(lastModifiedBase.getTime() + 1 * 1000); @@ -1037,10 +1055,15 @@ public void getBlobPropertiesWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 4096); - GetBlobPropertiesResult props = service.getBlobProperties(container, blob); + GetBlobPropertiesResult result = service.getBlobProperties(container, blob); // Assert - // Assert + assertNotNull(result); + + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + + BlobProperties props = result.getProperties(); assertNotNull(props); assertNull(props.getCacheControl()); assertNull(props.getContentEncoding()); @@ -1049,8 +1072,6 @@ public void getBlobPropertiesWorks() throws Exception { assertEquals(4096, props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("PageBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); @@ -1069,7 +1090,6 @@ public void getBlobMetadataWorks() throws Exception { service.createPageBlob(container, blob, 4096, new CreateBlobOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); GetBlobMetadataResult props = service.getBlobMetadata(container, blob); - // Assert // Assert assertNotNull(props); assertNotNull(props.getEtag()); @@ -1096,7 +1116,7 @@ public void setBlobPropertiesWorks() throws Exception { new SetBlobPropertiesOptions().setCacheControl("test").setContentEncoding("UTF-8").setContentLanguage("en-us").setContentLength(512L) .setContentMD5(null).setContentType("text/plain").setSequenceNumberAction("increment")); - GetBlobPropertiesResult props = service.getBlobProperties(container, blob); + GetBlobPropertiesResult getResult = service.getBlobProperties(container, blob); // Assert assertNotNull(result); @@ -1105,6 +1125,12 @@ public void setBlobPropertiesWorks() throws Exception { assertNotNull(result.getSequenceNumber()); assertEquals(1, result.getSequenceNumber().longValue()); + assertNotNull(getResult); + + assertNotNull(getResult.getMetadata()); + assertEquals(0, getResult.getMetadata().size()); + + BlobProperties props = getResult.getProperties(); assertNotNull(props); assertEquals("test", props.getCacheControl()); assertEquals("UTF-8", props.getContentEncoding()); @@ -1112,8 +1138,6 @@ public void setBlobPropertiesWorks() throws Exception { assertEquals("text/plain", props.getContentType()); assertEquals(512, props.getContentLength()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("PageBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); @@ -1178,15 +1202,19 @@ public void copyBlobWorks() throws Exception { service.copyBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5", TEST_CONTAINER_FOR_BLOBS, "test6"); GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5"); - GetBlobPropertiesResult props = blob.getProperties(); + GetBlobPropertiesResult result = blob.getProperties(); // Assert + assertNotNull(result); + + assertNotNull(result.getMetadata()); + assertEquals(0, result.getMetadata().size()); + + BlobProperties props = result.getProperties(); assertNotNull(props); assertEquals(content.length(), props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); - assertNotNull(props.getMetadata()); - assertEquals(0, props.getMetadata().size()); assertNotNull(props.getLastModified()); assertEquals("BlockBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus());